Aller au contenu principal

5. Compléter un lot (updateUnit)

Observé — plusieurs updateUnit sur le même id, depuis les onglets propriété / loyer / surfaces / DPE.

Chaque appel envoie un patch partiel dans UnitInputV2 : seuls les champs fournis sont mis à jour.

5.1 Rattacher l’organisation

Correspond à la section « Propriété / organisation » de l’UI.

mutation updateUnit($id: UUID!, $unit: UnitInputV2!) {
updateUnit(id: $id, unit: $unit) {
id
businessUnit { id name }
}
}
{
"id": "00000000-0000-4000-8000-000000000020",
"unit": {
"businessUnitId": "00000000-0000-4000-8000-000000000002"
}
}

5.2 Surfaces

{
"id": "00000000-0000-4000-8000-000000000020",
"unit": {
"unitSurfaces": [
{
"unitId": "00000000-0000-4000-8000-000000000020",
"surfaceType": "REAL_SURFACE",
"value": 30,
"measurementUnit": "M2",
"measurementSource": "AREA_CERTIFICATE",
"measurementDate": "2026-07-27",
"isReference": true
}
]
}
}
# payload.json = mutation updateUnit de la section 5.1, avec les variables ci-dessus
curl -sS -X POST "$UBLO_GRAPHQL_URL" \
-H "Authorization: Bearer $UBLO_API_TOKEN" \
-H 'Content-Type: application/json' \
-d @payload.json

5.3 Loyer & charges (centimes)

Prérequis : des accountingOperations avec usage: "invoicing" (voir Comptabilité). Les operationId des rentItems pointent vers ces opérations. Fournissez aussi vatCodeId et vatExemptionCodeId (RentItemInput — optionnels aujourd’hui, prévus obligatoires ; listVatCodes / listVatExemptionCodes).

Exemple observé (loyer 1 000,00 € + charges 200,00 € + dépôt 3 000,00 € / 3 mois) :

{
"id": "00000000-0000-4000-8000-000000000020",
"unit": {
"rentReferenceV2": {
"chargesType": "fixed",
"rentItems": [
{
"amount": 100000,
"operationId": "00000000-0000-4000-8000-000000000031",
"vatCodeId": "00000000-0000-4000-8000-000000000201",
"vatExemptionCodeId": "00000000-0000-4000-8000-000000000202",
"vatMention": "not_applicable",
"vatRate": 0,
"vatSpecific": "accounting"
},
{
"amount": 20000,
"operationId": "00000000-0000-4000-8000-000000000032",
"vatCodeId": "00000000-0000-4000-8000-000000000201",
"vatExemptionCodeId": "00000000-0000-4000-8000-000000000202",
"vatMention": "not_applicable",
"vatRate": 0,
"vatSpecific": "accounting"
}
],
"warrantyDepositItem": {
"amount": 300000,
"depositLength": 3,
"operationId": null
}
}
}
}
# payload.json = mutation updateUnit de la section 5.1, avec les variables ci-dessus
curl -sS -X POST "$UBLO_GRAPHQL_URL" \
-H "Authorization: Bearer $UBLO_API_TOKEN" \
-H 'Content-Type: application/json' \
-d @payload.json
Bonne pratique (doc utilisateur)

Renseignez d’abord le plan comptable et les opérations pour que « loyer hors charges » et « charges » apparaissent correctement.

5.4 DPE (EPC)

{
"id": "00000000-0000-4000-8000-000000000020",
"unit": {
"epc": {
"startDate": "2026-07-27",
"endDate": "2036-07-27",
"energyComsumption": 75,
"gazEmission": 7,
"epcNumber": "DPE-EXEMPLE-001",
"pecLabel": "B",
"ghgLabel": "B",
"id": null
},
"documents": {}
}
}
# payload.json = mutation updateUnit de la section 5.1, avec les variables ci-dessus
curl -sS -X POST "$UBLO_GRAPHQL_URL" \
-H "Authorization: Bearer $UBLO_API_TOKEN" \
-H 'Content-Type: application/json' \
-d @payload.json
Orthographe schéma

Le champ capturé est bien energyComsumption (typo historique du schéma).

5.5 Usage / modèle

{
"unit": {
"usage": "private",
"unitTemplateId": "00000000-0000-4000-8000-000000000010"
}
}
# payload.json = mutation updateUnit de la section 5.1, avec les variables ci-dessus
curl -sS -X POST "$UBLO_GRAPHQL_URL" \
-H "Authorization: Bearer $UBLO_API_TOKEN" \
-H 'Content-Type: application/json' \
-d @payload.json

Suite

Créer un propriétaire