{
  "openapi": "3.1.1",
  "info": {
    "title": "ESTATEREAL API",
    "description": "The ESTATEREAL API lets your own systems read and change your company's data — properties and units, contacts,\r\ntenancies, invoices, payments, maintenance, leasing, documents, tasks and reports — so you can connect an existing\r\nsystem step by step.\r\n\r\n## Base address\r\nCall the API on **your company address**, for example `https://{your-subdomain}.estatereal.io`. Every action below starts\r\nwith `/api/v1/`. A key works only on the address of its own company.\r\n\r\n## Getting a key\r\nAn administrator creates a key in **Settings → API keys → Integration API**: give it a name, a staff role, read-only\r\nif it only reads, and an optional last day. The key starts with `erk_` and is shown only once.\r\nSend it in the `X-Api-Key` header, or as `Authorization: Bearer erk_…`. Each key has a role (and can be read-only),\r\nso it can do only what that role may do. Keys are for server-to-server use: never put a key in a web page or a phone app.\r\nThe availability feed (`/api/v1/availability/get`) uses its own Availability key; the two kinds never open each\r\nother's actions. A ready-made Postman collection of these actions: `/api/v1/apidocs/postman` on your company address.\r\n\r\n## The answer envelope\r\nEvery answer has the same shape:\r\n\r\n```json\r\n{ \"status\": 1, \"statusCode\": 200, \"message\": \"Saved.\", \"payload\": { } }\r\n```\r\n\r\n* `status` 1 = done, 0 = not done.\r\n* **A business error is HTTP 200 with `status: 0`.** For example a missing or wrong field (`statusCode` 422, the\r\n  payload names the field), a conflict (409) or a rule that was not met (400). Always check `status`, not only the\r\n  HTTP code.\r\n* Real HTTP codes are used only for **401** (no key, or a wrong, expired or revoked key), **403** (the key's role may\r\n  not do this), **404** (unknown address or record), **429** (too many calls) and **5xx** (a fault on our side — retry\r\n  later).\r\n\r\n## Money, dates and ids\r\nAmounts are whole **cents** (12500 = €125.00). Dates are `yyyy-MM-dd`. Ids are GUIDs.\r\n\r\n## Paging\r\nLists answer 30 rows at a time: `{ \"items\": [ … ], \"pagination\": { \"pageSize\": 30, \"nextCursor\": \"…\", \"hasNext\": true } }`.\r\nSend `nextCursor` back as the `cursor` query value to get the next page; stop when `hasNext` is false. Leave `cursor`\r\nempty for the first page.\r\n\r\n## Retrying writes safely\r\nWrites that list an `Idempotency-Key` header (payments, deposits, invoices, credits, voids, refunds, reversals,\r\nallocations and tenancy create) can be retried without doing the work twice: send a unique value of up to 100\r\ncharacters. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key\r\nwith a different body is refused (409).\r\n\r\n## Rate limits\r\n120 calls per minute per key (default). Over the limit the answer is HTTP 429: wait a little and try again.\r\n\r\n## Versioning\r\n`/api/v1` is frozen: within v1 we only add (new actions, new optional fields, new fields in answers), so ignore\r\nfields you do not know. A breaking change comes as `/api/v2`; v1 then stays for at least 12 months and its answers\r\ncarry `Deprecation` and `Sunset` headers.",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://{subdomain}.estatereal.io",
      "description": "Your ESTATEREAL company address",
      "variables": {
        "subdomain": {
          "default": "your-subdomain",
          "description": "Replace with the subdomain of your ESTATEREAL company account."
        }
      }
    }
  ],
  "paths": {
    "/api/v1/ticket/getlist": {
      "get": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Lists maintenance tickets with filters, 30 at a time.",
        "operationId": "ticketGetList",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "description": "all (default) | open | new | assigned | progress | waiting | done | closed.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the ticket reference, title, property, unit, tenant or contractor.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "Optional: only this unit.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenancyId",
            "in": "query",
            "description": "Optional: only this tenancy.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "contactId",
            "in": "query",
            "description": "Optional: only tickets linked to this contact.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "urgency",
            "in": "query",
            "description": "emergency | high | normal | low | all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "category",
            "in": "query",
            "description": "Optional category (exact).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assignee",
            "in": "query",
            "description": "all (default) | none (unassigned) | a staff user id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "overdueOnly",
            "in": "query",
            "description": "true = only open tickets past their due time.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ticket/get": {
      "get": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Gets one ticket with its history, appointments and costs.",
        "operationId": "ticketGet",
        "parameters": [
          {
            "name": "ticketId",
            "in": "query",
            "description": "The ticket's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "contractors": [],
                    "appointments": [],
                    "costs": [],
                    "ui": {
                      "hide": []
                    },
                    "photos": [],
                    "messages": [],
                    "ticketId": "3fa85f64-5717-4562-b3fc-2c963f66a017",
                    "ref": "MR-000001",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "propertyName": "Building A",
                    "propertyCode": "BLDA",
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a002",
                    "unitRef": "A1",
                    "propertySharedAreaId": null,
                    "sharedAreaName": null,
                    "locationLabel": "BLDA · Unit A1",
                    "tenancyId": null,
                    "tenancyRef": null,
                    "tenantContactId": null,
                    "tenantName": null,
                    "assetId": null,
                    "title": "Leaking tap",
                    "description": "The kitchen tap drips all the time.",
                    "category": "Plumbing",
                    "urgency": "normal",
                    "status": "submitted",
                    "reportedBy": "staff",
                    "accessAvailability": "Weekdays after 17:00",
                    "assigneeUserId": null,
                    "assigneeName": null,
                    "dueBy": "2026-11-13T17:53:13.431",
                    "overdue": false,
                    "stalled": false,
                    "tenantConfirmationRequired": false,
                    "staffConfirmedAt": null,
                    "staffConfirmedByName": null,
                    "tenantConfirmedAt": null,
                    "completionSummary": null,
                    "disputedAt": null,
                    "disputedByName": null,
                    "disputeReason": null,
                    "contractorIds": [],
                    "contractorNames": [],
                    "totalCost": 0,
                    "journalTotal": 0,
                    "nextAppointment": null,
                    "messageCount": 0,
                    "allowedStatuses": [
                      "under_review",
                      "assigned",
                      "cancelled"
                    ],
                    "createdAt": "2026-11-10T17:53:13.431",
                    "createdByName": "Staff name",
                    "updatedAt": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ticket/create": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Reports a new maintenance ticket for a property, unit or shared area.",
        "operationId": "ticketCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTicketCreate"
              },
              "example": {
                "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66b003",
                "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66b002",
                "category": "Plumbing",
                "urgency": "normal",
                "title": "Leaking tap",
                "description": "The kitchen tap drips all the time.",
                "accessAvailability": "Weekdays after 17:00",
                "reportedBy": "staff"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Ticket MR-000001 created.",
                  "payload": {
                    "contractors": [],
                    "appointments": [],
                    "costs": [],
                    "ui": {
                      "hide": []
                    },
                    "photos": [],
                    "messages": [],
                    "ticketId": "3fa85f64-5717-4562-b3fc-2c963f66a017",
                    "ref": "MR-000001",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "propertyName": "Building A",
                    "propertyCode": "BLDA",
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a002",
                    "unitRef": "A1",
                    "propertySharedAreaId": null,
                    "sharedAreaName": null,
                    "locationLabel": "BLDA · Unit A1",
                    "tenancyId": null,
                    "tenancyRef": null,
                    "tenantContactId": null,
                    "tenantName": null,
                    "assetId": null,
                    "title": "Leaking tap",
                    "description": "The kitchen tap drips all the time.",
                    "category": "Plumbing",
                    "urgency": "normal",
                    "status": "submitted",
                    "reportedBy": "staff",
                    "accessAvailability": "Weekdays after 17:00",
                    "assigneeUserId": null,
                    "assigneeName": null,
                    "dueBy": "2026-11-13T17:53:13.431",
                    "overdue": false,
                    "stalled": false,
                    "tenantConfirmationRequired": false,
                    "staffConfirmedAt": null,
                    "staffConfirmedByName": null,
                    "tenantConfirmedAt": null,
                    "completionSummary": null,
                    "disputedAt": null,
                    "disputedByName": null,
                    "disputeReason": null,
                    "contractorIds": [],
                    "contractorNames": [],
                    "totalCost": 0,
                    "journalTotal": 0,
                    "nextAppointment": null,
                    "messageCount": 0,
                    "allowedStatuses": [
                      "under_review",
                      "assigned",
                      "cancelled"
                    ],
                    "createdAt": "2026-11-10T17:53:13.431",
                    "createdByName": "Staff name",
                    "updatedAt": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ticket/edit": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Changes the details of a ticket.",
        "operationId": "ticketEdit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTicketEdit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ticket/setstatus": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Moves a ticket to another status.",
        "operationId": "ticketSetStatus",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTicketStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ticket/close": {
      "post": {
        "tags": [
          "Maintenance"
        ],
        "summary": "Closes a ticket.",
        "operationId": "ticketClose",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTicketRef"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/getlist": {
      "get": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Lists tenancies, newest start date first, 30 at a time.",
        "operationId": "tenancyGetList",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "all | expiring | pending | active | notice_given | ending | ended | cancelled | archived.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "buildingId",
            "in": "query",
            "description": "Optional: only tenancies of this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "expiring",
            "in": "query",
            "description": "true = only live tenancies ending within 60 days.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the tenancy reference, unit, property or tenant names.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/get": {
      "get": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Gets one tenancy with its people, terms and onboarding checklist.",
        "operationId": "tenancyGet",
        "parameters": [
          {
            "name": "tenancyId",
            "in": "query",
            "description": "The tenancy's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "tenants": [
                      {
                        "contactId": "3fa85f64-5717-4562-b3fc-2c963f66a006",
                        "name": "Tenant name",
                        "email": "tenant@example.com",
                        "phone": "",
                        "depositSharePct": null
                      }
                    ],
                    "occupants": [],
                    "guarantors": [],
                    "onboarding": [],
                    "moveOut": null,
                    "termChanges": [],
                    "documentCount": 0,
                    "tenantDetailsMissing": [
                      {
                        "id": "3fa85f64-5717-4562-b3fc-2c963f66a006",
                        "name": "Tenant name",
                        "missing": [
                          "fatherName",
                          "addressStreet",
                          "addressCity",
                          "addressPostcode",
                          "idNumber",
                          "vatNumber",
                          "taxOffice",
                          "phone",
                          "iban",
                          "bankName"
                        ]
                      }
                    ],
                    "portalAccess": [
                      {
                        "contactId": "3fa85f64-5717-4562-b3fc-2c963f66a006",
                        "name": "Tenant name",
                        "email": "tenant@example.com",
                        "status": "none",
                        "invitedAt": null,
                        "activatedAt": null
                      }
                    ],
                    "repairClaims": {
                      "signed": 0,
                      "refused": 0
                    },
                    "money": {
                      "billed": 0,
                      "paid": 0,
                      "outstanding": 0,
                      "overdueCount": 0,
                      "depositPosted": false,
                      "depositHeld": 0,
                      "charges": []
                    },
                    "ui": {
                      "hide": []
                    },
                    "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                    "ref": "T-000001",
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a008",
                    "applicationId": null,
                    "source": "manual",
                    "status": "active",
                    "startDate": "2026-01-01",
                    "endDate": "2027-12-31",
                    "noticeDate": null,
                    "noticeGivenBy": null,
                    "moveOutDate": null,
                    "endReason": null,
                    "rent": 50000,
                    "deposit": 100000,
                    "initialPayment": 0,
                    "dueDay": 5,
                    "rentInterval": "monthly",
                    "dueWeekday": null,
                    "balanceBroughtForward": null,
                    "signedFileName": null,
                    "notes": null,
                    "createdAt": "2026-11-10T17:53:05.676",
                    "updatedAt": null,
                    "unitRef": "A1",
                    "unitType": "apartment",
                    "unitOccupancy": "occupied",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a009",
                    "propertyName": "Building A",
                    "tenantNames": "Tenant name",
                    "tenantIds": [
                      "3fa85f64-5717-4562-b3fc-2c963f66a006"
                    ],
                    "daysToEnd": 416,
                    "expiringSoon": false,
                    "onboardingDone": 0,
                    "onboardingTotal": 0
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/getdocuments": {
      "get": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Lists the documents of one tenancy (agreements and uploaded files).",
        "operationId": "tenancyGetDocuments",
        "parameters": [
          {
            "name": "tenancyId",
            "in": "query",
            "description": "The tenancy's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/create": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Creates a tenancy on a free unit, signed offline (with the signed PDF) or by e-signature.",
        "operationId": "tenancyCreate",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTenancyCreate"
              },
              "example": {
                "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66b002",
                "tenants": [
                  {
                    "firstName": "Tenant",
                    "lastName": "Name",
                    "email": "tenant@example.com",
                    "phone": "+30 210 000 0000"
                  }
                ],
                "tenantType": "employed",
                "startDate": "2026-01-01",
                "endDate": "2027-12-31",
                "rent": 50000,
                "deposit": 100000,
                "dueDay": 5,
                "rentInterval": "monthly",
                "agreementRoute": "offline",
                "signedFile": {
                  "fileName": "agreement.pdf",
                  "contentBase64": "JVBERi0xLjQKJSBleGFtcGxlCiUlRU9G"
                },
                "depositReceived": false
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Tenancy T-000001 created and active.",
                  "payload": {
                    "tenants": [
                      {
                        "contactId": "3fa85f64-5717-4562-b3fc-2c963f66a006",
                        "name": "Tenant name",
                        "email": "tenant@example.com",
                        "phone": "",
                        "depositSharePct": null
                      }
                    ],
                    "occupants": [],
                    "guarantors": [],
                    "onboarding": [],
                    "moveOut": null,
                    "termChanges": [],
                    "documentCount": 0,
                    "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                    "ref": "T-000001",
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a008",
                    "applicationId": null,
                    "source": "manual",
                    "status": "active",
                    "startDate": "2026-01-01",
                    "endDate": "2027-12-31",
                    "noticeDate": null,
                    "noticeGivenBy": null,
                    "moveOutDate": null,
                    "endReason": null,
                    "rent": 50000,
                    "deposit": 100000,
                    "initialPayment": 0,
                    "dueDay": 5,
                    "rentInterval": "monthly",
                    "dueWeekday": null,
                    "balanceBroughtForward": null,
                    "signedFileName": null,
                    "notes": null,
                    "createdAt": "2026-11-10T17:53:05.676",
                    "updatedAt": null,
                    "unitRef": "A1",
                    "unitType": "apartment",
                    "unitOccupancy": "occupied",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a009",
                    "propertyName": "Building A",
                    "tenantNames": "Tenant name",
                    "tenantIds": [
                      "3fa85f64-5717-4562-b3fc-2c963f66a006"
                    ],
                    "daysToEnd": 416,
                    "expiringSoon": false,
                    "onboardingDone": 0,
                    "onboardingTotal": 0
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/changeterms": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Changes the rent, end date or due day of a live tenancy (by amendment agreement when it was signed in the system).",
        "operationId": "tenancyChangeTerms",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTenancyTerms"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/renew": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Renews a tenancy with a new end date and terms (by renewal agreement when it was signed in the system).",
        "operationId": "tenancyRenew",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTenancyTerms"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/givenotice": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Records notice given by the tenant or the landlord; the end date moves to the move-out date.",
        "operationId": "tenancyGiveNotice",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOGiveNotice"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/end": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Ends a live tenancy; the unit becomes vacant unless another open tenancy holds it.",
        "operationId": "tenancyEnd",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOEndTenancy"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/tenancy/cancel": {
      "post": {
        "tags": [
          "Tenancies"
        ],
        "summary": "Cancels a pending tenancy that was never signed or started, with a reason; the unit is released.",
        "operationId": "tenancyCancel",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTenancyReason"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/officetask/getlist": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Lists office tasks with filters, 30 at a time.",
        "operationId": "officeTaskGetList",
        "parameters": [
          {
            "name": "from",
            "in": "query",
            "description": "Optional start (ISO date-time in UTC, included).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Optional end (ISO date-time in UTC, not included).",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "description": "mine | all (all needs the right to see everyone's tasks).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "assigneeUserId",
            "in": "query",
            "description": "Optional: only this staff user's tasks.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "type",
            "in": "query",
            "description": "viewing | handover | inspection | repair | rent_followup | general.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "active | pending | overdue | open | in_progress | done | cancelled.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "hidden",
            "in": "query",
            "description": "Optional: staff user ids (or none) whose tasks are left out, separated by commas.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the title or notes.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "order",
            "in": "query",
            "description": "asc (default) | desc by due time.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/officetask/get": {
      "get": {
        "tags": [
          "Tasks"
        ],
        "summary": "Gets one task.",
        "operationId": "officeTaskGet",
        "parameters": [
          {
            "name": "officeTaskId",
            "in": "query",
            "description": "The task's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "activity": [
                      {
                        "at": "2026-11-10T17:53:15.919",
                        "by": "Staff name",
                        "text": "Task created"
                      }
                    ],
                    "officeTaskId": "3fa85f64-5717-4562-b3fc-2c963f66a019",
                    "title": "Check the boiler",
                    "type": "general",
                    "dueAt": "2026-12-01T09:00:00",
                    "durationMin": 60,
                    "endsAt": "2026-12-01T10:00:00",
                    "assigneeUserId": "3fa85f64-5717-4562-b3fc-2c963f66a020",
                    "assigneeName": "Staff name",
                    "assigneeColour": "#2563eb",
                    "priority": "normal",
                    "status": "open",
                    "overdue": false,
                    "sourceType": null,
                    "sourceId": null,
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "propertyName": "Building A",
                    "propertyUnitId": null,
                    "unitRef": null,
                    "tenancyId": null,
                    "tenancyRef": null,
                    "notes": "Bring the service book.",
                    "completedAt": null,
                    "allowedStatuses": [
                      "in_progress",
                      "done",
                      "cancelled"
                    ],
                    "createdAt": "2026-11-10T17:53:15.919",
                    "createdByName": "Staff name",
                    "updatedAt": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/officetask/create": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Creates a task on the office calendar for a member of staff.",
        "operationId": "officeTaskCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTaskCreate"
              },
              "example": {
                "title": "Check the boiler",
                "type": "general",
                "dueAt": "2026-12-01T09:00:00Z",
                "durationMin": 60,
                "priority": "normal",
                "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66b003",
                "notes": "Bring the service book."
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Task created.",
                  "payload": {
                    "activity": [
                      {
                        "at": "2026-11-10T17:53:15.919",
                        "by": "Staff name",
                        "text": "Task created"
                      }
                    ],
                    "officeTaskId": "3fa85f64-5717-4562-b3fc-2c963f66a019",
                    "title": "Check the boiler",
                    "type": "general",
                    "dueAt": "2026-12-01T09:00:00",
                    "durationMin": 60,
                    "endsAt": "2026-12-01T10:00:00",
                    "assigneeUserId": "3fa85f64-5717-4562-b3fc-2c963f66a020",
                    "assigneeName": "Staff name",
                    "assigneeColour": "#2563eb",
                    "priority": "normal",
                    "status": "open",
                    "overdue": false,
                    "sourceType": null,
                    "sourceId": null,
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "propertyName": "Building A",
                    "propertyUnitId": null,
                    "unitRef": null,
                    "tenancyId": null,
                    "tenancyRef": null,
                    "notes": "Bring the service book.",
                    "completedAt": null,
                    "allowedStatuses": [
                      "in_progress",
                      "done",
                      "cancelled"
                    ],
                    "createdAt": "2026-11-10T17:53:15.919",
                    "createdByName": "Staff name",
                    "updatedAt": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/officetask/setstatus": {
      "post": {
        "tags": [
          "Tasks"
        ],
        "summary": "Changes a task's status.",
        "operationId": "officeTaskSetStatus",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOTaskStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/property/getlist": {
      "get": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Lists the company's properties (buildings and land), 30 at a time.",
        "operationId": "propertyGetList",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the name, code, address, city or area.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "active (default) | inactive | all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [
                      {
                        "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                        "name": "Building A",
                        "code": "BLDA",
                        "kind": "building",
                        "address": "Street name 1",
                        "city": "City name",
                        "postcode": "00000",
                        "area": "",
                        "country": "",
                        "yearBuilt": 2005,
                        "floors": 4,
                        "plotAreaSqm": null,
                        "areaUnit": null,
                        "landlordContactId": null,
                        "landlordName": null,
                        "managedOnBehalf": false,
                        "defaultAgreementTemplateId": null,
                        "notes": null,
                        "isActive": true,
                        "inactiveAt": null,
                        "inactiveReason": null,
                        "isSingleUnit": false,
                        "createdAt": "2026-11-10T17:52:59.443",
                        "updatedAt": null,
                        "unitCount": 0,
                        "occupied": 0,
                        "vacant": 0,
                        "reserved": 0,
                        "monthlyRent": 0,
                        "image": null
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/property/get": {
      "get": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Gets one property with its details.",
        "operationId": "propertyGet",
        "parameters": [
          {
            "name": "propertyId",
            "in": "query",
            "description": "The property's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/property/save": {
      "post": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Adds a property, or changes it when propertyId is sent.",
        "operationId": "propertySave",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOProperty"
              },
              "example": {
                "name": "Building A",
                "code": "BLDA",
                "kind": "building",
                "address": "Street name 1",
                "city": "City name",
                "postcode": "00000",
                "floors": 4,
                "yearBuilt": 2005
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Property created.",
                  "payload": {
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "name": "Building A",
                    "code": "BLDA",
                    "kind": "building",
                    "address": "Street name 1",
                    "city": "City name",
                    "postcode": "00000",
                    "area": "",
                    "country": "",
                    "yearBuilt": 2005,
                    "floors": 4,
                    "plotAreaSqm": null,
                    "areaUnit": null,
                    "landlordContactId": null,
                    "landlordName": null,
                    "managedOnBehalf": false,
                    "defaultAgreementTemplateId": null,
                    "notes": null,
                    "isActive": true,
                    "inactiveAt": null,
                    "inactiveReason": null,
                    "isSingleUnit": false,
                    "createdAt": "2026-11-10T17:52:59.443",
                    "updatedAt": null,
                    "unitCount": 0,
                    "occupied": 0,
                    "vacant": 0,
                    "reserved": 0,
                    "monthlyRent": 0,
                    "image": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/property/setactive": {
      "post": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Makes a property active or inactive (an inactive property is kept but left out of daily lists).",
        "operationId": "propertySetActive",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPropertyActive"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/propertyunit/getlist": {
      "get": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Lists the company's units, or the units of one property, 30 at a time.",
        "operationId": "propertyUnitGetList",
        "parameters": [
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only the units of this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "occupancy",
            "in": "query",
            "description": "vacant | reserved | occupied | all (default).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "active (default) | inactive | all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the unit reference, property name or code, tenant name or unit type.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "unit (default) | building | rent_desc | rent_asc | newest.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/propertyunit/get": {
      "get": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Gets one unit with its details.",
        "operationId": "propertyUnitGet",
        "parameters": [
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "The unit's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a002",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a001",
                    "propertyName": "Building A",
                    "propertyCode": "BLDA",
                    "city": "City name",
                    "ref": "A1",
                    "floor": 1,
                    "unitType": "apartment",
                    "sizeSqm": 65,
                    "bedrooms": 2,
                    "bathrooms": 1,
                    "occupancy": "vacant",
                    "operatingStatus": "ready",
                    "marketRent": 75000,
                    "publicSlug": "blda-a1",
                    "accessNotes": null,
                    "utilities": null,
                    "overallPermille": null,
                    "defaultAgreementTemplateId": null,
                    "isActive": true,
                    "inactiveAt": null,
                    "inactiveReason": null,
                    "inactive": false,
                    "propertyInactive": false,
                    "tenancyId": null,
                    "tenantName": null,
                    "currentRent": null,
                    "tenancyEndDate": null,
                    "features": [],
                    "images": [],
                    "createdAt": "2026-11-10T17:53:02.141",
                    "updatedAt": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/propertyunit/save": {
      "post": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Adds a unit to a property, or changes it when propertyUnitId is sent.",
        "operationId": "propertyUnitSave",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPropertyUnit"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/propertyunit/setactive": {
      "post": {
        "tags": [
          "Properties and units"
        ],
        "summary": "Makes a unit active or inactive.",
        "operationId": "propertyUnitSetActive",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPropertyUnitActive"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/availability/get": {
      "get": {
        "tags": [
          "Availability"
        ],
        "summary": "Lists the units free to rent in a date window, with asking rent, size, rooms and advert link.",
        "operationId": "availabilityGet",
        "parameters": [
          {
            "name": "X-Api-Key",
            "in": "header",
            "description": "The company's Availability API key (starts with erk_).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "First day (yyyy-MM-dd); default today.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Last day (yyyy-MM-dd); at most 366 days after from.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "from": "2026-12-01",
                    "to": "2027-02-28",
                    "pricesShown": true,
                    "items": [
                      {
                        "id": "3fa85f64-5717-4562-b3fc-2c963f66b005",
                        "purpose": "rent",
                        "saleStatus": null,
                        "title": "Two-bedroom flat, first floor",
                        "building": "Building A",
                        "city": "City name",
                        "postcode": "00000",
                        "unitType": "apartment",
                        "bedrooms": 2,
                        "bathrooms": 1,
                        "floor": 1,
                        "size": 65,
                        "areaUnit": "sqm",
                        "askingRent": 75000,
                        "deposit": 150000,
                        "salePrice": null,
                        "currency": "EUR",
                        "availableFrom": "2026-12-01",
                        "minTermMonths": 12,
                        "link": "https://company.estatereal.io/p/two-bedroom-flat-a1"
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/getlist": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Lists invoices (charges) with filters, newest due date first, 30 at a time.",
        "operationId": "chargeGetList",
        "parameters": [
          {
            "name": "ledger",
            "in": "query",
            "description": "rent | common (expenses); empty = both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenancyId",
            "in": "query",
            "description": "Optional: only this tenancy.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "all | open | overdue | paid | void | issued | partially_paid (open = issued, partly paid or overdue).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "period",
            "in": "query",
            "description": "Optional month yyyy-MM the invoice is for.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dueFrom",
            "in": "query",
            "description": "Optional first due date (yyyy-MM-dd, included).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "dueTo",
            "in": "query",
            "description": "Optional last due date (yyyy-MM-dd, included).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the invoice reference, tenant, unit or tenancy reference.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [
                      {
                        "chargeId": "3fa85f64-5717-4562-b3fc-2c963f66a010",
                        "ref": "INV-000001",
                        "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                        "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a008",
                        "ledger": "rent",
                        "kind": "manual",
                        "period": null,
                        "issueDate": "2026-11-10",
                        "dueDate": "2026-03-05",
                        "amount": 12500,
                        "paid": 0,
                        "adjusted": 0,
                        "outstanding": 12500,
                        "status": "issued",
                        "displayStatus": "overdue",
                        "daysOverdue": 250,
                        "description": "Extra cleaning",
                        "voidReason": null,
                        "tenantName": "Tenant name",
                        "unitLabel": "BLDA · A1",
                        "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a009",
                        "propertyName": "Building A",
                        "tenancyRef": "T-000001",
                        "createdAt": "2026-11-10T17:53:07.253",
                        "updatedAt": null,
                        "plannedByOthers": 0,
                        "bucket": null,
                        "lastReminderAt": null,
                        "manualReminderAt": null,
                        "manualReminderByName": null,
                        "taskId": null
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/get": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Gets one invoice with its payments, credits and write-offs.",
        "operationId": "chargeGet",
        "parameters": [
          {
            "name": "chargeId",
            "in": "query",
            "description": "The invoice's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/getopenlist": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Lists the open (not fully paid) invoices of one tenancy, oldest due date first.",
        "operationId": "chargeGetOpenList",
        "parameters": [
          {
            "name": "tenancyId",
            "in": "query",
            "description": "The tenancy's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "ledger",
            "in": "query",
            "description": "rent | common (required).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "excludePaymentId",
            "in": "query",
            "description": "Optional: a payment whose own allocations are left out.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/gettenancymoney": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Gets the money summary of one tenancy: balance per ledger, overdue amount and deposit.",
        "operationId": "chargeGetTenancyMoney",
        "parameters": [
          {
            "name": "tenancyId",
            "in": "query",
            "description": "The tenancy's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/add": {
      "post": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Issues a manual invoice on a tenancy's rent ledger.",
        "operationId": "chargeAdd",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOChargeAdd"
              },
              "example": {
                "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66b001",
                "amount": 12500,
                "dueDate": "2026-03-05",
                "description": "Extra cleaning"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Invoice issued.",
                  "payload": {
                    "chargeId": "3fa85f64-5717-4562-b3fc-2c963f66a010",
                    "ref": "INV-000001",
                    "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                    "propertyUnitId": "3fa85f64-5717-4562-b3fc-2c963f66a008",
                    "ledger": "rent",
                    "kind": "manual",
                    "period": null,
                    "issueDate": "2026-11-10",
                    "dueDate": "2026-03-05",
                    "amount": 12500,
                    "paid": 0,
                    "adjusted": 0,
                    "outstanding": 12500,
                    "status": "issued",
                    "displayStatus": "overdue",
                    "daysOverdue": 250,
                    "description": "Extra cleaning",
                    "voidReason": null,
                    "tenantName": "Tenant name",
                    "unitLabel": "BLDA · A1",
                    "propertyId": "3fa85f64-5717-4562-b3fc-2c963f66a009",
                    "propertyName": "Building A",
                    "tenancyRef": "T-000001",
                    "createdAt": "2026-11-10T17:53:07.253",
                    "updatedAt": null,
                    "plannedByOthers": 0,
                    "bucket": null,
                    "lastReminderAt": null,
                    "manualReminderAt": null,
                    "manualReminderByName": null,
                    "taskId": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/adjust": {
      "post": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Posts a credit note or a write-off on an invoice, with a reason.",
        "operationId": "chargeAdjust",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOChargeAdjust"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/charge/void": {
      "post": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Voids an invoice that has no payments or credits, with a reason.",
        "operationId": "chargeVoid",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOChargeVoid"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/deposit/record": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Records the deposit received for a tenancy (once per tenancy).",
        "operationId": "depositRecord",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTODepositRecord"
              },
              "example": {
                "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66b001",
                "paymentTypeId": "3fa85f64-5717-4562-b3fc-2c963f66b004",
                "receivedOn": "2026-01-01"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Deposit recorded.",
                  "payload": {
                    "depositTransactionId": "3fa85f64-5717-4562-b3fc-2c963f66a013",
                    "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                    "amount": 100000,
                    "journalEntryId": "3fa85f64-5717-4562-b3fc-2c963f66a014",
                    "entryNo": 3,
                    "depositPosted": true
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/deposit/return": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Records the deposit paid back and / or kept at the end of a tenancy.",
        "operationId": "depositReturn",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTODepositReturn"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ledger/getstatement": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Gets the statement of one tenancy: invoices, payments and the running balance.",
        "operationId": "ledgerGetStatement",
        "parameters": [
          {
            "name": "tenancyId",
            "in": "query",
            "description": "The tenancy's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "repairClaims": {
                      "signed": 0,
                      "refused": 0
                    },
                    "tenancy": {
                      "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                      "ref": "T-000001",
                      "status": "active",
                      "rent": 50000,
                      "dueDay": 5,
                      "rentInterval": "monthly",
                      "dueWeekday": null,
                      "startDate": "2026-01-01",
                      "endDate": "2027-12-31"
                    },
                    "tenantName": "Tenant name",
                    "tenantEmail": "tenant@example.com",
                    "unitLabel": "BLDA · A1",
                    "buildingName": "Building A",
                    "company": "Company name",
                    "rent": {
                      "ledger": "rent",
                      "lines": [
                        {
                          "journalEntryId": "3fa85f64-5717-4562-b3fc-2c963f66a015",
                          "entryNo": 1,
                          "date": "2026-11-10",
                          "description": "Invoice INV-000001 · Extra cleaning",
                          "kind": "charge",
                          "debit": 12500,
                          "credit": 0,
                          "balance": 12500
                        },
                        {
                          "journalEntryId": "3fa85f64-5717-4562-b3fc-2c963f66a016",
                          "entryNo": 2,
                          "date": "2026-11-10",
                          "description": "Payment PAY-000001 · Cash",
                          "kind": "payment",
                          "debit": 0,
                          "credit": 50000,
                          "balance": -37500
                        }
                      ],
                      "balance": -37500,
                      "overdue": 0,
                      "daysOverdue": 0,
                      "pending": [],
                      "pendingTotal": 0
                    },
                    "common": {
                      "ledger": "common",
                      "lines": [],
                      "balance": 0,
                      "overdue": 0,
                      "daysOverdue": 0,
                      "pending": [],
                      "pendingTotal": 0
                    },
                    "totalOwed": -37500,
                    "depositHeld": 100000,
                    "generatedAt": "2026-11-10T17:53:13.1072739Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ledger/getbalances": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Lists tenancy balances (what each tenancy owes on each ledger), 30 at a time.",
        "operationId": "ledgerGetBalances",
        "parameters": [
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the tenant, unit, tenancy reference or property.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/ledger/getarrears": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Lists tenancies in arrears with the overdue amount and days, 30 at a time.",
        "operationId": "ledgerGetArrears",
        "parameters": [
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "minDays",
            "in": "query",
            "description": "Optional: only invoices at least this many days overdue.",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the invoice reference, tenant or unit.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/getlist": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Lists payments with filters, newest first, 30 at a time.",
        "operationId": "paymentGetList",
        "parameters": [
          {
            "name": "ledger",
            "in": "query",
            "description": "rent | common (expenses); empty = both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenancyId",
            "in": "query",
            "description": "Optional: only this tenancy.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "all | pending | received | cleared | failed | reversed | refunded.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "paymentTypeId",
            "in": "query",
            "description": "Optional: only this payment type.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Optional first received date (yyyy-MM-dd, included).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Optional last received date (yyyy-MM-dd, included).",
            "schema": {
              "type": "string",
              "format": "date"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the payment reference, bank reference, tenant or unit.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeDeleted",
            "in": "query",
            "description": "true = also list deleted payments.",
            "schema": {
              "type": "boolean"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [
                      {
                        "paymentId": "3fa85f64-5717-4562-b3fc-2c963f66a011",
                        "ref": "PAY-000001",
                        "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                        "ledger": "rent",
                        "amount": 50000,
                        "paymentTypeId": "3fa85f64-5717-4562-b3fc-2c963f66a012",
                        "paymentTypeName": "Cash",
                        "receivedOn": "2026-03-04",
                        "status": "cleared",
                        "bankReference": "TRF-000123",
                        "note": null,
                        "clearedAt": "2026-11-10T17:53:09.678",
                        "isPosted": true,
                        "isDeleted": false,
                        "deletedAt": null,
                        "deleteReason": null,
                        "deletedByName": null,
                        "allocated": 12500,
                        "unallocated": 37500,
                        "editable": false,
                        "tenantName": "Tenant name",
                        "unitLabel": "BLDA · A1",
                        "createdAt": "2026-11-10T17:53:09.403",
                        "allocations": []
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/get": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Gets one payment with what it was set against.",
        "operationId": "paymentGet",
        "parameters": [
          {
            "name": "paymentId",
            "in": "query",
            "description": "The payment's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/getunallocated": {
      "get": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Lists cleared payments that still have money not set against an invoice, 30 at a time.",
        "operationId": "paymentGetUnallocated",
        "parameters": [
          {
            "name": "ledger",
            "in": "query",
            "description": "rent | common (expenses); empty = both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the payment reference, bank reference, tenant or unit.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/allocatechosen": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Sets the unallocated money of a cleared payment against invoices you choose, with a reason.",
        "operationId": "paymentAllocateChosen",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPaymentAllocate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/record": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Records a payment received from a tenant, on the rent or the expenses ledger.",
        "operationId": "paymentRecord",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPayment"
              },
              "example": {
                "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66b001",
                "ledger": "rent",
                "amount": 50000,
                "paymentTypeId": "3fa85f64-5717-4562-b3fc-2c963f66b004",
                "receivedOn": "2026-03-04",
                "bankReference": "TRF-000123",
                "status": "cleared"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Payment recorded.",
                  "payload": {
                    "paymentId": "3fa85f64-5717-4562-b3fc-2c963f66a011",
                    "ref": "PAY-000001",
                    "tenancyId": "3fa85f64-5717-4562-b3fc-2c963f66a007",
                    "ledger": "rent",
                    "amount": 50000,
                    "paymentTypeId": "3fa85f64-5717-4562-b3fc-2c963f66a012",
                    "paymentTypeName": "Cash",
                    "receivedOn": "2026-03-04",
                    "status": "cleared",
                    "bankReference": "TRF-000123",
                    "note": null,
                    "clearedAt": "2026-11-10T17:53:09.678",
                    "isPosted": true,
                    "isDeleted": false,
                    "deletedAt": null,
                    "deleteReason": null,
                    "deletedByName": null,
                    "allocated": 12500,
                    "unallocated": 37500,
                    "editable": false,
                    "tenantName": "Tenant name",
                    "unitLabel": "BLDA · A1",
                    "createdAt": "2026-11-10T17:53:09.403",
                    "allocations": [
                      {
                        "chargeId": "3fa85f64-5717-4562-b3fc-2c963f66a010",
                        "ref": "INV-000001",
                        "amount": 12500
                      }
                    ]
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/reverse": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Reverses a posted payment (for example a bounced transfer); its invoices open again.",
        "operationId": "paymentReverse",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPaymentReason"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/payment/refund": {
      "post": {
        "tags": [
          "Payments, deposits and ledger"
        ],
        "summary": "Refunds a posted payment to the tenant; its invoices open again.",
        "operationId": "paymentRefund",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "description": "Optional. A unique value (up to 100 characters) for this change. A repeat with the same key within 24 hours returns the first answer and changes nothing; the same key with another body is refused (statusCode 409).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOPaymentReason"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/getlist": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Lists rental applications with filters, 30 at a time.",
        "operationId": "applicationGetList",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "submitted | under_review | info_requested | approved | rejected | withdrawn | archived | draft; empty or all = every status but draft and archived.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "Optional: only this unit.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "applicantType",
            "in": "query",
            "description": "employed | self_employed | student | intern.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "from",
            "in": "query",
            "description": "Optional first submitted date (yyyy-MM-dd).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "to",
            "in": "query",
            "description": "Optional last submitted date (yyyy-MM-dd, the whole day).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "description": "newest (default) | score_desc | score_asc (scores need the screening permission).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the reference, applicant name or email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/get": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Gets one application.",
        "operationId": "applicationGet",
        "parameters": [
          {
            "name": "applicationId",
            "in": "query",
            "description": "The application's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/startreview": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Moves a submitted application to under review.",
        "operationId": "applicationStartReview",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOApplicationRef"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/decide": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Approves or rejects an application, with a reason.",
        "operationId": "applicationDecide",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTODecision"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/withdraw": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Records that the applicant withdrew the application.",
        "operationId": "applicationWithdraw",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOApplicationText"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/application/archive": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Archives a rejected or withdrawn application.",
        "operationId": "applicationArchive",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOApplicationRef"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/listing/getlist": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Lists the company's listings (adverts), 30 at a time.",
        "operationId": "listingGetList",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "draft | active | paused | closed; empty = all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the title, unit, property or city.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/listing/get": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Gets one listing with its details.",
        "operationId": "listingGet",
        "parameters": [
          {
            "name": "publicListingId",
            "in": "query",
            "description": "The listing's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/listing/setstatus": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Publishes, pauses, re-opens or closes a listing (allowed moves only).",
        "operationId": "listingSetStatus",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOListingStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/viewing/getlist": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Lists viewings with filters, 30 at a time.",
        "operationId": "viewingGetList",
        "parameters": [
          {
            "name": "when",
            "in": "query",
            "description": "upcoming (default) | past | all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "requested | scheduled | completed | cancelled | no_show | closed.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "publicListingId",
            "in": "query",
            "description": "Optional: only this listing.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "Optional: only this unit.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the visitor's name or email.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/viewing/get": {
      "get": {
        "tags": [
          "Leasing"
        ],
        "summary": "Gets one viewing.",
        "operationId": "viewingGet",
        "parameters": [
          {
            "name": "viewingId",
            "in": "query",
            "description": "The viewing's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/viewing/setstatus": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Moves a viewing to another status (allowed moves only); the visitor is emailed.",
        "operationId": "viewingSetStatus",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOViewingStatus"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/viewing/reschedule": {
      "post": {
        "tags": [
          "Leasing"
        ],
        "summary": "Moves a viewing to a new date and time; the visitor is emailed.",
        "operationId": "viewingReschedule",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOViewingReschedule"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/unitinvoice/getlist": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Lists unit invoices (costs charged to a unit's tenant on the expenses ledger), 30 at a time.",
        "operationId": "unitInvoiceGetList",
        "parameters": [
          {
            "name": "status",
            "in": "query",
            "description": "all | draft | open | paid.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "source",
            "in": "query",
            "description": "manual | utility | period | housekeeping | all.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Optional text to look for in the invoice reference, tenant, unit or a line.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/unitinvoice/get": {
      "get": {
        "tags": [
          "Charges and invoices"
        ],
        "summary": "Gets one unit invoice with its lines.",
        "operationId": "unitInvoiceGet",
        "parameters": [
          {
            "name": "unitInvoiceId",
            "in": "query",
            "description": "The unit invoice's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/document/getlist": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Lists the documents attached to one or more records, 30 at a time.",
        "operationId": "documentGetList",
        "parameters": [
          {
            "name": "refs",
            "in": "query",
            "description": "Required: 1 to 100 records as type:id, separated by commas (type = property | property_unit | tenancy | contact | handover | asset).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [
                      {
                        "documentId": "3fa85f64-5717-4562-b3fc-2c963f66a018",
                        "name": "inventory.pdf",
                        "category": "other",
                        "tag": "Other",
                        "visibility": "internal",
                        "version": 1,
                        "sizeKb": 1,
                        "locked": false,
                        "createdAt": "2026-11-10T17:53:14.81",
                        "createdByName": "Staff name",
                        "unitRef": "A1",
                        "handoverId": null
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/document/getlink": {
      "get": {
        "tags": [
          "Documents"
        ],
        "summary": "Gets a short-lived link to download one document.",
        "operationId": "documentGetLink",
        "parameters": [
          {
            "name": "documentId",
            "in": "query",
            "description": "The document's id. The link works for 5 minutes.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/document/upload": {
      "post": {
        "tags": [
          "Documents"
        ],
        "summary": "Uploads a file (base64 in the JSON body) and attaches it to a record.",
        "operationId": "documentUpload",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTODocumentUpload"
              },
              "example": {
                "recordType": "tenancy",
                "recordId": "3fa85f64-5717-4562-b3fc-2c963f66b001",
                "fileName": "inventory.pdf",
                "contentBase64": "JVBERi0xLjQKJSBleGFtcGxlCiUlRU9G",
                "kind": "other",
                "visibility": "internal"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "File attached.",
                  "payload": {
                    "documentId": "3fa85f64-5717-4562-b3fc-2c963f66a018",
                    "name": "inventory.pdf",
                    "category": "other",
                    "tag": "Other",
                    "visibility": "internal",
                    "version": 1,
                    "sizeKb": 1,
                    "locked": false,
                    "createdAt": "2026-11-10T17:53:14.8106577Z",
                    "createdByName": "Staff name",
                    "unitRef": null,
                    "handoverId": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/report/get": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Gets the reports page figures for the chosen filters.",
        "operationId": "reportGet",
        "parameters": [
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "Optional: only this unit (of the property).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenancyId",
            "in": "query",
            "description": "Optional: only this tenancy.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "current | ending | ended (tenancies).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "responsible",
            "in": "query",
            "description": "Optional: user:{id} (staff) or contact:{id} (contractor).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "months",
            "in": "query",
            "description": "1 to 24 months back (default 6).",
            "schema": {
              "pattern": "^-?(?:0|[1-9]\\d*)$",
              "type": [
                "integer",
                "string"
              ],
              "format": "int32"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "buildings": [],
                    "totals": {
                      "units": 2,
                      "occupied": 1,
                      "vacant": 1,
                      "reserved": 0,
                      "occupancyPct": 50
                    },
                    "occupancy": [
                      {
                        "building": "Building A",
                        "vacant": 1,
                        "reserved": 0,
                        "occupied": 0
                      },
                      {
                        "building": "Building A",
                        "vacant": 0,
                        "reserved": 0,
                        "occupied": 1
                      }
                    ],
                    "collection": [
                      {
                        "month": "2026-06",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      },
                      {
                        "month": "2026-07",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      },
                      {
                        "month": "2026-08",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      },
                      {
                        "month": "2026-09",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      },
                      {
                        "month": "2026-10",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      },
                      {
                        "month": "2026-11",
                        "rentDue": 0,
                        "rentCollected": 0,
                        "commonDue": 0,
                        "commonCollected": 0
                      }
                    ],
                    "finance": {
                      "rent": {
                        "due": 0,
                        "collected": 0,
                        "outstanding": 0,
                        "overdue": 0
                      },
                      "common": {
                        "due": 0,
                        "collected": 0,
                        "outstanding": 0,
                        "overdue": 0
                      }
                    },
                    "arrears": [
                      {
                        "bucket": "0–30 days",
                        "rent": 0,
                        "common": 0
                      },
                      {
                        "bucket": "31–60 days",
                        "rent": 0,
                        "common": 0
                      },
                      {
                        "bucket": "60+ days",
                        "rent": 0,
                        "common": 0
                      }
                    ],
                    "arrearsTotal": 0,
                    "arrearsCount": 0,
                    "arrearsRows": [],
                    "viewings": [],
                    "applications": [],
                    "maintenance": {
                      "open": 1,
                      "overdue": 0,
                      "highPriority": 0,
                      "stalled": 0,
                      "contractorAssigned": 0
                    },
                    "byContractor": [],
                    "alerts": [],
                    "ui": {
                      "hide": []
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/report/getarrears": {
      "get": {
        "tags": [
          "Reports"
        ],
        "summary": "Lists the arrears rows of the report, 30 at a time.",
        "operationId": "reportGetArrears",
        "parameters": [
          {
            "name": "propertyId",
            "in": "query",
            "description": "Optional: only this property.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "propertyUnitId",
            "in": "query",
            "description": "Optional: only this unit (of the property).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "tenancyId",
            "in": "query",
            "description": "Optional: only this tenancy.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "current | ending | ended (tenancies).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "ledger",
            "in": "query",
            "description": "rent | common (expenses); empty = both.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "cursor",
            "in": "query",
            "description": "Paging: leave empty for the first page, then send pagination.nextCursor of the previous answer (stop when hasNext is false).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/contact/getlist": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Lists contacts (people and organisations) with filters, 30 at a time.",
        "operationId": "contactGetList",
        "parameters": [
          {
            "name": "Roles",
            "in": "query",
            "description": "Comma list of roles in snake_case (tenant,landlord …). Empty = every role.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Search",
            "in": "query",
            "description": "Optional text to look for in the name, organisation, email or phone.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "State",
            "in": "query",
            "description": "active (default) | inactive | all",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Cursor",
            "in": "query",
            "description": "Paging: empty for the first page, then the nextCursor of the previous answer.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 200,
                  "message": "Done.",
                  "payload": {
                    "items": [
                      {
                        "contactId": "3fa85f64-5717-4562-b3fc-2c963f66a003",
                        "ownerId": "3fa85f64-5717-4562-b3fc-2c963f66a004",
                        "addedByCompanyId": "3fa85f64-5717-4562-b3fc-2c963f66a005",
                        "addedBy": "Company name",
                        "name": "Tenant Name",
                        "kind": "person",
                        "firstName": "Tenant",
                        "lastName": "Name",
                        "orgName": null,
                        "email": "tenant@example.com",
                        "phone": "+302100000000",
                        "roles": [
                          "tenant"
                        ],
                        "preferredChannel": "email",
                        "marketingConsent": false,
                        "marketingConsentAt": null,
                        "emailVerifiedAt": null,
                        "phoneVerifiedAt": null,
                        "notes": null,
                        "managementFeePct": null,
                        "fatherName": null,
                        "idNumber": null,
                        "vatNumber": null,
                        "taxOffice": null,
                        "addressStreet": null,
                        "addressCity": null,
                        "addressPostcode": null,
                        "iban": null,
                        "bankName": null,
                        "ibanMasked": false,
                        "idNumberMasked": false,
                        "isActive": true,
                        "inactiveAt": null,
                        "inactiveReason": null,
                        "createdAt": "2026-11-10T17:53:03.958",
                        "updatedAt": null,
                        "onOpenTenancy": false,
                        "tenantDetailsMissing": [
                          "fatherName",
                          "addressStreet",
                          "addressCity",
                          "addressPostcode",
                          "idNumber",
                          "vatNumber",
                          "taxOffice",
                          "iban",
                          "bankName"
                        ],
                        "duplicateIds": []
                      }
                    ],
                    "pagination": {
                      "pageSize": 30,
                      "nextCursor": null,
                      "hasNext": false
                    },
                    "duplicates": {
                      "items": [],
                      "more": false
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/contact/get": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Gets one contact with its roles and details.",
        "operationId": "contactGet",
        "parameters": [
          {
            "name": "contactId",
            "in": "query",
            "description": "The contact's id.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/contact/findmatches": {
      "get": {
        "tags": [
          "Contacts"
        ],
        "summary": "Finds contacts that already use this email or phone, so the same person is not added twice.",
        "operationId": "contactFindMatches",
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "description": "Email to look for (compared without case).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "phone",
            "in": "query",
            "description": "Phone to look for (only digits and + are compared).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "excludeId",
            "in": "query",
            "description": "Optional: a contact to leave out (the one being edited).",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/contact/save": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Adds a contact, or changes it when contactId is sent.",
        "operationId": "contactSave",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOContactSave"
              },
              "example": {
                "kind": "person",
                "firstName": "Tenant",
                "lastName": "Name",
                "email": "tenant@example.com",
                "phone": "+30 210 000 0000",
                "roles": [
                  "tenant"
                ],
                "preferredChannel": "email"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                },
                "example": {
                  "status": 1,
                  "statusCode": 201,
                  "message": "Contact added.",
                  "payload": {
                    "contactId": "3fa85f64-5717-4562-b3fc-2c963f66a003",
                    "ownerId": "3fa85f64-5717-4562-b3fc-2c963f66a004",
                    "addedByCompanyId": "3fa85f64-5717-4562-b3fc-2c963f66a005",
                    "addedBy": "Company name",
                    "name": "Tenant Name",
                    "kind": "person",
                    "firstName": "Tenant",
                    "lastName": "Name",
                    "orgName": null,
                    "email": "tenant@example.com",
                    "phone": "+302100000000",
                    "roles": [
                      "tenant"
                    ],
                    "preferredChannel": "email",
                    "marketingConsent": false,
                    "marketingConsentAt": null,
                    "emailVerifiedAt": null,
                    "phoneVerifiedAt": null,
                    "notes": null,
                    "managementFeePct": null,
                    "fatherName": null,
                    "idNumber": null,
                    "vatNumber": null,
                    "taxOffice": null,
                    "addressStreet": null,
                    "addressCity": null,
                    "addressPostcode": null,
                    "iban": null,
                    "bankName": null,
                    "ibanMasked": false,
                    "idNumberMasked": false,
                    "isActive": true,
                    "inactiveAt": null,
                    "inactiveReason": null,
                    "createdAt": "2026-11-10T17:53:03.958",
                    "updatedAt": null,
                    "onOpenTenancy": false,
                    "tenantDetailsMissing": [
                      "fatherName",
                      "addressStreet",
                      "addressCity",
                      "addressPostcode",
                      "idNumber",
                      "vatNumber",
                      "taxOffice",
                      "iban",
                      "bankName"
                    ],
                    "duplicateIds": []
                  }
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    },
    "/api/v1/contact/setactive": {
      "post": {
        "tags": [
          "Contacts"
        ],
        "summary": "Makes a contact active or inactive.",
        "operationId": "contactSetActive",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DTOContactActive"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "The envelope. status 1 = done; status 0 = not done (business error) — still HTTP 200, see statusCode and message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Envelope"
                }
              }
            }
          },
          "401": {
            "description": "No key, or the key is wrong, expired or revoked."
          },
          "403": {
            "description": "The key's role may not do this."
          },
          "404": {
            "description": "Unknown address (or a switched-off area)."
          },
          "429": {
            "description": "Too many calls for this key; wait a little and try again."
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "DTOAllocation": {
        "type": "object",
        "properties": {
          "chargeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The invoice's id.",
            "format": "uuid"
          },
          "amount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents set against this invoice.",
            "format": "int64"
          }
        },
        "description": "One planned allocation (cents)."
      },
      "DTOApplicationRef": {
        "type": "object",
        "properties": {
          "applicationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The application's id.",
            "format": "uuid"
          }
        }
      },
      "DTOApplicationText": {
        "type": "object",
        "properties": {
          "applicationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The application's id.",
            "format": "uuid"
          },
          "text": {
            "type": [
              "null",
              "string"
            ],
            "description": "The note or reason."
          }
        }
      },
      "DTOChargeAdd": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "amount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents, above zero (12500 = €125.00).",
            "format": "int64"
          },
          "dueDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "Due date (yyyy-MM-dd).",
            "format": "date"
          },
          "issueDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional issue date (yyyy-MM-dd); default today.",
            "format": "date"
          },
          "description": {
            "type": [
              "null",
              "string"
            ],
            "description": "What the invoice is for (up to 300 characters)."
          }
        },
        "description": "A manual invoice on a tenancy's rent ledger."
      },
      "DTOChargeAdjust": {
        "type": "object",
        "properties": {
          "chargeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The invoice's id.",
            "format": "uuid"
          },
          "kind": {
            "type": [
              "null",
              "string"
            ],
            "description": "credit | write_off"
          },
          "amount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents, at most the invoice's open balance.",
            "format": "int64"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why (at least 5 characters); kept on the record's history."
          }
        },
        "description": "Credit note or write-off on an invoice (RENT-004, RENT-012)."
      },
      "DTOChargeVoid": {
        "type": "object",
        "properties": {
          "chargeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The invoice's id.",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why (at least 5 characters); kept on the record's history."
          }
        },
        "description": "Void an invoice nothing was paid or credited on (mirror journal entry, reason required)."
      },
      "DTOContactActive": {
        "type": "object",
        "properties": {
          "contactId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The contact's id.",
            "format": "uuid"
          },
          "active": {
            "type": "boolean",
            "description": "true = active again; false = inactive."
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why it is made inactive."
          }
        }
      },
      "DTOContactSave": {
        "type": "object",
        "properties": {
          "contactId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Empty to add a contact; the contact's id to change it.",
            "format": "uuid"
          },
          "kind": {
            "type": [
              "null",
              "string"
            ],
            "description": "person | organization"
          },
          "firstName": {
            "type": [
              "null",
              "string"
            ],
            "description": "First name (people)."
          },
          "lastName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Last name (people)."
          },
          "orgName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Organisation name (organisations)."
          },
          "email": {
            "type": [
              "null",
              "string"
            ],
            "description": "Email address."
          },
          "phone": {
            "type": [
              "null",
              "string"
            ],
            "description": "Phone number, with the country code."
          },
          "roles": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Roles in snake_case."
          },
          "preferredChannel": {
            "type": [
              "null",
              "string"
            ],
            "description": "email | sms | both"
          },
          "marketingConsent": {
            "type": "boolean",
            "description": "true when the contact agreed to marketing messages."
          },
          "notes": {
            "type": [
              "null",
              "string"
            ],
            "description": "Internal notes (never shown to tenants)."
          },
          "managementFeePct": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Landlords: the management fee in percent (0 to 100).",
            "format": "double"
          },
          "fatherName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Father's name (used on Greek agreements)."
          },
          "idNumber": {
            "type": [
              "null",
              "string"
            ],
            "description": "Identity card or passport number."
          },
          "vatNumber": {
            "type": [
              "null",
              "string"
            ],
            "description": "Tax (VAT) number."
          },
          "taxOffice": {
            "type": [
              "null",
              "string"
            ],
            "description": "Tax office."
          },
          "addressStreet": {
            "type": [
              "null",
              "string"
            ],
            "description": "Street and number."
          },
          "addressCity": {
            "type": [
              "null",
              "string"
            ],
            "description": "City."
          },
          "addressPostcode": {
            "type": [
              "null",
              "string"
            ],
            "description": "Postcode."
          },
          "iban": {
            "type": [
              "null",
              "string"
            ],
            "description": "Bank account (IBAN)."
          },
          "bankName": {
            "type": [
              "null",
              "string"
            ],
            "description": "Bank name."
          }
        },
        "description": "Create (no ContactId) or edit a contact."
      },
      "DTODecision": {
        "type": "object",
        "properties": {
          "applicationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The application's id.",
            "format": "uuid"
          },
          "outcome": {
            "type": [
              "null",
              "string"
            ],
            "description": "approved | rejected"
          },
          "rationale": {
            "type": [
              "null",
              "string"
            ],
            "description": "The reason for the decision (required)."
          }
        },
        "description": "APPL-009: approve or reject with a reason."
      },
      "DTODepositRecord": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "paymentTypeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "How the deposit was paid (payment type id).",
            "format": "uuid"
          },
          "receivedOn": {
            "type": [
              "null",
              "string"
            ],
            "description": "Date the deposit was received (yyyy-MM-dd).",
            "format": "date"
          }
        },
        "description": "Deposit received for a tenancy (contract shared with the tenancy screens). Amount = the tenancy's deposit."
      },
      "DTODepositReturn": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "refund": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents paid back to the tenant.",
            "format": "int64"
          },
          "kept": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents kept (for damage, unpaid rent …).",
            "format": "int64"
          },
          "paymentTypeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "How the refund is paid (payment type id).",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why an amount is kept."
          }
        },
        "description": "Deposit paid back and / or kept at the end of a tenancy (ACCT-003)."
      },
      "DTODocumentUpload": {
        "type": "object",
        "properties": {
          "recordType": {
            "type": [
              "null",
              "string"
            ],
            "description": "property | property_unit | tenancy | contact | handover | asset | work_order"
          },
          "recordId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The id of the record the file belongs to.",
            "format": "uuid"
          },
          "fileName": {
            "type": [
              "null",
              "string"
            ],
            "description": "File name with its extension, e.g. lease.pdf."
          },
          "contentBase64": {
            "type": [
              "null",
              "string"
            ],
            "description": "The file content in base64 (a data: URL is also accepted)."
          },
          "kind": {
            "type": [
              "null",
              "string"
            ],
            "description": "invoice | manual | warranty | photo | certificate | other. Empty = no finer label."
          },
          "visibility": {
            "type": [
              "null",
              "string"
            ],
            "description": "internal (default) | tenant"
          }
        },
        "description": "Attach one file to a record. The file comes as a data URL, like the other uploads."
      },
      "DTOEndTenancy": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "endDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "End date (yyyy-MM-dd)."
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional reason."
          }
        }
      },
      "DTOGiveNotice": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "noticeDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "Date the notice was given (yyyy-MM-dd)."
          },
          "moveOutDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "Move-out date (yyyy-MM-dd); becomes the end date."
          },
          "givenBy": {
            "type": [
              "null",
              "string"
            ],
            "description": "tenant | landlord"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional reason."
          }
        }
      },
      "DTOListingStatus": {
        "type": "object",
        "properties": {
          "publicListingId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The listing's id.",
            "format": "uuid"
          },
          "status": {
            "type": [
              "null",
              "string"
            ],
            "description": "active | paused | closed"
          }
        }
      },
      "DTOPayment": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "ledger": {
            "type": [
              "null",
              "string"
            ],
            "description": "rent | common"
          },
          "amount": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Amount in cents, above zero.",
            "format": "int64"
          },
          "paymentTypeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The payment type (cash, bank transfer …) id.",
            "format": "uuid"
          },
          "receivedOn": {
            "type": [
              "null",
              "string"
            ],
            "description": "Date the money was received (yyyy-MM-dd).",
            "format": "date"
          },
          "bankReference": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional bank reference."
          },
          "note": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional note."
          },
          "status": {
            "type": [
              "null",
              "string"
            ],
            "description": "pending | received | cleared"
          },
          "allocations": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/DTOAllocation"
            },
            "description": "Optional: which invoices it pays. Left out = oldest invoices first; an empty list = keep it all as credit."
          },
          "sendReceipt": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "Q3.11: \"Send receipt to tenant\" (unticked = no email). Recording a payment only; ignored on a change."
          }
        },
        "description": "Record a payment (PAYM-001). Allocations null = oldest invoices first; empty list = keep it all as credit."
      },
      "DTOPaymentAllocate": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The payment's id.",
            "format": "uuid"
          },
          "allocations": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/DTOAllocation"
            },
            "description": "The invoices (of the same tenancy and ledger) and the amount for each."
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why (at least 5 characters); kept on the record's history."
          }
        },
        "description": "Review queue (BMS-82): set a cleared payment's money left over against chosen invoices of its own tenancy and ledger."
      },
      "DTOPaymentReason": {
        "type": "object",
        "properties": {
          "paymentId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The payment's id.",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why (at least 5 characters); kept on the record's history."
          }
        },
        "description": "Fail (unposted), delete (any payment, soft, D-113), reverse or refund (posted) a payment — always with a reason."
      },
      "DTOProperty": {
        "type": "object",
        "properties": {
          "propertyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Empty to add a property; the property's id to change it.",
            "format": "uuid"
          },
          "name": {
            "type": [
              "null",
              "string"
            ],
            "description": "Name of the building or land."
          },
          "code": {
            "type": [
              "null",
              "string"
            ],
            "description": "Short code, unique in the company."
          },
          "kind": {
            "type": [
              "null",
              "string"
            ],
            "description": "building | land (default building on create; unchanged when left out on edit)."
          },
          "address": {
            "type": [
              "null",
              "string"
            ],
            "description": "Street and number."
          },
          "city": {
            "type": [
              "null",
              "string"
            ],
            "description": "City."
          },
          "postcode": {
            "type": [
              "null",
              "string"
            ],
            "description": "Postcode."
          },
          "area": {
            "type": [
              "null",
              "string"
            ],
            "description": "Stage 16: district / neighbourhood for the listings site (optional)."
          },
          "country": {
            "type": [
              "null",
              "string"
            ],
            "description": "Stage 16: ISO country code, e.g. GR (optional)."
          },
          "yearBuilt": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Year built.",
            "format": "int32"
          },
          "floors": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Number of floors.",
            "format": "int32"
          },
          "plotAreaSqm": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Plot area in square metres.",
            "format": "double"
          },
          "areaUnit": {
            "type": [
              "null",
              "string"
            ],
            "description": "sqm | sqft | sqyd; empty = the company default."
          },
          "landlordContactId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the landlord (a contact with the landlord role).",
            "format": "uuid"
          },
          "managedOnBehalf": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "true when the company manages it for another landlord."
          },
          "defaultAgreementTemplateId": {
            "type": [
              "null",
              "string"
            ],
            "description": "AGRM-012. Accepted but not stored yet: agreement templates arrive in Stage 7."
          },
          "notes": {
            "type": [
              "null",
              "string"
            ],
            "description": "Internal notes."
          },
          "isSingleUnit": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "D-122: \"This property is one unit (e.g. a house or plot)\". Null = unchanged on edit, off on create."
          },
          "images": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Photos in order (first = cover): data URLs for new photos, read links for kept ones. Null = leave photos as they are."
          }
        },
        "description": "Add (no propertyId) or edit a building. Enums in snake_case (prototype)."
      },
      "DTOPropertyActive": {
        "type": "object",
        "properties": {
          "propertyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The property's id.",
            "format": "uuid"
          },
          "active": {
            "type": "boolean",
            "description": "true = active again; false = inactive."
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why it is made inactive (required then)."
          }
        },
        "description": "Make a building inactive (reason required) or active again."
      },
      "DTOPropertyUnit": {
        "type": "object",
        "properties": {
          "propertyUnitId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Empty to add a unit; the unit's id to change it.",
            "format": "uuid"
          },
          "propertyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The property the unit is in.",
            "format": "uuid"
          },
          "ref": {
            "type": [
              "null",
              "string"
            ],
            "description": "The unit's reference, e.g. A1."
          },
          "floor": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Floor number.",
            "format": "int32"
          },
          "unitType": {
            "type": [
              "null",
              "string"
            ],
            "description": "apartment | studio | maisonette | shop | office | parking | storage."
          },
          "sizeSqm": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Size in square metres.",
            "format": "double"
          },
          "bedrooms": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Number of bedrooms.",
            "format": "int32"
          },
          "bathrooms": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Number of bathrooms.",
            "format": "int32"
          },
          "operatingStatus": {
            "type": [
              "null",
              "string"
            ],
            "description": "ready | under_works | not_rentable."
          },
          "marketRent": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Asking rent in cents per month.",
            "format": "int64"
          },
          "features": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Features, e.g. balcony, parking."
          },
          "accessNotes": {
            "type": [
              "null",
              "string"
            ],
            "description": "How to get in (keys, codes); internal."
          },
          "utilities": {
            "type": [
              "null",
              "string"
            ],
            "description": "Utility details (meters, providers)."
          },
          "defaultAgreementTemplateId": {
            "type": [
              "null",
              "string"
            ],
            "description": "AGRM-012. Accepted but not stored yet: agreement templates arrive in Stage 7."
          },
          "images": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Photos in order (first = cover); same rules as DTOProperty.Images."
          }
        },
        "description": "Add (no propertyUnitId) or edit a unit. Money in whole cents."
      },
      "DTOPropertyUnitActive": {
        "type": "object",
        "properties": {
          "propertyUnitId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The unit's id.",
            "format": "uuid"
          },
          "active": {
            "type": "boolean",
            "description": "true = active again; false = inactive."
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why it is made inactive (required then)."
          }
        }
      },
      "DTOTaskCreate": {
        "type": "object",
        "properties": {
          "title": {
            "type": [
              "null",
              "string"
            ],
            "description": "Short title."
          },
          "type": {
            "type": [
              "null",
              "string"
            ],
            "description": "viewing | handover | inspection | repair | rent_followup | general"
          },
          "dueAt": {
            "type": [
              "null",
              "string"
            ],
            "description": "Start date and time (ISO date-time, UTC).",
            "format": "date-time"
          },
          "durationMin": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Length in minutes.",
            "format": "int32"
          },
          "assigneeUserId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The staff user who does the task.",
            "format": "uuid"
          },
          "priority": {
            "type": [
              "null",
              "string"
            ],
            "description": "low | normal | high"
          },
          "propertyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the property it is about.",
            "format": "uuid"
          },
          "propertyUnitId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the unit it is about.",
            "format": "uuid"
          },
          "notes": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional notes."
          }
        },
        "description": "A task added by hand (TASK-001). Non-office staff can only add tasks for themselves."
      },
      "DTOTaskStatus": {
        "type": "object",
        "properties": {
          "officeTaskId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The task's id.",
            "format": "uuid"
          },
          "status": {
            "type": [
              "null",
              "string"
            ],
            "description": "open | in_progress | done | cancelled"
          }
        }
      },
      "DTOTenancyCreate": {
        "type": "object",
        "properties": {
          "applicationId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the approved application this tenancy comes from.",
            "format": "uuid"
          },
          "propertyUnitId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The unit (free, not occupied).",
            "format": "uuid"
          },
          "tenants": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/DTOTenancyParty"
            },
            "description": "The tenants (at least one)."
          },
          "occupants": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/DTOTenancyParty"
            },
            "description": "Optional: other people who live there."
          },
          "guarantors": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/DTOTenancyParty"
            },
            "description": "Guarantors (students need at least one)."
          },
          "tenantType": {
            "type": [
              "null",
              "string"
            ],
            "description": "employed | self_employed | student | intern"
          },
          "startDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "Start date (yyyy-MM-dd)."
          },
          "endDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "End date (yyyy-MM-dd)."
          },
          "rent": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Rent in cents per period (month, week or day).",
            "format": "int64"
          },
          "deposit": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Deposit in cents.",
            "format": "int64"
          },
          "initialPayment": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Initial down payment in cents (TENC-014, D-115), separate from the deposit. Empty or 0 = none.",
            "format": "int64"
          },
          "dueDay": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Monthly rent: the day of the month it is due (1 to 28).",
            "format": "int32"
          },
          "rentInterval": {
            "type": [
              "null",
              "string"
            ],
            "description": "Stage 15 (D-130): monthly (default) | weekly | daily. Rent is then per month / week / day."
          },
          "dueWeekday": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Weekly rent: the weekday it is due, 1 = Monday … 7 = Sunday.",
            "format": "int32"
          },
          "agreementRoute": {
            "type": [
              "null",
              "string"
            ],
            "description": "offline (signed on paper, PDF uploaded) | esign (the agreement is made from a template and sent for signature, Stage 7)."
          },
          "signedFile": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "description": "Offline route: the signed agreement as a PDF.",
                "$ref": "#/components/schemas/DTOTenancyFile"
              }
            ]
          },
          "agreementTemplateId": {
            "type": [
              "null",
              "string"
            ],
            "description": "esign: a published template (empty = the unit's / building's default, else the best match).",
            "format": "uuid"
          },
          "signingOrder": {
            "type": [
              "null",
              "string"
            ],
            "description": "esign: landlord_last (default) | any | in_order (AGRM-011)."
          },
          "leaveBlank": {
            "type": "boolean",
            "description": "esign: send even when some values are missing (they become blank lines, AGRM-013)."
          },
          "clauseKeys": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "esign: clause blocks switched on (empty = the template's defaults, AGRM-012)."
          },
          "depositReceived": {
            "type": "boolean",
            "description": "true when the deposit was already received."
          },
          "depositPaymentTypeId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Checked only; the deposit itself is posted by the money area (POST /deposit/record).",
            "format": "uuid"
          },
          "notes": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional internal notes."
          }
        }
      },
      "DTOTenancyFile": {
        "type": "object",
        "properties": {
          "fileName": {
            "type": [
              "null",
              "string"
            ],
            "description": "File name, e.g. agreement.pdf."
          },
          "contentBase64": {
            "type": [
              "null",
              "string"
            ],
            "description": "The PDF content in base64."
          }
        },
        "description": "A file sent inside the JSON body (base64, no data: prefix needed)."
      },
      "DTOTenancyParty": {
        "type": "object",
        "properties": {
          "contactId": {
            "type": [
              "null",
              "string"
            ],
            "description": "An existing contact's id; or leave empty and give the new person's details.",
            "format": "uuid"
          },
          "firstName": {
            "type": [
              "null",
              "string"
            ],
            "description": "New person: first name."
          },
          "lastName": {
            "type": [
              "null",
              "string"
            ],
            "description": "New person: last name."
          },
          "email": {
            "type": [
              "null",
              "string"
            ],
            "description": "New person: email."
          },
          "phone": {
            "type": [
              "null",
              "string"
            ],
            "description": "New person: phone, with the country code."
          },
          "depositSharePct": {
            "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
            "type": [
              "null",
              "number",
              "string"
            ],
            "description": "Tenants only (TENC-013): share of the deposit; left out = split equally.",
            "format": "double"
          }
        },
        "description": "One person on a new tenancy: an existing directory contact (ContactId) or a new person."
      },
      "DTOTenancyReason": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Why (at least 5 characters); kept on the record's history."
          }
        }
      },
      "DTOTenancyTerms": {
        "type": "object",
        "properties": {
          "tenancyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The tenancy's id.",
            "format": "uuid"
          },
          "rent": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "New rent in cents.",
            "format": "int64"
          },
          "endDate": {
            "type": [
              "null",
              "string"
            ],
            "description": "New end date (yyyy-MM-dd)."
          },
          "dueDay": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "New due day of the month.",
            "format": "int32"
          },
          "initialPayment": {
            "pattern": "^-?(?:0|[1-9]\\d*)$",
            "type": [
              "null",
              "integer",
              "string"
            ],
            "description": "Change terms only (offline route): the initial down payment in cents (D-115). Empty = unchanged.",
            "format": "int64"
          },
          "note": {
            "type": [
              "null",
              "string"
            ],
            "description": "Change terms only: what changed and why."
          },
          "route": {
            "type": [
              "null",
              "string"
            ],
            "description": "Stage 7: offline (the terms change now, signed on paper) | esign (a renewal / amendment agreement is sent; its terms\r\napply when everyone has signed). Empty = esign when the tenancy has an agreement signed in the system, else offline."
          },
          "agreementTemplateId": {
            "type": [
              "null",
              "string"
            ],
            "description": "esign: a published renewal / amendment template (empty = the company's default).",
            "format": "uuid"
          },
          "leaveBlank": {
            "type": "boolean",
            "description": "esign: send even when some values are missing (they become blank lines, AGRM-013)."
          }
        }
      },
      "DTOTicketCreate": {
        "type": "object",
        "properties": {
          "propertyId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The property.",
            "format": "uuid"
          },
          "propertyUnitId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the unit.",
            "format": "uuid"
          },
          "propertySharedAreaId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the shared area (stairs, roof …).",
            "format": "uuid"
          },
          "category": {
            "type": [
              "null",
              "string"
            ],
            "description": "Category, e.g. plumbing or electrical."
          },
          "urgency": {
            "type": [
              "null",
              "string"
            ],
            "description": "emergency | high | normal | low"
          },
          "title": {
            "type": [
              "null",
              "string"
            ],
            "description": "Short title."
          },
          "description": {
            "type": [
              "null",
              "string"
            ],
            "description": "What is wrong."
          },
          "accessAvailability": {
            "type": [
              "null",
              "string"
            ],
            "description": "When the contractor can get in."
          },
          "reportedBy": {
            "type": [
              "null",
              "string"
            ],
            "description": "staff | tenant (a tenant who called the office)"
          },
          "tenantConfirmationRequired": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "Null = required when the unit has a current tenancy and the tenant reported it."
          },
          "photos": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "type": "string"
            },
            "description": "Photos as data URLs (JPEG / PNG / WebP), up to 6. Stored as \"report\" photos."
          },
          "assetId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The broken item (ASST-006): an active asset of the same building (Stage 9).",
            "format": "uuid"
          }
        },
        "description": "New ticket from staff (TICK-001/002/003). Place: the building, or one of its units or shared areas."
      },
      "DTOTicketEdit": {
        "type": "object",
        "properties": {
          "ticketId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The ticket's id.",
            "format": "uuid"
          },
          "title": {
            "type": [
              "null",
              "string"
            ],
            "description": "Short title."
          },
          "description": {
            "type": [
              "null",
              "string"
            ],
            "description": "What is wrong."
          },
          "category": {
            "type": [
              "null",
              "string"
            ],
            "description": "Category."
          },
          "accessAvailability": {
            "type": [
              "null",
              "string"
            ],
            "description": "When the contractor can get in."
          }
        },
        "description": "Change the request text of a ticket."
      },
      "DTOTicketRef": {
        "type": "object",
        "properties": {
          "ticketId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The ticket's id.",
            "format": "uuid"
          }
        },
        "description": "Just a ticket (close, …)."
      },
      "DTOTicketStatus": {
        "type": "object",
        "properties": {
          "ticketId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The ticket's id.",
            "format": "uuid"
          },
          "status": {
            "type": [
              "null",
              "string"
            ],
            "description": "submitted | under_review | assigned | scheduled | in_progress | awaiting_tenant | awaiting_contractor | awaiting_parts | completed | cancelled | closed (allowed moves only)."
          },
          "note": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional note for the history."
          }
        }
      },
      "DTOViewingReschedule": {
        "type": "object",
        "properties": {
          "viewingId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The viewing's id.",
            "format": "uuid"
          },
          "slotStart": {
            "type": [
              "null",
              "string"
            ],
            "description": "The new date and time (ISO date-time, UTC).",
            "format": "date-time"
          },
          "assigneeUserId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the staff user who shows the unit.",
            "format": "uuid"
          },
          "note": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional note for the visitor."
          }
        },
        "description": "LIST-006: staff set or change the date and time of a viewing."
      },
      "DTOViewingStatus": {
        "type": "object",
        "properties": {
          "viewingId": {
            "type": [
              "null",
              "string"
            ],
            "description": "The viewing's id.",
            "format": "uuid"
          },
          "status": {
            "type": [
              "null",
              "string"
            ],
            "description": "requested | scheduled | completed | cancelled | no_show | closed"
          },
          "outcome": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: how the viewing went (short text)."
          },
          "interested": {
            "type": [
              "null",
              "boolean"
            ],
            "description": "Optional: whether the visitor is interested."
          },
          "assigneeUserId": {
            "type": [
              "null",
              "string"
            ],
            "description": "Optional: the staff user who shows the unit (when scheduling).",
            "format": "uuid"
          }
        },
        "description": "Staff move a viewing on (LIST-005/006) and record the outcome."
      },
      "Envelope": {
        "required": [
          "status",
          "statusCode",
          "message",
          "payload"
        ],
        "type": "object",
        "properties": {
          "status": {
            "enum": [
              0,
              1
            ],
            "type": "integer",
            "description": "1 = done, 0 = not done."
          },
          "statusCode": {
            "type": "integer",
            "description": "The outcome as an HTTP-style code: 200 / 201 done; 400, 409, 422 … not done (the HTTP code itself stays 200)."
          },
          "message": {
            "type": "string",
            "description": "A short sentence for people (English, or Greek with the header X-Language: el)."
          },
          "payload": {
            "description": "The data of the answer (an object, a list page {items, pagination: {pageSize, nextCursor, hasNext}}, or null). On a 422 it names the field."
          }
        },
        "description": "Every answer: status 1 = done, 0 = not done (business error, still HTTP 200)."
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "description": "The company's API key (starts with erk_), in the X-Api-Key header.",
        "name": "X-Api-Key",
        "in": "header"
      },
      "Bearer": {
        "type": "http",
        "description": "The same API key sent as Authorization: Bearer erk_….",
        "scheme": "bearer",
        "bearerFormat": "erk_…"
      }
    }
  },
  "security": [
    {
      "ApiKey": []
    },
    {
      "Bearer": []
    }
  ],
  "tags": [
    {
      "name": "Properties and units",
      "description": "Buildings (properties) and the units inside them."
    },
    {
      "name": "Contacts",
      "description": "People and organisations: tenants, owners, contractors and other contacts."
    },
    {
      "name": "Tenancies",
      "description": "Tenancies (leases): create, change terms, renew, notice, end and cancel."
    },
    {
      "name": "Charges and invoices",
      "description": "Invoices (charges) on the rent ledger, credits, write-offs, voids and unit invoices."
    },
    {
      "name": "Payments, deposits and ledger",
      "description": "Payments, allocation, reversals and refunds, deposits, balances, arrears and statements."
    },
    {
      "name": "Maintenance",
      "description": "Maintenance tickets: report, edit, move through the statuses and close."
    },
    {
      "name": "Leasing",
      "description": "Public listings (adverts), viewings and rental applications."
    },
    {
      "name": "Documents",
      "description": "Files kept on a record: list, download link and upload."
    },
    {
      "name": "Tasks",
      "description": "Office tasks and the calendar."
    },
    {
      "name": "Reports",
      "description": "Read-only reports."
    },
    {
      "name": "Availability",
      "description": "The partner availability feed (its own Availability key)."
    }
  ]
}
