{
  "openapi": "3.0.3",
  "info": {
    "title": "ConnectMe Work Management External API",
    "version": "1.3.0",
    "description": "Public integration API for work-management data. Use an API key created in Setup > API Portal > Management."
  },
  "tags": [
    {
      "name": "External employees"
    },
    {
      "name": "External time"
    },
    {
      "name": "External expenses"
    },
    {
      "name": "External absences"
    },
    {
      "name": "External setup"
    },
    {
      "name": "External CRM"
    },
    {
      "name": "External CRM clients"
    },
    {
      "name": "External CRM contacts"
    },
    {
      "name": "External CRM locations"
    },
    {
      "name": "External compensation"
    },
    {
      "name": "External materials"
    },
    {
      "name": "External suppliers"
    },
    {
      "name": "External agreements"
    },
    {
      "name": "External work orders"
    },
    {
      "name": "External work order reporting"
    },
    {
      "name": "External inspections"
    },
    {
      "name": "External building management"
    },
    {
      "name": "External building finance"
    },
    {
      "name": "External building ownership"
    },
    {
      "name": "External attachments"
    }
  ],
  "servers": [
    {
      "url": "https://demo.connectme.work/v1/api"
    },
    {
      "url": "http://127.0.0.1:3000/v1/api"
    }
  ],
  "security": [
    {
      "bearerApiKey": [
        "*"
      ]
    },
    {
      "headerApiKey": [
        "*"
      ]
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer cm_live_..."
      },
      "headerApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "X-API-Key: cm_live_..."
      },
      "mcpOAuth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "/v1/mcp/oauth/authorize",
            "tokenUrl": "/v1/mcp/oauth/token",
            "scopes": {
              "work-orders:read": "work-orders:read",
              "suppliers:read": "suppliers:read",
              "inspections:read": "inspections:read",
              "resident:properties:read": "resident:properties:read",
              "resident:requests:read": "resident:requests:read",
              "supplier:bids:read": "supplier:bids:read"
            }
          }
        },
        "description": "Delegated MCP grant; organizational API keys are not accepted on delegated-only routes."
      }
    }
  },
  "x-authentication-examples": {
    "bearer": "curl -H \"Authorization: Bearer cm_live_xxx\" \"https://demo.connectme.work/v1/api/employees?skip=0&take=20&sort=ASC&orderBy=&filter=\"",
    "header": "curl -H \"X-API-Key: cm_live_xxx\" \"https://demo.connectme.work/v1/api/time/worked-shifts?skip=0&take=20&sort=ASC&orderBy=&filter=&dateFrom=2026-08-01&dateTo=2026-08-31\""
  },
  "x-authorization-scopes": [
    "*",
    "employees:read",
    "employees:write",
    "time:read",
    "expenses:read",
    "absences:read",
    "absences:write",
    "setup:read",
    "setup:write",
    "clients:read",
    "clients:write",
    "sites:read",
    "sites:write",
    "contacts:read",
    "contacts:write",
    "locations:read",
    "compensation:read",
    "compensation:write",
    "materials:read",
    "materials:write",
    "suppliers:read",
    "suppliers:write",
    "agreements:read",
    "agreements:write",
    "work-orders:read",
    "work-orders:write",
    "work-order-reports:read",
    "inspections:read",
    "inspections:write",
    "building-management:read",
    "building-management:write",
    "building-management:sync",
    "building-ownership:read",
    "building-ownership:write",
    "building-finance:read",
    "building-finance:write",
    "attachments:read"
  ],
  "x-mcp-catalog": {
    "url": "/v1/api/mcp-catalog.json",
    "version": "0.3.0",
    "discovery": "tools/list",
    "status": "local verification; disabled by default"
  },
  "paths": {
    "/mcp/staff/inspections/{actId}": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpGetStaffInspection",
        "operationId": "mcpGetStaffInspection",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "actId": {
                      "type": [
                        "number",
                        "string"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "referenceNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "clientPartyId": {
                      "anyOf": [
                        {
                          "type": [
                            "number",
                            "string"
                          ]
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "inspectionDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "nextInspectionDate": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "actId"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/resident/properties": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpListResidentProperties",
        "operationId": "mcpListResidentProperties",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "resident:properties:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": [
                              "number",
                              "string"
                            ]
                          },
                          "buildingPartyId": {
                            "$ref": "#/properties/list/items/properties/siteId"
                          },
                          "siteName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "buildingName": {
                            "$ref": "#/properties/list/items/properties/siteName"
                          }
                        },
                        "required": [
                          "siteId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/resident/properties/{siteId}/requests": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpListResidentRequests",
        "operationId": "mcpListResidentRequests",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "resident:requests:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "serviceRequestId": {
                            "type": [
                              "number",
                              "string"
                            ]
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "$ref": "#/properties/list/items/properties/description"
                          },
                          "problemType": {
                            "$ref": "#/properties/list/items/properties/description"
                          },
                          "createdDate": {}
                        },
                        "required": [
                          "serviceRequestId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/resident/properties/{siteId}/requests/{id}": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpGetResidentRequest",
        "operationId": "mcpGetResidentRequest",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "resident:requests:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "serviceRequestId": {
                      "type": [
                        "number",
                        "string"
                      ]
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "$ref": "#/properties/description"
                    },
                    "problemType": {
                      "$ref": "#/properties/description"
                    },
                    "createdDate": {}
                  },
                  "required": [
                    "serviceRequestId"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/supplier/bids": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpListSupplierOpportunities",
        "operationId": "mcpListSupplierOpportunities",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "supplier:bids:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "bidRequestId": {
                            "type": [
                              "number",
                              "string"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "$ref": "#/properties/list/items/properties/title"
                          },
                          "invitationStatus": {
                            "$ref": "#/properties/list/items/properties/title"
                          },
                          "responseCount": {
                            "type": "number"
                          },
                          "responseStatus": {
                            "$ref": "#/properties/list/items/properties/title"
                          }
                        },
                        "required": [
                          "bidRequestId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/supplier/bids/{bidRequestId}/status": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "mcpGetOwnSupplierBidStatus",
        "operationId": "mcpGetOwnSupplierBidStatus",
        "description": "Read-only audience-specific projection. Requires current delegated MCP credentials, session and resource capability; organizational API keys are rejected.",
        "security": [
          {
            "mcpOAuth": [
              "supplier:bids:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "bidRequestId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Authorized projection",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "bidRequestId": {
                      "type": [
                        "number",
                        "string"
                      ]
                    },
                    "title": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "$ref": "#/properties/title"
                    },
                    "invitationStatus": {
                      "$ref": "#/properties/title"
                    },
                    "responseCount": {
                      "type": "number"
                    },
                    "responseStatus": {
                      "$ref": "#/properties/title"
                    }
                  },
                  "required": [
                    "bidRequestId"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/staff/inspections": {
      "get": {
        "tags": [
          "MCP delegated reads"
        ],
        "summary": "List currently authorized staff inspections",
        "operationId": "mcpListStaffInspections",
        "description": "Delegated MCP credentials only. Uses current inspection roles and assignments; never grants inspectionActsViewAll from an organizational API key.",
        "security": [
          {
            "mcpOAuth": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 100000
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 50
            }
          },
          {
            "name": "clientPartyId",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "exclusiveMinimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current authorized inspection acts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "actId": {
                            "type": [
                              "number",
                              "string"
                            ]
                          },
                          "title": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "referenceNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "clientPartyId": {
                            "anyOf": [
                              {
                                "type": [
                                  "number",
                                  "string"
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "actId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          }
        }
      }
    },
    "/building-finance/imports": {
      "get": {
        "tags": [
          "External building finance"
        ],
        "summary": "List normalized financial imports",
        "description": "Returns provider document processing status and matching issues without retained raw payloads.",
        "operationId": "listBuildingFinancialImports",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:read"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "description": "Filter by provider code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceCode",
            "in": "query",
            "required": false,
            "description": "Filter by provider resource code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "externalDocumentId",
            "in": "query",
            "required": false,
            "description": "Filter by provider document id.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by staging status.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "buildingPartyId",
            "in": "query",
            "required": false,
            "description": "Filter by matched building.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by matched apartment.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "financialImportId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "schemaVersion": {
                            "type": "integer"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "providerTenantKey": {
                            "type": "string"
                          },
                          "providerOrganizationKey": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sourceResourceCode": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "externalDocumentId": {
                            "type": "string"
                          },
                          "sourceVersion": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "sourceCounter": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string"
                          },
                          "receivedVia": {
                            "type": "string"
                          },
                          "buildingPartyId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "siteId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "payerPartyId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "apartmentAgreementId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "documentKind": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "documentNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "issueDate": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "dueDate": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "currencyCode": {
                            "type": "string"
                          },
                          "payableAmount": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "matchingIssueCodes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "financialDocumentId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "rejectionReason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "updatedDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "financialImportId",
                          "schemaVersion",
                          "provider",
                          "providerTenantKey",
                          "providerOrganizationKey",
                          "sourceResourceCode",
                          "externalDocumentId",
                          "sourceVersion",
                          "sourceCounter",
                          "status",
                          "receivedVia",
                          "buildingPartyId",
                          "siteId",
                          "payerPartyId",
                          "apartmentAgreementId",
                          "documentKind",
                          "documentNumber",
                          "issueDate",
                          "dueDate",
                          "currencyCode",
                          "payableAmount",
                          "matchingIssueCodes",
                          "financialDocumentId",
                          "rejectionReason",
                          "createdDate",
                          "updatedDate"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building finance"
        ],
        "summary": "Stage a normalized building-finance document",
        "description": "Stages a provider-neutral invoice, debit note, or credit note for scoped staff reconciliation. Replays of identical provider documents are idempotent.",
        "operationId": "createBuildingFinancialImport",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:write"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "number",
                    "const": 1
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 50
                      },
                      "tenantKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "organizationKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "resourceCode": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "externalDocumentId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "version": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 150
                      },
                      "counter": {
                        "type": "string",
                        "pattern": "^\\d+$",
                        "maxLength": 19
                      },
                      "modifiedAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": [
                      "provider",
                      "tenantKey",
                      "organizationKey",
                      "resourceCode",
                      "externalDocumentId"
                    ],
                    "additionalProperties": false
                  },
                  "agreement": {
                    "type": "object",
                    "properties": {
                      "externalAgreementId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      },
                      "agreementCode": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 150
                      },
                      "validFrom": {
                        "type": "string",
                        "format": "date"
                      },
                      "validTo": {
                        "$ref": "#/properties/agreement/properties/validFrom"
                      },
                      "legalInstrument": {
                        "type": "object",
                        "properties": {
                          "type": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 30
                          },
                          "externalId": {
                            "$ref": "#/properties/source/properties/externalDocumentId"
                          },
                          "documentNumber": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 150
                          },
                          "issuedDate": {
                            "$ref": "#/properties/agreement/properties/validFrom"
                          }
                        },
                        "required": [
                          "type"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "additionalProperties": false
                  },
                  "parties": {
                    "type": "object",
                    "properties": {
                      "payerExternalId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      },
                      "payerCode": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 150
                      },
                      "issuerExternalId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      }
                    },
                    "required": [
                      "payerExternalId"
                    ],
                    "additionalProperties": false
                  },
                  "property": {
                    "type": "object",
                    "properties": {
                      "buildingExternalId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      },
                      "apartmentExternalId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      }
                    },
                    "required": [
                      "apartmentExternalId"
                    ],
                    "additionalProperties": false
                  },
                  "document": {
                    "type": "object",
                    "properties": {
                      "kind": {
                        "type": "string",
                        "enum": [
                          "INVOICE",
                          "CREDIT_NOTE",
                          "DEBIT_NOTE"
                        ]
                      },
                      "number": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "issueDate": {
                        "$ref": "#/properties/agreement/properties/validFrom"
                      },
                      "dueDate": {
                        "$ref": "#/properties/agreement/properties/validFrom"
                      },
                      "servicePeriodStart": {
                        "$ref": "#/properties/agreement/properties/validFrom"
                      },
                      "servicePeriodEnd": {
                        "$ref": "#/properties/agreement/properties/validFrom"
                      },
                      "currencyCode": {
                        "type": "string",
                        "pattern": "^[A-Z]{3}$"
                      },
                      "netAmount": {
                        "type": "string",
                        "pattern": "^-?\\d{1,16}(?:\\.\\d{1,2})?$"
                      },
                      "taxAmount": {
                        "$ref": "#/properties/document/properties/netAmount"
                      },
                      "grossAmount": {
                        "$ref": "#/properties/document/properties/netAmount"
                      },
                      "payableAmount": {
                        "$ref": "#/properties/document/properties/netAmount"
                      },
                      "supersedesExternalDocumentId": {
                        "$ref": "#/properties/source/properties/externalDocumentId"
                      }
                    },
                    "required": [
                      "kind",
                      "number",
                      "issueDate",
                      "currencyCode",
                      "netAmount",
                      "taxAmount",
                      "grossAmount",
                      "payableAmount"
                    ],
                    "additionalProperties": false
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "externalLineId": {
                          "$ref": "#/properties/source/properties/externalDocumentId"
                        },
                        "lineNumber": {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        "category": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "itemCode": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "description": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 1000
                        },
                        "quantity": {
                          "type": "string",
                          "pattern": "^-?\\d{1,14}(?:\\.\\d{1,6})?$"
                        },
                        "unit": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 30
                        },
                        "unitPrice": {
                          "$ref": "#/properties/lines/items/properties/quantity"
                        },
                        "currentPeriodAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "previousPeriodAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "correctionAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "discountAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "netAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "taxRate": {
                          "type": "string",
                          "pattern": "^\\d{1,3}(?:\\.\\d{1,4})?$"
                        },
                        "taxAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "grossAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        }
                      },
                      "required": [
                        "lineNumber",
                        "description",
                        "quantity",
                        "unitPrice",
                        "netAmount",
                        "taxRate",
                        "taxAmount",
                        "grossAmount"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 500
                  },
                  "taxTotals": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "taxRate": {
                          "$ref": "#/properties/lines/items/properties/taxRate"
                        },
                        "taxableAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        },
                        "taxAmount": {
                          "$ref": "#/properties/document/properties/netAmount"
                        }
                      },
                      "required": [
                        "taxRate",
                        "taxableAmount",
                        "taxAmount"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 100
                  },
                  "meterSnapshots": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "externalMeterId": {
                          "$ref": "#/properties/source/properties/externalDocumentId"
                        },
                        "serialNumber": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 150
                        },
                        "meterType": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100
                        },
                        "reading": {
                          "$ref": "#/properties/lines/items/properties/quantity"
                        },
                        "unit": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 30
                        },
                        "verificationValidUntil": {
                          "$ref": "#/properties/agreement/properties/validFrom"
                        }
                      },
                      "required": [
                        "serialNumber",
                        "meterType",
                        "reading"
                      ],
                      "additionalProperties": false
                    },
                    "maxItems": 100
                  },
                  "statementFacts": {
                    "type": "object",
                    "additionalProperties": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 2000
                        },
                        {
                          "type": "number"
                        }
                      ]
                    }
                  },
                  "renderedDocument": {
                    "type": "object",
                    "properties": {
                      "mimeType": {
                        "type": "string",
                        "const": "application/pdf"
                      },
                      "sha256": {
                        "type": "string",
                        "pattern": "^[0-9a-f]{64}$"
                      },
                      "downloadReference": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 500
                      }
                    },
                    "required": [
                      "mimeType",
                      "sha256"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "schemaVersion",
                  "source",
                  "agreement",
                  "parties",
                  "property",
                  "document",
                  "lines",
                  "taxTotals"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Existing import updated or replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "created",
                        "updated",
                        "replayed"
                      ]
                    },
                    "financialImportId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "importStatus": {
                      "type": "string",
                      "enum": [
                        "RECEIVED",
                        "DOCUMENT_RECEIVED",
                        "READY",
                        "IMPORTED",
                        "REJECTED"
                      ]
                    },
                    "matchingIssueCodes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "status",
                    "financialImportId",
                    "importStatus",
                    "matchingIssueCodes"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "201": {
            "description": "Import staged.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "created",
                        "updated",
                        "replayed"
                      ]
                    },
                    "financialImportId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "importStatus": {
                      "type": "string",
                      "enum": [
                        "RECEIVED",
                        "DOCUMENT_RECEIVED",
                        "READY",
                        "IMPORTED",
                        "REJECTED"
                      ]
                    },
                    "matchingIssueCodes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  },
                  "required": [
                    "status",
                    "financialImportId",
                    "importStatus",
                    "matchingIssueCodes"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "409": {
            "description": "A terminal import exists with different content."
          }
        }
      }
    },
    "/building-finance/imports/{id}/document": {
      "post": {
        "tags": [
          "External building finance"
        ],
        "summary": "Upload invoice PDF bytes",
        "description": "Accepts application/pdf bytes for a staged import. Optional x-content-sha256 must match the uploaded bytes. Storage follows the selected agent's bucketName setting, otherwise local storage is used.",
        "operationId": "uploadBuildingFinancialImportDocument",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:write"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Financial import id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Identical PDF replayed."
          },
          "201": {
            "description": "PDF stored and verified."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          },
          "409": {
            "description": "Checksum mismatch or terminal import."
          }
        }
      }
    },
    "/building-finance/payments": {
      "post": {
        "tags": [
          "External building finance"
        ],
        "summary": "Import payment allocations",
        "description": "Creates or updates an external payment and its explicit allocations, then recalculates canonical invoice paid amount and OPEN, PARTIAL, PAID, or OVERDUE status.",
        "operationId": "importBuildingFinancialPayment",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:write"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "schemaVersion": {
                    "type": "number",
                    "const": 1
                  },
                  "source": {
                    "type": "object",
                    "properties": {
                      "provider": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 50
                      },
                      "tenantKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "organizationKey": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "resourceCode": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 100
                      },
                      "externalPaymentId": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      "counter": {
                        "type": "string",
                        "pattern": "^\\d+$",
                        "maxLength": 19
                      },
                      "modifiedAt": {
                        "type": "string",
                        "format": "date-time"
                      }
                    },
                    "required": [
                      "provider",
                      "tenantKey",
                      "organizationKey",
                      "resourceCode",
                      "externalPaymentId"
                    ],
                    "additionalProperties": false
                  },
                  "paymentDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "currencyCode": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "amount": {
                    "type": "string",
                    "pattern": "^\\d{1,16}(?:\\.\\d{1,2})?$"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "RECEIVED",
                      "SETTLED",
                      "CANCELLED",
                      "REVERSED"
                    ]
                  },
                  "payerExternalId": {
                    "$ref": "#/properties/source/properties/externalPaymentId"
                  },
                  "allocations": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "externalDocumentId": {
                          "$ref": "#/properties/source/properties/externalPaymentId"
                        },
                        "amount": {
                          "$ref": "#/properties/amount"
                        },
                        "allocationDate": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "status": {
                          "type": "string",
                          "enum": [
                            "ACTIVE",
                            "CANCELLED",
                            "REVERSED"
                          ],
                          "default": "ACTIVE"
                        }
                      },
                      "required": [
                        "externalDocumentId",
                        "amount",
                        "allocationDate"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 500
                  }
                },
                "required": [
                  "schemaVersion",
                  "source",
                  "paymentDate",
                  "currencyCode",
                  "amount",
                  "status",
                  "allocations"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment updated or replayed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "created",
                        "updated",
                        "replayed"
                      ]
                    },
                    "buildingPaymentId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "affectedFinancialDocumentIds": {
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    }
                  },
                  "required": [
                    "status",
                    "buildingPaymentId",
                    "affectedFinancialDocumentIds"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "201": {
            "description": "Payment created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "created",
                        "updated",
                        "replayed"
                      ]
                    },
                    "buildingPaymentId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "affectedFinancialDocumentIds": {
                      "type": "array",
                      "items": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    }
                  },
                  "required": [
                    "status",
                    "buildingPaymentId",
                    "affectedFinancialDocumentIds"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "409": {
            "description": "Allocation cannot be resolved safely."
          }
        }
      }
    },
    "/building-finance/provider-identities": {
      "get": {
        "tags": [
          "External building finance"
        ],
        "summary": "List provider identity mappings",
        "description": "Returns organization-scoped mappings between provider identifiers and local buildings, apartments, parties, agreements, or legal instruments.",
        "operationId": "listBuildingFinancialProviderIdentities",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:read"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "provider",
            "in": "query",
            "required": false,
            "description": "Filter by provider code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "tenantKey",
            "in": "query",
            "required": false,
            "description": "Filter by provider tenant.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "organizationKey",
            "in": "query",
            "required": false,
            "description": "Filter by provider organization.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "resourceCode",
            "in": "query",
            "required": false,
            "description": "Filter by resource code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "localObjectType",
            "in": "query",
            "required": false,
            "description": "Filter by local object type.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "localObjectId",
            "in": "query",
            "required": false,
            "description": "Filter by local object id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "provider": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 50
                          },
                          "tenantKey": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "organizationKey": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "resourceCode": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "externalId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "externalCode": {
                            "anyOf": [
                              {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "localObjectType": {
                            "type": "string",
                            "enum": [
                              "BUILDING",
                              "APARTMENT",
                              "PARTY",
                              "APARTMENT_AGREEMENT",
                              "APARTMENT_LEGAL_INSTRUMENT"
                            ]
                          },
                          "localObjectId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "version": {
                            "anyOf": [
                              {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 150
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "counter": {
                            "anyOf": [
                              {
                                "type": "string",
                                "pattern": "^\\d+$",
                                "maxLength": 19
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "financialProviderIdentityId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "lastSeenAt": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "lastSyncedAt": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "provider",
                          "tenantKey",
                          "organizationKey",
                          "resourceCode",
                          "externalId",
                          "localObjectType",
                          "localObjectId",
                          "financialProviderIdentityId",
                          "lastSeenAt",
                          "lastSyncedAt"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "put": {
        "tags": [
          "External building finance"
        ],
        "summary": "Bind a provider identity",
        "description": "Creates or updates a scoped provider-to-local identifier mapping used by normalized financial matching. This never grants resident access.",
        "operationId": "upsertBuildingFinancialProviderIdentity",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:write"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "provider": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "tenantKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "organizationKey": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "resourceCode": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "externalId": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "externalCode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 200
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "localObjectType": {
                    "type": "string",
                    "enum": [
                      "BUILDING",
                      "APARTMENT",
                      "PARTY",
                      "APARTMENT_AGREEMENT",
                      "APARTMENT_LEGAL_INSTRUMENT"
                    ]
                  },
                  "localObjectId": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "version": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "counter": {
                    "anyOf": [
                      {
                        "type": "string",
                        "pattern": "^\\d+$",
                        "maxLength": 19
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "provider",
                  "tenantKey",
                  "organizationKey",
                  "resourceCode",
                  "externalId",
                  "localObjectType",
                  "localObjectId"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "upserted"
                    },
                    "financialProviderIdentityId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    }
                  },
                  "required": [
                    "status",
                    "financialProviderIdentityId"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/employees": {
      "get": {
        "tags": [
          "External employees"
        ],
        "summary": "List employees",
        "description": "Returns employees in the active organization.",
        "operationId": "listEmployees",
        "security": [
          {
            "bearerApiKey": [
              "employees:read"
            ]
          },
          {
            "headerApiKey": [
              "employees:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyId": {
                            "type": "number"
                          },
                          "partyName": {
                            "type": "string"
                          },
                          "partyNumber": {
                            "type": "string"
                          },
                          "maskedSsnNumber": {
                            "type": "string"
                          },
                          "countryCode": {
                            "type": "string"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "managerPartyId": {
                            "type": "number"
                          },
                          "managerPartyName": {
                            "type": "string"
                          },
                          "avatar": {
                            "type": "string"
                          },
                          "department": {
                            "type": "string"
                          },
                          "departmentCode": {
                            "type": "string"
                          },
                          "jobTitle": {
                            "type": "string"
                          },
                          "standardHours": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "standardPay": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "partyId",
                          "partyName",
                          "partyNumber",
                          "countryCode"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External employees"
        ],
        "summary": "Create employee and invitation user",
        "operationId": "createEmployee",
        "security": [
          {
            "bearerApiKey": [
              "employees:write"
            ]
          },
          {
            "headerApiKey": [
              "employees:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "personFirstName": {
                    "type": "string"
                  },
                  "personMiddleName": {
                    "type": "string"
                  },
                  "personLastName": {
                    "type": "string"
                  },
                  "ssnNumber": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "countryCode": {
                    "type": "string"
                  },
                  "origSystemReference": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "dateOfBirth": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "skillTypes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "personSkillId": {
                          "type": "number"
                        },
                        "skillType": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "departmentCode": {
                    "type": "string"
                  },
                  "userRoles": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "userRoleId": {
                          "type": "number"
                        },
                        "userRoleName": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "jobTitle": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "string",
                    "enum": [
                      "M",
                      "F",
                      "O"
                    ]
                  },
                  "standardHours": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "standardPay": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "attribute1": {
                    "type": "string"
                  },
                  "attribute2": {
                    "type": "string"
                  },
                  "attribute3": {
                    "type": "string"
                  },
                  "attribute4": {
                    "type": "string"
                  },
                  "attribute5": {
                    "type": "string"
                  },
                  "attribute6": {
                    "type": "string"
                  },
                  "attribute7": {
                    "type": "string"
                  },
                  "attribute8": {
                    "type": "string"
                  },
                  "attribute9": {
                    "type": "string"
                  },
                  "attribute10": {
                    "type": "string"
                  },
                  "attribute11": {
                    "type": "string"
                  },
                  "attribute12": {
                    "type": "string"
                  },
                  "attribute13": {
                    "type": "string"
                  },
                  "attribute14": {
                    "type": "string"
                  },
                  "attribute15": {
                    "type": "string"
                  },
                  "managerPartyId": {
                    "type": "number"
                  },
                  "propertyManager": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "personFirstName",
                  "personLastName",
                  "countryCode",
                  "email",
                  "phone",
                  "gender"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "personFirstName": "John",
                "personLastName": "Worker",
                "email": "john@example.com",
                "phone": "+37120000000",
                "countryCode": "LVA",
                "departmentCode": "OPS",
                "jobTitle": "Technician",
                "startDateActive": "2026-08-01T00:00:00.000Z",
                "skillTypes": [
                  {
                    "skillType": "ELECTRICIAN"
                  }
                ]
              }
            }
          }
        },
        "x-example": {
          "personFirstName": "John",
          "personLastName": "Worker",
          "email": "john@example.com",
          "phone": "+37120000000",
          "countryCode": "LVA",
          "departmentCode": "OPS",
          "jobTitle": "Technician",
          "startDateActive": "2026-08-01T00:00:00.000Z",
          "skillTypes": [
            {
              "skillType": "ELECTRICIAN"
            }
          ]
        },
        "responses": {
          "200": {
            "description": "Employee created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/employees/{employeeId}": {
      "get": {
        "tags": [
          "External employees"
        ],
        "summary": "Get employee",
        "operationId": "getEmployee",
        "security": [
          {
            "bearerApiKey": [
              "employees:read"
            ]
          },
          {
            "headerApiKey": [
              "employees:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "employeeId",
            "in": "path",
            "required": true,
            "description": "Employee party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "partyId": {
                      "type": "number"
                    },
                    "partyNumber": {
                      "type": "string"
                    },
                    "maskedSsnNumber": {
                      "type": "string"
                    },
                    "origSystemReference": {
                      "type": "string"
                    },
                    "personFirstName": {
                      "type": "string"
                    },
                    "personMiddleName": {
                      "type": "string"
                    },
                    "personLastName": {
                      "type": "string"
                    },
                    "email": {
                      "type": "string"
                    },
                    "phone": {
                      "type": "string"
                    },
                    "dateOfBirth": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "departmentCode": {
                      "type": "string"
                    },
                    "department": {
                      "type": "string"
                    },
                    "countryCode": {
                      "type": "string"
                    },
                    "jobTitle": {
                      "type": "string"
                    },
                    "avatar": {
                      "type": "string"
                    },
                    "standardHours": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "standardPay": {
                      "type": "number"
                    },
                    "skillTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "personSkillId": {
                            "type": "number"
                          },
                          "skillType": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "userRoles": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "userRoleId": {
                            "type": "number"
                          },
                          "userRoleName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "gender": {
                      "type": "string",
                      "enum": [
                        "M",
                        "F",
                        "O"
                      ]
                    },
                    "startDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "attribute1": {
                      "type": "string"
                    },
                    "attribute2": {
                      "type": "string"
                    },
                    "attribute3": {
                      "type": "string"
                    },
                    "attribute4": {
                      "type": "string"
                    },
                    "attribute5": {
                      "type": "string"
                    },
                    "attribute6": {
                      "type": "string"
                    },
                    "attribute7": {
                      "type": "string"
                    },
                    "attribute8": {
                      "type": "string"
                    },
                    "attribute9": {
                      "type": "string"
                    },
                    "attribute10": {
                      "type": "string"
                    },
                    "attribute11": {
                      "type": "string"
                    },
                    "attribute12": {
                      "type": "string"
                    },
                    "attribute13": {
                      "type": "string"
                    },
                    "attribute14": {
                      "type": "string"
                    },
                    "attribute15": {
                      "type": "string"
                    },
                    "managerPartyId": {
                      "type": "number"
                    },
                    "managerPartyName": {
                      "type": "string"
                    },
                    "propertyManager": {
                      "type": "boolean"
                    },
                    "compensation": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "compensationName": {
                            "type": "string"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "lines": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "startDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "endDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "amount": {
                                  "type": "number"
                                },
                                "holidayAmount": {
                                  "type": "number"
                                },
                                "overtimeAmount": {
                                  "type": "number"
                                },
                                "ccy": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "startDateActive",
                                "ccy"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "compensationName",
                          "startDateActive",
                          "lines"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "attachments": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "attachmentId": {
                                "type": "number"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "fileName": {
                                "type": "string"
                              },
                              "fileType": {
                                "type": "string"
                              },
                              "size": {
                                "type": "number"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    },
                    "notes": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "noteId": {
                                "type": "number"
                              },
                              "note": {
                                "type": "string"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "partyId",
                    "partyNumber",
                    "personFirstName",
                    "personLastName",
                    "gender"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External employees"
        ],
        "summary": "Update employee",
        "operationId": "updateEmployee",
        "security": [
          {
            "bearerApiKey": [
              "employees:write"
            ]
          },
          {
            "headerApiKey": [
              "employees:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "employeeId",
            "in": "path",
            "required": true,
            "description": "Employee party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "personFirstName": {
                    "type": "string"
                  },
                  "personMiddleName": {
                    "type": "string"
                  },
                  "personLastName": {
                    "type": "string"
                  },
                  "ssnNumber": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "countryCode": {
                    "type": "string"
                  },
                  "origSystemReference": {
                    "type": "string"
                  },
                  "email": {
                    "type": "string"
                  },
                  "phone": {
                    "type": "string"
                  },
                  "dateOfBirth": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "skillTypes": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "personSkillId": {
                          "type": "number"
                        },
                        "skillType": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "departmentCode": {
                    "type": "string"
                  },
                  "userRoles": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "userRoleId": {
                          "type": "number"
                        },
                        "userRoleName": {
                          "type": "string"
                        }
                      },
                      "additionalProperties": false
                    }
                  },
                  "jobTitle": {
                    "type": "string"
                  },
                  "gender": {
                    "type": "string",
                    "enum": [
                      "M",
                      "F",
                      "O"
                    ]
                  },
                  "standardHours": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "standardPay": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "attribute1": {
                    "type": "string"
                  },
                  "attribute2": {
                    "type": "string"
                  },
                  "attribute3": {
                    "type": "string"
                  },
                  "attribute4": {
                    "type": "string"
                  },
                  "attribute5": {
                    "type": "string"
                  },
                  "attribute6": {
                    "type": "string"
                  },
                  "attribute7": {
                    "type": "string"
                  },
                  "attribute8": {
                    "type": "string"
                  },
                  "attribute9": {
                    "type": "string"
                  },
                  "attribute10": {
                    "type": "string"
                  },
                  "attribute11": {
                    "type": "string"
                  },
                  "attribute12": {
                    "type": "string"
                  },
                  "attribute13": {
                    "type": "string"
                  },
                  "attribute14": {
                    "type": "string"
                  },
                  "attribute15": {
                    "type": "string"
                  },
                  "managerPartyId": {
                    "type": "number"
                  },
                  "propertyManager": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "personFirstName",
                  "personLastName",
                  "countryCode",
                  "email",
                  "phone",
                  "gender"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "personFirstName": "John",
                "personLastName": "Worker",
                "email": "john@example.com",
                "phone": "+37120000000",
                "countryCode": "LVA",
                "departmentCode": "OPS",
                "jobTitle": "Technician",
                "startDateActive": "2026-08-01T00:00:00.000Z",
                "skillTypes": [
                  {
                    "skillType": "ELECTRICIAN"
                  }
                ]
              }
            }
          }
        },
        "x-example": {
          "personFirstName": "John",
          "personLastName": "Worker",
          "email": "john@example.com",
          "phone": "+37120000000",
          "countryCode": "LVA",
          "departmentCode": "OPS",
          "jobTitle": "Technician",
          "startDateActive": "2026-08-01T00:00:00.000Z",
          "skillTypes": [
            {
              "skillType": "ELECTRICIAN"
            }
          ]
        },
        "responses": {
          "200": {
            "description": "Employee updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/employees/{employeeId}/discontinue": {
      "post": {
        "tags": [
          "External employees"
        ],
        "summary": "End-date employee and user login",
        "operationId": "discontinueEmployee",
        "security": [
          {
            "bearerApiKey": [
              "employees:write"
            ]
          },
          {
            "headerApiKey": [
              "employees:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "employeeId",
            "in": "path",
            "required": true,
            "description": "Employee party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Employee discontinued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/time/worked-shifts": {
      "get": {
        "tags": [
          "External time"
        ],
        "summary": "Get worked shifts and reported entries",
        "operationId": "listWorkedShifts",
        "security": [
          {
            "bearerApiKey": [
              "time:read"
            ]
          },
          {
            "headerApiKey": [
              "time:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/time/summary": {
      "get": {
        "tags": [
          "External time"
        ],
        "summary": "Get worked-time and pay summary by employee",
        "operationId": "getTimeSummary",
        "security": [
          {
            "bearerApiKey": [
              "time:read"
            ]
          },
          {
            "headerApiKey": [
              "time:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/expenses": {
      "get": {
        "tags": [
          "External expenses"
        ],
        "summary": "List expense headers and lines",
        "operationId": "listExpenses",
        "security": [
          {
            "bearerApiKey": [
              "expenses:read"
            ]
          },
          {
            "headerApiKey": [
              "expenses:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/absences": {
      "get": {
        "tags": [
          "External absences"
        ],
        "summary": "List vacations and absences",
        "operationId": "listAbsences",
        "security": [
          {
            "bearerApiKey": [
              "absences:read"
            ]
          },
          {
            "headerApiKey": [
              "absences:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External absences"
        ],
        "summary": "Create vacation or absence",
        "operationId": "createAbsence",
        "security": [
          {
            "bearerApiKey": [
              "absences:write"
            ]
          },
          {
            "headerApiKey": [
              "absences:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "employeeId": {
                    "type": "number"
                  },
                  "absenceType": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "default": ""
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "format": "date-time"
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "employeeId",
                  "absenceType",
                  "startDateActive"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "employeeId": 123,
                "absenceType": "VACATION",
                "description": "Annual leave",
                "startDateActive": "2026-08-10T00:00:00.000Z",
                "endDateActive": "2026-08-14T00:00:00.000Z",
                "enabled": true
              }
            }
          }
        },
        "x-example": {
          "employeeId": 123,
          "absenceType": "VACATION",
          "description": "Annual leave",
          "startDateActive": "2026-08-10T00:00:00.000Z",
          "endDateActive": "2026-08-14T00:00:00.000Z",
          "enabled": true
        },
        "responses": {
          "201": {
            "description": "Absence created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/absences/{absenceId}": {
      "get": {
        "tags": [
          "External absences"
        ],
        "summary": "Get absence",
        "operationId": "getAbsence",
        "security": [
          {
            "bearerApiKey": [
              "absences:read"
            ]
          },
          {
            "headerApiKey": [
              "absences:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "absenceId",
            "in": "path",
            "required": true,
            "description": "Absence id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External absences"
        ],
        "summary": "Update absence",
        "operationId": "updateAbsence",
        "security": [
          {
            "bearerApiKey": [
              "absences:write"
            ]
          },
          {
            "headerApiKey": [
              "absences:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "absenceId",
            "in": "path",
            "required": true,
            "description": "Absence id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "absenceType": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string",
                    "default": ""
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "format": "date-time"
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "enabled": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "description": "Updated absence note",
                "enabled": true
              }
            }
          }
        },
        "x-example": {
          "description": "Updated absence note",
          "enabled": true
        },
        "responses": {
          "200": {
            "description": "Absence updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External absences"
        ],
        "summary": "Delete absence",
        "operationId": "deleteAbsence",
        "security": [
          {
            "bearerApiKey": [
              "absences:write"
            ]
          },
          {
            "headerApiKey": [
              "absences:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "absenceId",
            "in": "path",
            "required": true,
            "description": "Absence id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Absence deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/clients": {
      "get": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "List CRM clients",
        "operationId": "listClients",
        "security": [
          {
            "bearerApiKey": [
              "clients:read"
            ]
          },
          {
            "headerApiKey": [
              "clients:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyId": {
                            "type": "number"
                          },
                          "partyName": {
                            "type": "string"
                          },
                          "partyNumber": {
                            "type": "string"
                          },
                          "maskedSsnNumber": {
                            "type": "string"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "partyType": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "partyId",
                          "partyName",
                          "partyNumber"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "Create CRM client",
        "operationId": "createClient",
        "security": [
          {
            "bearerApiKey": [
              "clients:write"
            ]
          },
          {
            "headerApiKey": [
              "clients:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "origSystemReference": {
                    "type": "string"
                  },
                  "partyType": {
                    "type": "string",
                    "enum": [
                      "PERSON",
                      "ORGANIZATION",
                      "BUILDING"
                    ]
                  },
                  "person": {
                    "type": "object",
                    "properties": {
                      "personFirstName": {
                        "type": "string"
                      },
                      "personMiddleName": {
                        "type": "string"
                      },
                      "personLastName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "personFirstName",
                      "personLastName"
                    ],
                    "additionalProperties": false
                  },
                  "organization": {
                    "type": "object",
                    "properties": {
                      "organizationName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "organizationName"
                    ],
                    "additionalProperties": false
                  },
                  "building": {
                    "type": "object",
                    "properties": {
                      "buildingName": {
                        "type": "string"
                      },
                      "buildingType": {
                        "type": "string",
                        "enum": [
                          "RESIDENTIAL",
                          "MIXED_USE",
                          "COMMERCIAL",
                          "OTHER"
                        ]
                      },
                      "constructionYear": {
                        "type": "integer",
                        "minimum": 1000,
                        "maximum": 2200
                      },
                      "floorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "undergroundFloorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "entranceCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "elevatorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentsPerStaircase": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentLayout": {
                        "type": "object",
                        "properties": {
                          "version": {
                            "type": "number",
                            "const": 1
                          },
                          "staircases": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "staircaseNumber": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 100
                                },
                                "apartmentCount": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 10000
                                },
                                "floors": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "floorNumber": {
                                        "type": "integer",
                                        "exclusiveMinimum": 0,
                                        "maximum": 200
                                      },
                                      "apartmentCount": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 1000
                                      }
                                    },
                                    "required": [
                                      "floorNumber",
                                      "apartmentCount"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "maxItems": 200
                                }
                              },
                              "required": [
                                "staircaseNumber",
                                "apartmentCount",
                                "floors"
                              ],
                              "additionalProperties": false
                            },
                            "maxItems": 100
                          }
                        },
                        "required": [
                          "version",
                          "staircases"
                        ],
                        "additionalProperties": false
                      },
                      "totalArea": {
                        "type": "number",
                        "minimum": 0
                      },
                      "heatedArea": {
                        "type": "number",
                        "minimum": 0
                      },
                      "cadastreNumber": {
                        "type": "string"
                      },
                      "propertyCadastreNumber": {
                        "type": "string",
                        "pattern": "^\\d{11}$"
                      },
                      "buildingCadastreDesignation": {
                        "type": "string",
                        "pattern": "^\\d{14}$"
                      },
                      "landCadastreDesignations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^\\d{11}$"
                        },
                        "maxItems": 20
                      },
                      "heatingType": {
                        "type": "string",
                        "maxLength": 30
                      },
                      "roofType": {
                        "type": "string",
                        "maxLength": 30
                      },
                      "parkingType": {
                        "type": "string",
                        "enum": [
                          "NONE",
                          "STREET",
                          "SURFACE",
                          "UNDERGROUND",
                          "MIXED"
                        ]
                      },
                      "parkingSpaceCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "hasAccessibleEntrance": {
                        "type": "boolean"
                      },
                      "hasWheelchairLift": {
                        "type": "boolean"
                      },
                      "hasBasement": {
                        "type": "boolean"
                      },
                      "hasAttic": {
                        "type": "boolean"
                      },
                      "hasSharedUtilityMeters": {
                        "type": "boolean"
                      },
                      "hasFireSafetySystem": {
                        "type": "boolean"
                      },
                      "hasAccessControl": {
                        "type": "boolean"
                      },
                      "wasteCollectionNotes": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "emergencyAccessNotes": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "cleaningWeekdays": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "MONDAY",
                            "TUESDAY",
                            "WEDNESDAY",
                            "THURSDAY",
                            "FRIDAY",
                            "SATURDAY",
                            "SUNDAY"
                          ]
                        },
                        "maxItems": 7
                      },
                      "cleaningExcludesHolidays": {
                        "type": "boolean"
                      },
                      "grassMowingResponsibility": {
                        "type": "string",
                        "enum": [
                          "SERVICE_PROVIDER",
                          "RESIDENTS",
                          "MIXED",
                          "NOT_APPLICABLE"
                        ]
                      },
                      "entranceAccessCodes": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "entranceLabel": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            },
                            "apartmentNumber": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 20
                            },
                            "code": {
                              "type": "string",
                              "pattern": "^\\d{4}$"
                            }
                          },
                          "required": [
                            "apartmentNumber",
                            "code"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 50
                      },
                      "additionalDetails": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "required": [
                      "buildingName"
                    ],
                    "additionalProperties": false
                  },
                  "people": {
                    "type": "object",
                    "properties": {
                      "houseSeniorPartyId": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      "houseRepresentative": {
                        "type": "object",
                        "properties": {
                          "partyId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "createPerson": {
                            "type": "object",
                            "properties": {
                              "personFirstName": {
                                "type": "string",
                                "minLength": 1
                              },
                              "personMiddleName": {
                                "type": "string"
                              },
                              "personLastName": {
                                "type": "string",
                                "minLength": 1
                              },
                              "ssnNumber": {
                                "type": "string"
                              },
                              "contactPoints": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "contactPointType": {
                                      "type": "string",
                                      "enum": [
                                        "PHONE",
                                        "EMAIL",
                                        "HOME_PHONE",
                                        "RELATIVE_PHONE",
                                        "TELEGRAM",
                                        "WHATSAPP",
                                        "WEBSITE",
                                        "SKYPE"
                                      ]
                                    },
                                    "text": {
                                      "type": "string",
                                      "minLength": 1
                                    },
                                    "description": {
                                      "type": "string",
                                      "maxLength": 255
                                    }
                                  },
                                  "required": [
                                    "contactPointType",
                                    "text"
                                  ],
                                  "additionalProperties": false
                                },
                                "minItems": 1
                              }
                            },
                            "required": [
                              "personFirstName",
                              "personLastName",
                              "contactPoints"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "additionalProperties": false
                      },
                      "propertyManagerPartyId": {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      }
                    },
                    "additionalProperties": false
                  },
                  "primaryLocation": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "taxpayerNumber": {
                    "type": "string"
                  },
                  "ssnNumber": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "contactPoints": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "contactPointType": {
                          "type": "string",
                          "enum": [
                            "PHONE",
                            "EMAIL",
                            "HOME_PHONE",
                            "RELATIVE_PHONE",
                            "TELEGRAM",
                            "WHATSAPP",
                            "WEBSITE",
                            "SKYPE"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        },
                        "attachments": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "number"
                            },
                            "list": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "attachmentId": {
                                    "type": "number"
                                  },
                                  "editable": {
                                    "type": "boolean"
                                  },
                                  "fileName": {
                                    "type": "string"
                                  },
                                  "fileType": {
                                    "type": "string"
                                  },
                                  "size": {
                                    "type": "number"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "attribute1": {
                                    "type": "string"
                                  },
                                  "attribute2": {
                                    "type": "string"
                                  },
                                  "attribute3": {
                                    "type": "string"
                                  },
                                  "attribute4": {
                                    "type": "string"
                                  },
                                  "attribute5": {
                                    "type": "string"
                                  },
                                  "attribute6": {
                                    "type": "string"
                                  },
                                  "attribute7": {
                                    "type": "string"
                                  },
                                  "attribute8": {
                                    "type": "string"
                                  },
                                  "attribute9": {
                                    "type": "string"
                                  },
                                  "attribute10": {
                                    "type": "string"
                                  },
                                  "attribute11": {
                                    "type": "string"
                                  },
                                  "attribute12": {
                                    "type": "string"
                                  },
                                  "attribute13": {
                                    "type": "string"
                                  },
                                  "attribute14": {
                                    "type": "string"
                                  },
                                  "attribute15": {
                                    "type": "string"
                                  },
                                  "createDate": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "createdBy": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "count",
                            "list"
                          ],
                          "additionalProperties": false
                        },
                        "notes": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "number"
                            },
                            "list": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "noteId": {
                                    "type": "number"
                                  },
                                  "note": {
                                    "type": "string"
                                  },
                                  "editable": {
                                    "type": "boolean"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "attribute1": {
                                    "type": "string"
                                  },
                                  "attribute2": {
                                    "type": "string"
                                  },
                                  "attribute3": {
                                    "type": "string"
                                  },
                                  "attribute4": {
                                    "type": "string"
                                  },
                                  "attribute5": {
                                    "type": "string"
                                  },
                                  "attribute6": {
                                    "type": "string"
                                  },
                                  "attribute7": {
                                    "type": "string"
                                  },
                                  "attribute8": {
                                    "type": "string"
                                  },
                                  "attribute9": {
                                    "type": "string"
                                  },
                                  "attribute10": {
                                    "type": "string"
                                  },
                                  "attribute11": {
                                    "type": "string"
                                  },
                                  "attribute12": {
                                    "type": "string"
                                  },
                                  "attribute13": {
                                    "type": "string"
                                  },
                                  "attribute14": {
                                    "type": "string"
                                  },
                                  "attribute15": {
                                    "type": "string"
                                  },
                                  "createDate": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "createdBy": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "count",
                            "list"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "contactPointType",
                        "text"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "sites": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteName": {
                          "type": "string"
                        },
                        "siteType": {
                          "type": "string",
                          "enum": [
                            "SITE",
                            "APARTMENT"
                          ]
                        },
                        "comments": {
                          "type": "string"
                        },
                        "siteUses": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "siteUseType": {
                                "type": "string",
                                "enum": [
                                  "BILLING",
                                  "MAILING",
                                  "SITE"
                                ]
                              },
                              "primaryPerType": {
                                "type": "boolean"
                              },
                              "active": {
                                "type": "boolean"
                              },
                              "startDateActive": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "endDateActive": {
                                "type": "string",
                                "format": "date-time"
                              }
                            },
                            "required": [
                              "siteUseType",
                              "primaryPerType",
                              "active"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "location": {
                          "$ref": "#/properties/primaryLocation"
                        },
                        "apartmentProfile": {
                          "type": "object",
                          "properties": {
                            "apartmentProfileId": {
                              "type": "number"
                            },
                            "apartmentNumber": {
                              "type": "string"
                            },
                            "staircase": {
                              "type": "string"
                            },
                            "floor": {
                              "type": "string"
                            },
                            "area": {
                              "type": "number"
                            },
                            "cadastreNumber": {
                              "type": "string"
                            },
                            "propertyCadastreNumber": {
                              "type": "string",
                              "pattern": "^\\d{11}$"
                            },
                            "premisesGroupCadastreDesignation": {
                              "type": "string",
                              "pattern": "^\\d{17}$"
                            },
                            "buildingUndividedShares": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "cadastralDesignation": {
                                    "type": "string",
                                    "pattern": "^\\d{14}$"
                                  },
                                  "numerator": {
                                    "type": "string",
                                    "pattern": "^\\d+$"
                                  },
                                  "denominator": {
                                    "type": "string",
                                    "pattern": "^[1-9]\\d*$"
                                  }
                                },
                                "required": [
                                  "cadastralDesignation",
                                  "numerator",
                                  "denominator"
                                ],
                                "additionalProperties": false
                              },
                              "maxItems": 20
                            },
                            "landUndividedShares": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "cadastralDesignation": {
                                    "type": "string",
                                    "pattern": "^\\d{11}$"
                                  },
                                  "numerator": {
                                    "type": "string",
                                    "pattern": "^\\d+$"
                                  },
                                  "denominator": {
                                    "type": "string",
                                    "pattern": "^[1-9]\\d*$"
                                  }
                                },
                                "required": [
                                  "cadastralDesignation",
                                  "numerator",
                                  "denominator"
                                ],
                                "additionalProperties": false
                              },
                              "maxItems": 20
                            },
                            "rooms": {
                              "type": "number"
                            },
                            "status": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "apartmentNumber"
                          ],
                          "additionalProperties": false
                        },
                        "owners": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "tenants": {
                          "type": "array",
                          "items": {
                            "type": "string"
                          }
                        },
                        "contactPoints": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "contactPointId": {
                                "type": "number"
                              },
                              "siteId": {
                                "type": "number"
                              },
                              "contactPointType": {
                                "type": "string",
                                "enum": [
                                  "EMAIL",
                                  "PHONE"
                                ]
                              },
                              "text": {
                                "type": "string",
                                "minLength": 1
                              },
                              "description": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              }
                            },
                            "required": [
                              "contactPointType",
                              "text"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "attachments": {
                          "$ref": "#/properties/contactPoints/items/properties/attachments"
                        },
                        "notes": {
                          "$ref": "#/properties/contactPoints/items/properties/notes"
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "partyType",
                  "comments",
                  "contactPoints"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Client created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    },
                    "siteId": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/clients/{clientId}": {
      "get": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "Get CRM client details",
        "operationId": "getClient",
        "security": [
          {
            "bearerApiKey": [
              "clients:read"
            ]
          },
          {
            "headerApiKey": [
              "clients:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "partyId": {
                      "type": "number"
                    },
                    "partyNumber": {
                      "type": "string"
                    },
                    "origSystemReference": {
                      "type": "string"
                    },
                    "partyName": {
                      "type": "string"
                    },
                    "partyType": {
                      "type": "string",
                      "enum": [
                        "PERSON",
                        "ORGANIZATION",
                        "BUILDING",
                        "SUPPLIER"
                      ]
                    },
                    "person": {
                      "type": "object",
                      "properties": {
                        "personFirstName": {
                          "type": "string"
                        },
                        "personMiddleName": {
                          "type": "string"
                        },
                        "personLastName": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "personFirstName",
                        "personLastName"
                      ],
                      "additionalProperties": false
                    },
                    "organization": {
                      "type": "object",
                      "properties": {
                        "organizationName": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "organizationName"
                      ],
                      "additionalProperties": false
                    },
                    "building": {
                      "type": "object",
                      "properties": {
                        "buildingName": {
                          "type": "string"
                        },
                        "buildingType": {
                          "type": "string",
                          "enum": [
                            "RESIDENTIAL",
                            "MIXED_USE",
                            "COMMERCIAL",
                            "OTHER"
                          ]
                        },
                        "constructionYear": {
                          "type": "integer",
                          "minimum": 1000,
                          "maximum": 2200
                        },
                        "floorCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "undergroundFloorCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "entranceCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "elevatorCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "apartmentCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "apartmentsPerStaircase": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "apartmentLayout": {
                          "type": "object",
                          "properties": {
                            "version": {
                              "type": "number",
                              "const": 1
                            },
                            "staircases": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "staircaseNumber": {
                                    "type": "integer",
                                    "exclusiveMinimum": 0,
                                    "maximum": 100
                                  },
                                  "apartmentCount": {
                                    "type": "integer",
                                    "minimum": 0,
                                    "maximum": 10000
                                  },
                                  "floors": {
                                    "type": "array",
                                    "items": {
                                      "type": "object",
                                      "properties": {
                                        "floorNumber": {
                                          "type": "integer",
                                          "exclusiveMinimum": 0,
                                          "maximum": 200
                                        },
                                        "apartmentCount": {
                                          "type": "integer",
                                          "minimum": 0,
                                          "maximum": 1000
                                        }
                                      },
                                      "required": [
                                        "floorNumber",
                                        "apartmentCount"
                                      ],
                                      "additionalProperties": false
                                    },
                                    "maxItems": 200
                                  }
                                },
                                "required": [
                                  "staircaseNumber",
                                  "apartmentCount",
                                  "floors"
                                ],
                                "additionalProperties": false
                              },
                              "maxItems": 100
                            }
                          },
                          "required": [
                            "version",
                            "staircases"
                          ],
                          "additionalProperties": false
                        },
                        "totalArea": {
                          "type": "number",
                          "minimum": 0
                        },
                        "heatedArea": {
                          "type": "number",
                          "minimum": 0
                        },
                        "cadastreNumber": {
                          "type": "string"
                        },
                        "propertyCadastreNumber": {
                          "type": "string",
                          "pattern": "^\\d{11}$"
                        },
                        "buildingCadastreDesignation": {
                          "type": "string",
                          "pattern": "^\\d{14}$"
                        },
                        "landCadastreDesignations": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "pattern": "^\\d{11}$"
                          },
                          "maxItems": 20
                        },
                        "heatingType": {
                          "type": "string",
                          "maxLength": 30
                        },
                        "roofType": {
                          "type": "string",
                          "maxLength": 30
                        },
                        "parkingType": {
                          "type": "string",
                          "enum": [
                            "NONE",
                            "STREET",
                            "SURFACE",
                            "UNDERGROUND",
                            "MIXED"
                          ]
                        },
                        "parkingSpaceCount": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "hasAccessibleEntrance": {
                          "type": "boolean"
                        },
                        "hasWheelchairLift": {
                          "type": "boolean"
                        },
                        "hasBasement": {
                          "type": "boolean"
                        },
                        "hasAttic": {
                          "type": "boolean"
                        },
                        "hasSharedUtilityMeters": {
                          "type": "boolean"
                        },
                        "hasFireSafetySystem": {
                          "type": "boolean"
                        },
                        "hasAccessControl": {
                          "type": "boolean"
                        },
                        "wasteCollectionNotes": {
                          "type": "string",
                          "maxLength": 500
                        },
                        "emergencyAccessNotes": {
                          "type": "string",
                          "maxLength": 500
                        },
                        "cleaningWeekdays": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "MONDAY",
                              "TUESDAY",
                              "WEDNESDAY",
                              "THURSDAY",
                              "FRIDAY",
                              "SATURDAY",
                              "SUNDAY"
                            ]
                          },
                          "maxItems": 7
                        },
                        "cleaningExcludesHolidays": {
                          "type": "boolean"
                        },
                        "grassMowingResponsibility": {
                          "type": "string",
                          "enum": [
                            "SERVICE_PROVIDER",
                            "RESIDENTS",
                            "MIXED",
                            "NOT_APPLICABLE"
                          ]
                        },
                        "entranceAccessCodes": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "entranceLabel": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 100
                              },
                              "apartmentNumber": {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 20
                              },
                              "code": {
                                "type": "string",
                                "pattern": "^\\d{4}$"
                              }
                            },
                            "required": [
                              "apartmentNumber",
                              "code"
                            ],
                            "additionalProperties": false
                          },
                          "maxItems": 50
                        },
                        "additionalDetails": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "required": [
                        "buildingName"
                      ],
                      "additionalProperties": false
                    },
                    "primaryLocation": {
                      "type": "object",
                      "properties": {
                        "addressLine1": {
                          "type": "string"
                        },
                        "addressLine2": {
                          "type": "string"
                        },
                        "addressLine3": {
                          "type": "string"
                        },
                        "addressLine4": {
                          "type": "string"
                        },
                        "city": {
                          "type": "string"
                        },
                        "county": {
                          "type": "string"
                        },
                        "country": {
                          "type": "string"
                        },
                        "postalCode": {
                          "type": "string"
                        },
                        "longitude": {
                          "type": "string"
                        },
                        "latitude": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "addressLine1",
                        "city",
                        "county",
                        "country",
                        "postalCode"
                      ],
                      "additionalProperties": false
                    },
                    "houseSenior": {
                      "type": "object",
                      "properties": {
                        "relationshipId": {
                          "type": "number"
                        },
                        "partyId": {
                          "type": "number"
                        },
                        "partyName": {
                          "type": "string"
                        },
                        "phone": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "relationshipId",
                        "partyId",
                        "partyName",
                        "active"
                      ],
                      "additionalProperties": false
                    },
                    "propertyManager": {
                      "type": "object",
                      "properties": {
                        "relationshipId": {
                          "type": "number"
                        },
                        "partyId": {
                          "type": "number"
                        },
                        "partyName": {
                          "type": "string"
                        },
                        "phone": {
                          "type": "string"
                        },
                        "email": {
                          "type": "string"
                        },
                        "department": {
                          "type": "string"
                        },
                        "jobTitle": {
                          "type": "string"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "relationshipId",
                        "partyId",
                        "partyName",
                        "active"
                      ],
                      "additionalProperties": false
                    },
                    "taxpayerNumber": {
                      "type": "string"
                    },
                    "ssnNumber": {
                      "type": "string"
                    },
                    "maskedSsnNumber": {
                      "type": "string"
                    },
                    "comments": {
                      "type": "string"
                    },
                    "startDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "attribute1": {
                      "type": "string"
                    },
                    "attribute2": {
                      "type": "string"
                    },
                    "attribute3": {
                      "type": "string"
                    },
                    "attribute4": {
                      "type": "string"
                    },
                    "attribute5": {
                      "type": "string"
                    },
                    "attribute6": {
                      "type": "string"
                    },
                    "attribute7": {
                      "type": "string"
                    },
                    "attribute8": {
                      "type": "string"
                    },
                    "attribute9": {
                      "type": "string"
                    },
                    "attribute10": {
                      "type": "string"
                    },
                    "attribute11": {
                      "type": "string"
                    },
                    "attribute12": {
                      "type": "string"
                    },
                    "attribute13": {
                      "type": "string"
                    },
                    "attribute14": {
                      "type": "string"
                    },
                    "attribute15": {
                      "type": "string"
                    },
                    "contactPoints": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactPointId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "contactPointType": {
                            "type": "string",
                            "enum": [
                              "PHONE",
                              "EMAIL",
                              "HOME_PHONE",
                              "RELATIVE_PHONE",
                              "TELEGRAM",
                              "WHATSAPP",
                              "WEBSITE",
                              "SKYPE"
                            ]
                          },
                          "text": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "contactPointId",
                          "contactPointType",
                          "text"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "sites": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "siteType": {
                            "type": "string",
                            "enum": [
                              "SITE",
                              "APARTMENT"
                            ]
                          },
                          "comments": {
                            "type": "string"
                          },
                          "siteUses": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "siteUseType": {
                                  "type": "string",
                                  "enum": [
                                    "BILLING",
                                    "MAILING",
                                    "SITE"
                                  ]
                                },
                                "primaryPerType": {
                                  "type": "boolean"
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "startDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "endDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              },
                              "required": [
                                "siteUseType",
                                "primaryPerType",
                                "active"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "location": {
                            "$ref": "#/properties/primaryLocation"
                          },
                          "apartmentProfile": {
                            "type": "object",
                            "properties": {
                              "apartmentProfileId": {
                                "type": "number"
                              },
                              "apartmentNumber": {
                                "type": "string"
                              },
                              "staircase": {
                                "type": "string"
                              },
                              "floor": {
                                "type": "string"
                              },
                              "area": {
                                "type": "number"
                              },
                              "cadastreNumber": {
                                "type": "string"
                              },
                              "propertyCadastreNumber": {
                                "type": "string",
                                "pattern": "^\\d{11}$"
                              },
                              "premisesGroupCadastreDesignation": {
                                "type": "string",
                                "pattern": "^\\d{17}$"
                              },
                              "buildingUndividedShares": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "cadastralDesignation": {
                                      "type": "string",
                                      "pattern": "^\\d{14}$"
                                    },
                                    "numerator": {
                                      "type": "string",
                                      "pattern": "^\\d+$"
                                    },
                                    "denominator": {
                                      "type": "string",
                                      "pattern": "^[1-9]\\d*$"
                                    }
                                  },
                                  "required": [
                                    "cadastralDesignation",
                                    "numerator",
                                    "denominator"
                                  ],
                                  "additionalProperties": false
                                },
                                "maxItems": 20
                              },
                              "landUndividedShares": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "cadastralDesignation": {
                                      "type": "string",
                                      "pattern": "^\\d{11}$"
                                    },
                                    "numerator": {
                                      "type": "string",
                                      "pattern": "^\\d+$"
                                    },
                                    "denominator": {
                                      "type": "string",
                                      "pattern": "^[1-9]\\d*$"
                                    }
                                  },
                                  "required": [
                                    "cadastralDesignation",
                                    "numerator",
                                    "denominator"
                                  ],
                                  "additionalProperties": false
                                },
                                "maxItems": 20
                              },
                              "rooms": {
                                "type": "number"
                              },
                              "status": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "apartmentNumber"
                            ],
                            "additionalProperties": false
                          },
                          "owners": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "tenants": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "contactPoints": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "contactPointId": {
                                  "type": "number"
                                },
                                "siteId": {
                                  "type": "number"
                                },
                                "contactPointType": {
                                  "type": "string",
                                  "enum": [
                                    "EMAIL",
                                    "PHONE"
                                  ]
                                },
                                "text": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "description": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                }
                              },
                              "required": [
                                "contactPointType",
                                "text"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "$ref": "#/properties/contactPoints/items/properties/attachments"
                          },
                          "notes": {
                            "$ref": "#/properties/contactPoints/items/properties/notes"
                          }
                        },
                        "required": [
                          "siteId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "attachments": {
                      "$ref": "#/properties/contactPoints/items/properties/attachments"
                    },
                    "notes": {
                      "$ref": "#/properties/contactPoints/items/properties/notes"
                    },
                    "enabledTabs": {
                      "type": "object",
                      "properties": {
                        "inspections": {
                          "type": "boolean"
                        },
                        "questionnaires": {
                          "type": "boolean"
                        },
                        "clientPortal": {
                          "type": "boolean"
                        },
                        "propertyClient360": {
                          "type": "boolean"
                        }
                      },
                      "additionalProperties": false
                    },
                    "tabs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "code": {
                            "type": "string"
                          },
                          "label": {
                            "type": "string"
                          },
                          "route": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "code",
                          "label",
                          "route"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "partyId",
                    "partyNumber",
                    "partyName",
                    "partyType",
                    "comments",
                    "contactPoints",
                    "sites"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "Update CRM client",
        "operationId": "updateClient",
        "security": [
          {
            "bearerApiKey": [
              "clients:write"
            ]
          },
          {
            "headerApiKey": [
              "clients:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "origSystemReference": {
                    "type": "string"
                  },
                  "partyType": {
                    "type": "string",
                    "enum": [
                      "PERSON",
                      "ORGANIZATION",
                      "BUILDING"
                    ]
                  },
                  "person": {
                    "type": "object",
                    "properties": {
                      "personFirstName": {
                        "type": "string"
                      },
                      "personMiddleName": {
                        "type": "string"
                      },
                      "personLastName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "personFirstName",
                      "personLastName"
                    ],
                    "additionalProperties": false
                  },
                  "organization": {
                    "type": "object",
                    "properties": {
                      "organizationName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "organizationName"
                    ],
                    "additionalProperties": false
                  },
                  "building": {
                    "type": "object",
                    "properties": {
                      "buildingName": {
                        "type": "string"
                      },
                      "buildingType": {
                        "type": "string",
                        "enum": [
                          "RESIDENTIAL",
                          "MIXED_USE",
                          "COMMERCIAL",
                          "OTHER"
                        ]
                      },
                      "constructionYear": {
                        "type": "integer",
                        "minimum": 1000,
                        "maximum": 2200
                      },
                      "floorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "undergroundFloorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "entranceCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "elevatorCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentsPerStaircase": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "apartmentLayout": {
                        "type": "object",
                        "properties": {
                          "version": {
                            "type": "number",
                            "const": 1
                          },
                          "staircases": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "staircaseNumber": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0,
                                  "maximum": 100
                                },
                                "apartmentCount": {
                                  "type": "integer",
                                  "minimum": 0,
                                  "maximum": 10000
                                },
                                "floors": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "floorNumber": {
                                        "type": "integer",
                                        "exclusiveMinimum": 0,
                                        "maximum": 200
                                      },
                                      "apartmentCount": {
                                        "type": "integer",
                                        "minimum": 0,
                                        "maximum": 1000
                                      }
                                    },
                                    "required": [
                                      "floorNumber",
                                      "apartmentCount"
                                    ],
                                    "additionalProperties": false
                                  },
                                  "maxItems": 200
                                }
                              },
                              "required": [
                                "staircaseNumber",
                                "apartmentCount",
                                "floors"
                              ],
                              "additionalProperties": false
                            },
                            "maxItems": 100
                          }
                        },
                        "required": [
                          "version",
                          "staircases"
                        ],
                        "additionalProperties": false
                      },
                      "totalArea": {
                        "type": "number",
                        "minimum": 0
                      },
                      "heatedArea": {
                        "type": "number",
                        "minimum": 0
                      },
                      "cadastreNumber": {
                        "type": "string"
                      },
                      "propertyCadastreNumber": {
                        "type": "string",
                        "pattern": "^\\d{11}$"
                      },
                      "buildingCadastreDesignation": {
                        "type": "string",
                        "pattern": "^\\d{14}$"
                      },
                      "landCadastreDesignations": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "pattern": "^\\d{11}$"
                        },
                        "maxItems": 20
                      },
                      "heatingType": {
                        "type": "string",
                        "maxLength": 30
                      },
                      "roofType": {
                        "type": "string",
                        "maxLength": 30
                      },
                      "parkingType": {
                        "type": "string",
                        "enum": [
                          "NONE",
                          "STREET",
                          "SURFACE",
                          "UNDERGROUND",
                          "MIXED"
                        ]
                      },
                      "parkingSpaceCount": {
                        "type": "integer",
                        "minimum": 0
                      },
                      "hasAccessibleEntrance": {
                        "type": "boolean"
                      },
                      "hasWheelchairLift": {
                        "type": "boolean"
                      },
                      "hasBasement": {
                        "type": "boolean"
                      },
                      "hasAttic": {
                        "type": "boolean"
                      },
                      "hasSharedUtilityMeters": {
                        "type": "boolean"
                      },
                      "hasFireSafetySystem": {
                        "type": "boolean"
                      },
                      "hasAccessControl": {
                        "type": "boolean"
                      },
                      "wasteCollectionNotes": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "emergencyAccessNotes": {
                        "type": "string",
                        "maxLength": 500
                      },
                      "cleaningWeekdays": {
                        "type": "array",
                        "items": {
                          "type": "string",
                          "enum": [
                            "MONDAY",
                            "TUESDAY",
                            "WEDNESDAY",
                            "THURSDAY",
                            "FRIDAY",
                            "SATURDAY",
                            "SUNDAY"
                          ]
                        },
                        "maxItems": 7
                      },
                      "cleaningExcludesHolidays": {
                        "type": "boolean"
                      },
                      "grassMowingResponsibility": {
                        "type": "string",
                        "enum": [
                          "SERVICE_PROVIDER",
                          "RESIDENTS",
                          "MIXED",
                          "NOT_APPLICABLE"
                        ]
                      },
                      "entranceAccessCodes": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "entranceLabel": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 100
                            },
                            "apartmentNumber": {
                              "type": "string",
                              "minLength": 1,
                              "maxLength": 20
                            },
                            "code": {
                              "type": "string",
                              "pattern": "^\\d{4}$"
                            }
                          },
                          "required": [
                            "apartmentNumber",
                            "code"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 50
                      },
                      "additionalDetails": {
                        "type": "object",
                        "additionalProperties": {}
                      }
                    },
                    "required": [
                      "buildingName"
                    ],
                    "additionalProperties": false
                  },
                  "primaryLocation": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "taxpayerNumber": {
                    "type": "string"
                  },
                  "ssnNumber": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "attribute1": {
                    "type": "string"
                  },
                  "attribute2": {
                    "type": "string"
                  },
                  "attribute3": {
                    "type": "string"
                  },
                  "attribute4": {
                    "type": "string"
                  },
                  "attribute5": {
                    "type": "string"
                  },
                  "attribute6": {
                    "type": "string"
                  },
                  "attribute7": {
                    "type": "string"
                  },
                  "attribute8": {
                    "type": "string"
                  },
                  "attribute9": {
                    "type": "string"
                  },
                  "attribute10": {
                    "type": "string"
                  },
                  "attribute11": {
                    "type": "string"
                  },
                  "attribute12": {
                    "type": "string"
                  },
                  "attribute13": {
                    "type": "string"
                  },
                  "attribute14": {
                    "type": "string"
                  },
                  "attribute15": {
                    "type": "string"
                  }
                },
                "required": [
                  "partyType",
                  "comments"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Client updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/clients/{clientId}/sites": {
      "get": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "List sites for CRM client",
        "operationId": "listClientSites",
        "security": [
          {
            "bearerApiKey": [
              "sites:read"
            ]
          },
          {
            "headerApiKey": [
              "sites:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "siteType": {
                            "type": "string",
                            "enum": [
                              "SITE",
                              "APARTMENT"
                            ]
                          },
                          "comments": {
                            "type": "string"
                          },
                          "siteUses": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "siteUseType": {
                                  "type": "string",
                                  "enum": [
                                    "BILLING",
                                    "MAILING",
                                    "SITE"
                                  ]
                                },
                                "primaryPerType": {
                                  "type": "boolean"
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "startDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "endDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              },
                              "required": [
                                "siteUseType",
                                "primaryPerType",
                                "active"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "location": {
                            "type": "object",
                            "properties": {
                              "addressLine1": {
                                "type": "string"
                              },
                              "addressLine2": {
                                "type": "string"
                              },
                              "addressLine3": {
                                "type": "string"
                              },
                              "addressLine4": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "county": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "postalCode": {
                                "type": "string"
                              },
                              "longitude": {
                                "type": "string"
                              },
                              "latitude": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "addressLine1",
                              "city",
                              "county",
                              "country",
                              "postalCode"
                            ],
                            "additionalProperties": false
                          },
                          "apartmentProfile": {
                            "type": "object",
                            "properties": {
                              "apartmentProfileId": {
                                "type": "number"
                              },
                              "apartmentNumber": {
                                "type": "string"
                              },
                              "staircase": {
                                "type": "string"
                              },
                              "floor": {
                                "type": "string"
                              },
                              "area": {
                                "type": "number"
                              },
                              "cadastreNumber": {
                                "type": "string"
                              },
                              "propertyCadastreNumber": {
                                "type": "string",
                                "pattern": "^\\d{11}$"
                              },
                              "premisesGroupCadastreDesignation": {
                                "type": "string",
                                "pattern": "^\\d{17}$"
                              },
                              "buildingUndividedShares": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "cadastralDesignation": {
                                      "type": "string",
                                      "pattern": "^\\d{14}$"
                                    },
                                    "numerator": {
                                      "type": "string",
                                      "pattern": "^\\d+$"
                                    },
                                    "denominator": {
                                      "type": "string",
                                      "pattern": "^[1-9]\\d*$"
                                    }
                                  },
                                  "required": [
                                    "cadastralDesignation",
                                    "numerator",
                                    "denominator"
                                  ],
                                  "additionalProperties": false
                                },
                                "maxItems": 20
                              },
                              "landUndividedShares": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "cadastralDesignation": {
                                      "type": "string",
                                      "pattern": "^\\d{11}$"
                                    },
                                    "numerator": {
                                      "type": "string",
                                      "pattern": "^\\d+$"
                                    },
                                    "denominator": {
                                      "type": "string",
                                      "pattern": "^[1-9]\\d*$"
                                    }
                                  },
                                  "required": [
                                    "cadastralDesignation",
                                    "numerator",
                                    "denominator"
                                  ],
                                  "additionalProperties": false
                                },
                                "maxItems": 20
                              },
                              "rooms": {
                                "type": "number"
                              },
                              "status": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "apartmentNumber"
                            ],
                            "additionalProperties": false
                          },
                          "owners": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "tenants": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "contactPoints": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "contactPointId": {
                                  "type": "number"
                                },
                                "siteId": {
                                  "type": "number"
                                },
                                "contactPointType": {
                                  "type": "string",
                                  "enum": [
                                    "EMAIL",
                                    "PHONE"
                                  ]
                                },
                                "text": {
                                  "type": "string",
                                  "minLength": 1
                                },
                                "description": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                }
                              },
                              "required": [
                                "contactPointType",
                                "text"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "siteId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "Create site for CRM client",
        "operationId": "createClientSite",
        "security": [
          {
            "bearerApiKey": [
              "sites:write"
            ]
          },
          {
            "headerApiKey": [
              "sites:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteName": {
                    "type": "string"
                  },
                  "siteType": {
                    "type": "string",
                    "enum": [
                      "SITE",
                      "APARTMENT"
                    ]
                  },
                  "comments": {
                    "type": "string"
                  },
                  "siteUses": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteUseType": {
                          "type": "string",
                          "enum": [
                            "BILLING",
                            "MAILING",
                            "SITE"
                          ]
                        },
                        "primaryPerType": {
                          "type": "boolean"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "siteUseType",
                        "primaryPerType",
                        "active"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "location": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "apartmentProfile": {
                    "type": "object",
                    "properties": {
                      "apartmentProfileId": {
                        "type": "number"
                      },
                      "apartmentNumber": {
                        "type": "string"
                      },
                      "staircase": {
                        "type": "string"
                      },
                      "floor": {
                        "type": "string"
                      },
                      "area": {
                        "type": "number"
                      },
                      "cadastreNumber": {
                        "type": "string"
                      },
                      "propertyCadastreNumber": {
                        "type": "string",
                        "pattern": "^\\d{11}$"
                      },
                      "premisesGroupCadastreDesignation": {
                        "type": "string",
                        "pattern": "^\\d{17}$"
                      },
                      "buildingUndividedShares": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "cadastralDesignation": {
                              "type": "string",
                              "pattern": "^\\d{14}$"
                            },
                            "numerator": {
                              "type": "string",
                              "pattern": "^\\d+$"
                            },
                            "denominator": {
                              "type": "string",
                              "pattern": "^[1-9]\\d*$"
                            }
                          },
                          "required": [
                            "cadastralDesignation",
                            "numerator",
                            "denominator"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 20
                      },
                      "landUndividedShares": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "cadastralDesignation": {
                              "type": "string",
                              "pattern": "^\\d{11}$"
                            },
                            "numerator": {
                              "type": "string",
                              "pattern": "^\\d+$"
                            },
                            "denominator": {
                              "type": "string",
                              "pattern": "^[1-9]\\d*$"
                            }
                          },
                          "required": [
                            "cadastralDesignation",
                            "numerator",
                            "denominator"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 20
                      },
                      "rooms": {
                        "type": "number"
                      },
                      "status": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "apartmentNumber"
                    ],
                    "additionalProperties": false
                  },
                  "owners": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tenants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "contactPoints": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "contactPointId": {
                          "type": "number"
                        },
                        "siteId": {
                          "type": "number"
                        },
                        "contactPointType": {
                          "type": "string",
                          "enum": [
                            "EMAIL",
                            "PHONE"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "contactPointType",
                        "text"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Client site created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/clients/{clientId}/sites/{siteId}": {
      "patch": {
        "tags": [
          "External CRM clients"
        ],
        "summary": "Update site for CRM client",
        "operationId": "updateClientSite",
        "security": [
          {
            "bearerApiKey": [
              "sites:write"
            ]
          },
          {
            "headerApiKey": [
              "sites:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "siteName": {
                    "type": "string"
                  },
                  "siteType": {
                    "type": "string",
                    "enum": [
                      "SITE",
                      "APARTMENT"
                    ]
                  },
                  "comments": {
                    "type": "string"
                  },
                  "siteUses": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteUseType": {
                          "type": "string",
                          "enum": [
                            "BILLING",
                            "MAILING",
                            "SITE"
                          ]
                        },
                        "primaryPerType": {
                          "type": "boolean"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        }
                      },
                      "required": [
                        "siteUseType",
                        "primaryPerType",
                        "active"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "location": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "apartmentProfile": {
                    "type": "object",
                    "properties": {
                      "apartmentProfileId": {
                        "type": "number"
                      },
                      "apartmentNumber": {
                        "type": "string"
                      },
                      "staircase": {
                        "type": "string"
                      },
                      "floor": {
                        "type": "string"
                      },
                      "area": {
                        "type": "number"
                      },
                      "cadastreNumber": {
                        "type": "string"
                      },
                      "propertyCadastreNumber": {
                        "type": "string",
                        "pattern": "^\\d{11}$"
                      },
                      "premisesGroupCadastreDesignation": {
                        "type": "string",
                        "pattern": "^\\d{17}$"
                      },
                      "buildingUndividedShares": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "cadastralDesignation": {
                              "type": "string",
                              "pattern": "^\\d{14}$"
                            },
                            "numerator": {
                              "type": "string",
                              "pattern": "^\\d+$"
                            },
                            "denominator": {
                              "type": "string",
                              "pattern": "^[1-9]\\d*$"
                            }
                          },
                          "required": [
                            "cadastralDesignation",
                            "numerator",
                            "denominator"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 20
                      },
                      "landUndividedShares": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "cadastralDesignation": {
                              "type": "string",
                              "pattern": "^\\d{11}$"
                            },
                            "numerator": {
                              "type": "string",
                              "pattern": "^\\d+$"
                            },
                            "denominator": {
                              "type": "string",
                              "pattern": "^[1-9]\\d*$"
                            }
                          },
                          "required": [
                            "cadastralDesignation",
                            "numerator",
                            "denominator"
                          ],
                          "additionalProperties": false
                        },
                        "maxItems": 20
                      },
                      "rooms": {
                        "type": "number"
                      },
                      "status": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "apartmentNumber"
                    ],
                    "additionalProperties": false
                  },
                  "owners": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tenants": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "contactPoints": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "contactPointId": {
                          "type": "number"
                        },
                        "siteId": {
                          "type": "number"
                        },
                        "contactPointType": {
                          "type": "string",
                          "enum": [
                            "EMAIL",
                            "PHONE"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        },
                        "description": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "contactPointType",
                        "text"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "siteId"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Client site updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/clients/{clientId}/contacts": {
      "get": {
        "tags": [
          "External CRM contacts"
        ],
        "summary": "List contacts for CRM client",
        "operationId": "listClientContacts",
        "security": [
          {
            "bearerApiKey": [
              "contacts:read"
            ]
          },
          {
            "headerApiKey": [
              "contacts:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactPointId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "contactPointType": {
                            "type": "string",
                            "enum": [
                              "PHONE",
                              "EMAIL",
                              "HOME_PHONE",
                              "RELATIVE_PHONE",
                              "TELEGRAM",
                              "WHATSAPP",
                              "WEBSITE",
                              "SKYPE"
                            ]
                          },
                          "text": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "contactPointId",
                          "contactPointType",
                          "text"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External CRM contacts"
        ],
        "summary": "Create contact for CRM client",
        "operationId": "createClientContact",
        "security": [
          {
            "bearerApiKey": [
              "contacts:write"
            ]
          },
          {
            "headerApiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "contactPointType": {
                    "type": "string",
                    "enum": [
                      "PHONE",
                      "EMAIL",
                      "HOME_PHONE",
                      "RELATIVE_PHONE",
                      "TELEGRAM",
                      "WHATSAPP",
                      "WEBSITE",
                      "SKYPE"
                    ]
                  },
                  "text": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "attribute1": {
                    "type": "string"
                  },
                  "attribute2": {
                    "type": "string"
                  },
                  "attribute3": {
                    "type": "string"
                  },
                  "attribute4": {
                    "type": "string"
                  },
                  "attribute5": {
                    "type": "string"
                  },
                  "attribute6": {
                    "type": "string"
                  },
                  "attribute7": {
                    "type": "string"
                  },
                  "attribute8": {
                    "type": "string"
                  },
                  "attribute9": {
                    "type": "string"
                  },
                  "attribute10": {
                    "type": "string"
                  },
                  "attribute11": {
                    "type": "string"
                  },
                  "attribute12": {
                    "type": "string"
                  },
                  "attribute13": {
                    "type": "string"
                  },
                  "attribute14": {
                    "type": "string"
                  },
                  "attribute15": {
                    "type": "string"
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "contactPointType",
                  "text"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Contact created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/contacts": {
      "get": {
        "tags": [
          "External CRM contacts"
        ],
        "summary": "List CRM contacts",
        "operationId": "listContacts",
        "security": [
          {
            "bearerApiKey": [
              "contacts:read"
            ]
          },
          {
            "headerApiKey": [
              "contacts:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "clientId",
            "in": "query",
            "required": false,
            "description": "Filter by client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactPointId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "contactPointType": {
                            "type": "string",
                            "enum": [
                              "PHONE",
                              "EMAIL",
                              "HOME_PHONE",
                              "RELATIVE_PHONE",
                              "TELEGRAM",
                              "WHATSAPP",
                              "WEBSITE",
                              "SKYPE"
                            ]
                          },
                          "text": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "contactPointId",
                          "contactPointType",
                          "text"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/contacts/{contactPointId}": {
      "patch": {
        "tags": [
          "External CRM contacts"
        ],
        "summary": "Update CRM contact",
        "operationId": "updateContact",
        "security": [
          {
            "bearerApiKey": [
              "contacts:write"
            ]
          },
          {
            "headerApiKey": [
              "contacts:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "contactPointId",
            "in": "path",
            "required": true,
            "description": "Contact point id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "contactPointId": {
                    "type": "number"
                  },
                  "siteId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "contactPointType": {
                    "type": "string",
                    "enum": [
                      "PHONE",
                      "EMAIL",
                      "HOME_PHONE",
                      "RELATIVE_PHONE",
                      "TELEGRAM",
                      "WHATSAPP",
                      "WEBSITE",
                      "SKYPE"
                    ]
                  },
                  "text": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "attribute1": {
                    "type": "string"
                  },
                  "attribute2": {
                    "type": "string"
                  },
                  "attribute3": {
                    "type": "string"
                  },
                  "attribute4": {
                    "type": "string"
                  },
                  "attribute5": {
                    "type": "string"
                  },
                  "attribute6": {
                    "type": "string"
                  },
                  "attribute7": {
                    "type": "string"
                  },
                  "attribute8": {
                    "type": "string"
                  },
                  "attribute9": {
                    "type": "string"
                  },
                  "attribute10": {
                    "type": "string"
                  },
                  "attribute11": {
                    "type": "string"
                  },
                  "attribute12": {
                    "type": "string"
                  },
                  "attribute13": {
                    "type": "string"
                  },
                  "attribute14": {
                    "type": "string"
                  },
                  "attribute15": {
                    "type": "string"
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "contactPointId",
                  "contactPointType",
                  "text"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Contact updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/locations": {
      "get": {
        "tags": [
          "External CRM locations"
        ],
        "summary": "List CRM site locations",
        "operationId": "listLocations",
        "security": [
          {
            "bearerApiKey": [
              "locations:read"
            ]
          },
          {
            "headerApiKey": [
              "locations:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "clientId",
            "in": "query",
            "required": false,
            "description": "Filter by client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "locationId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": "number"
                          },
                          "clientId": {
                            "type": "number"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "addressLine1": {
                            "type": "string"
                          },
                          "addressLine2": {
                            "type": "string"
                          },
                          "addressLine3": {
                            "type": "string"
                          },
                          "addressLine4": {
                            "type": "string"
                          },
                          "city": {
                            "type": "string"
                          },
                          "county": {
                            "type": "string"
                          },
                          "country": {
                            "type": "string"
                          },
                          "postalCode": {
                            "type": "string"
                          },
                          "longitude": {
                            "type": "string"
                          },
                          "latitude": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "locationId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/sites": {
      "get": {
        "tags": [
          "External CRM"
        ],
        "summary": "List organization sites",
        "operationId": "listSites",
        "security": [
          {
            "bearerApiKey": [
              "sites:read"
            ]
          },
          {
            "headerApiKey": [
              "sites:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "comments": {
                            "type": "string"
                          },
                          "siteUses": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "siteUseType": {
                                  "type": "string",
                                  "enum": [
                                    "BILLING",
                                    "MAILING",
                                    "SITE"
                                  ]
                                },
                                "primaryPerType": {
                                  "type": "boolean"
                                },
                                "active": {
                                  "type": "boolean"
                                },
                                "startDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "endDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "siteUseId": {
                                  "type": "number"
                                }
                              },
                              "required": [
                                "siteUseType",
                                "primaryPerType",
                                "active",
                                "siteUseId"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "location": {
                            "type": "object",
                            "properties": {
                              "addressLine1": {
                                "type": "string"
                              },
                              "addressLine2": {
                                "type": "string"
                              },
                              "addressLine3": {
                                "type": "string"
                              },
                              "addressLine4": {
                                "type": "string"
                              },
                              "city": {
                                "type": "string"
                              },
                              "county": {
                                "type": "string"
                              },
                              "country": {
                                "type": "string"
                              },
                              "postalCode": {
                                "type": "string"
                              },
                              "longitude": {
                                "type": "string"
                              },
                              "latitude": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              }
                            },
                            "required": [
                              "addressLine1",
                              "city",
                              "county",
                              "country",
                              "postalCode"
                            ],
                            "additionalProperties": false
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "siteId",
                          "siteName"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External CRM"
        ],
        "summary": "Create organization site with location",
        "operationId": "createSite",
        "security": [
          {
            "bearerApiKey": [
              "sites:write"
            ]
          },
          {
            "headerApiKey": [
              "sites:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteName": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "siteUses": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteUseType": {
                          "type": "string",
                          "enum": [
                            "BILLING",
                            "MAILING",
                            "SITE"
                          ]
                        },
                        "primaryPerType": {
                          "type": "boolean"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "siteUseId": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "siteUseType",
                        "primaryPerType",
                        "active",
                        "siteUseId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "location": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "siteName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Site created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/sites/{siteId}": {
      "get": {
        "tags": [
          "External CRM"
        ],
        "summary": "Get organization site",
        "operationId": "getSite",
        "security": [
          {
            "bearerApiKey": [
              "sites:read"
            ]
          },
          {
            "headerApiKey": [
              "sites:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "siteId": {
                      "type": "number"
                    },
                    "siteName": {
                      "type": "string"
                    },
                    "comments": {
                      "type": "string"
                    },
                    "siteUses": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteUseType": {
                            "type": "string",
                            "enum": [
                              "BILLING",
                              "MAILING",
                              "SITE"
                            ]
                          },
                          "primaryPerType": {
                            "type": "boolean"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteUseId": {
                            "type": "number"
                          }
                        },
                        "required": [
                          "siteUseType",
                          "primaryPerType",
                          "active",
                          "siteUseId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "location": {
                      "type": "object",
                      "properties": {
                        "addressLine1": {
                          "type": "string"
                        },
                        "addressLine2": {
                          "type": "string"
                        },
                        "addressLine3": {
                          "type": "string"
                        },
                        "addressLine4": {
                          "type": "string"
                        },
                        "city": {
                          "type": "string"
                        },
                        "county": {
                          "type": "string"
                        },
                        "country": {
                          "type": "string"
                        },
                        "postalCode": {
                          "type": "string"
                        },
                        "longitude": {
                          "type": "string"
                        },
                        "latitude": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "addressLine1",
                        "city",
                        "county",
                        "country",
                        "postalCode"
                      ],
                      "additionalProperties": false
                    },
                    "attachments": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "attachmentId": {
                                "type": "number"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "fileName": {
                                "type": "string"
                              },
                              "fileType": {
                                "type": "string"
                              },
                              "size": {
                                "type": "number"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    },
                    "notes": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "noteId": {
                                "type": "number"
                              },
                              "note": {
                                "type": "string"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "siteId",
                    "siteName"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External CRM"
        ],
        "summary": "Update organization site",
        "operationId": "updateSite",
        "security": [
          {
            "bearerApiKey": [
              "sites:write"
            ]
          },
          {
            "headerApiKey": [
              "sites:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteName": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "siteUses": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteUseType": {
                          "type": "string",
                          "enum": [
                            "BILLING",
                            "MAILING",
                            "SITE"
                          ]
                        },
                        "primaryPerType": {
                          "type": "boolean"
                        },
                        "active": {
                          "type": "boolean"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "siteUseId": {
                          "type": "number"
                        }
                      },
                      "required": [
                        "siteUseType",
                        "primaryPerType",
                        "active",
                        "siteUseId"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "location": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "attachments": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "attachmentId": {
                              "type": "number"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "fileName": {
                              "type": "string"
                            },
                            "fileType": {
                              "type": "string"
                            },
                            "size": {
                              "type": "number"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  },
                  "notes": {
                    "type": "object",
                    "properties": {
                      "count": {
                        "type": "number"
                      },
                      "list": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "noteId": {
                              "type": "number"
                            },
                            "note": {
                              "type": "string"
                            },
                            "editable": {
                              "type": "boolean"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "createDate": {
                              "type": "string",
                              "format": "date-time"
                            },
                            "createdBy": {
                              "type": "string"
                            }
                          },
                          "additionalProperties": false
                        }
                      }
                    },
                    "required": [
                      "count",
                      "list"
                    ],
                    "additionalProperties": false
                  }
                },
                "required": [
                  "siteName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Site updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/sites/{siteId}/equipment": {
      "get": {
        "tags": [
          "External setup"
        ],
        "summary": "List equipment",
        "operationId": "listSiteEquipment",
        "security": [
          {
            "bearerApiKey": [
              "setup:read"
            ]
          },
          {
            "headerApiKey": [
              "setup:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteEquipmentId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "partyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "siteEquipmentName": {
                            "type": "string"
                          },
                          "comments": {
                            "type": "string"
                          },
                          "skillType": {
                            "type": "string"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "operatorCount": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meterEnabled": {
                            "type": "boolean",
                            "default": false
                          },
                          "serialNumber": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 150
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utilityType": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 30
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "utilitySubtype": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 30
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "measurementUnit": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 30
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "readingPrecision": {
                            "type": "integer",
                            "minimum": 0,
                            "maximum": 6,
                            "default": 3
                          },
                          "rolloverValue": {
                            "anyOf": [
                              {
                                "type": "number",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationValidFrom": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationValidUntil": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "shifts": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "siteEquipmentShiftId": {
                                  "type": "number"
                                },
                                "shiftName": {
                                  "type": "string"
                                },
                                "comments": {
                                  "type": "string"
                                },
                                "startDateActive": {
                                  "type": "string",
                                  "format": "date-time"
                                },
                                "endDateActive": {
                                  "anyOf": [
                                    {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    {
                                      "type": "null"
                                    }
                                  ]
                                },
                                "shiftStartTime": {
                                  "type": "string"
                                },
                                "shiftEndTime": {
                                  "type": "string"
                                },
                                "holidays": {
                                  "type": "boolean"
                                },
                                "monday": {
                                  "type": "boolean"
                                },
                                "tuesday": {
                                  "type": "boolean"
                                },
                                "wednesday": {
                                  "type": "boolean"
                                },
                                "thursday": {
                                  "type": "boolean"
                                },
                                "friday": {
                                  "type": "boolean"
                                },
                                "saturday": {
                                  "type": "boolean"
                                },
                                "sunday": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "holidays",
                                "monday",
                                "tuesday",
                                "wednesday",
                                "thursday",
                                "friday",
                                "saturday",
                                "sunday"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "siteEquipmentName"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External setup"
        ],
        "summary": "Create equipment",
        "operationId": "createSiteEquipment",
        "security": [
          {
            "bearerApiKey": [
              "setup:write"
            ]
          },
          {
            "headerApiKey": [
              "setup:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteEquipmentName": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "skillType": {
                    "type": "string"
                  },
                  "active": {
                    "type": "boolean"
                  },
                  "operatorCount": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "meterEnabled": {
                    "type": "boolean",
                    "default": false
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utilityType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utilitySubtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "measurementUnit": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "shifts": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteEquipmentShiftId": {
                          "type": "number"
                        },
                        "shiftName": {
                          "type": "string"
                        },
                        "comments": {
                          "type": "string"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "shiftStartTime": {
                          "type": "string"
                        },
                        "shiftEndTime": {
                          "type": "string"
                        },
                        "holidays": {
                          "type": "boolean"
                        },
                        "monday": {
                          "type": "boolean"
                        },
                        "tuesday": {
                          "type": "boolean"
                        },
                        "wednesday": {
                          "type": "boolean"
                        },
                        "thursday": {
                          "type": "boolean"
                        },
                        "friday": {
                          "type": "boolean"
                        },
                        "saturday": {
                          "type": "boolean"
                        },
                        "sunday": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "holidays",
                        "monday",
                        "tuesday",
                        "wednesday",
                        "thursday",
                        "friday",
                        "saturday",
                        "sunday"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "siteEquipmentName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Equipment created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/sites/{siteId}/equipment/{equipmentId}": {
      "get": {
        "tags": [
          "External setup"
        ],
        "summary": "Get equipment",
        "operationId": "getSiteEquipment",
        "security": [
          {
            "bearerApiKey": [
              "setup:read"
            ]
          },
          {
            "headerApiKey": [
              "setup:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "path",
            "required": true,
            "description": "Equipment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "siteEquipmentId": {
                      "type": "number"
                    },
                    "siteId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "partyId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "siteEquipmentName": {
                      "type": "string"
                    },
                    "comments": {
                      "type": "string"
                    },
                    "skillType": {
                      "type": "string"
                    },
                    "active": {
                      "type": "boolean"
                    },
                    "operatorCount": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "startDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endDateActive": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "meterEnabled": {
                      "type": "boolean",
                      "default": false
                    },
                    "serialNumber": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 150
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utilityType": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 30
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "utilitySubtype": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 30
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "measurementUnit": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 30
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "readingPrecision": {
                      "type": "integer",
                      "minimum": 0,
                      "maximum": 6,
                      "default": 3
                    },
                    "rolloverValue": {
                      "anyOf": [
                        {
                          "type": "number",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationValidFrom": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "verificationValidUntil": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "attachments": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "attachmentId": {
                                "type": "number"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "fileName": {
                                "type": "string"
                              },
                              "fileType": {
                                "type": "string"
                              },
                              "size": {
                                "type": "number"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    },
                    "notes": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "noteId": {
                                "type": "number"
                              },
                              "note": {
                                "type": "string"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "siteEquipmentName"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External setup"
        ],
        "summary": "Update equipment",
        "operationId": "updateSiteEquipment",
        "security": [
          {
            "bearerApiKey": [
              "setup:write"
            ]
          },
          {
            "headerApiKey": [
              "setup:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "path",
            "required": true,
            "description": "Equipment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteEquipmentName": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "skillType": {
                    "type": "string"
                  },
                  "active": {
                    "type": "boolean"
                  },
                  "operatorCount": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "meterEnabled": {
                    "type": "boolean",
                    "default": false
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utilityType": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "utilitySubtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "measurementUnit": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "shifts": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteEquipmentShiftId": {
                          "type": "number"
                        },
                        "shiftName": {
                          "type": "string"
                        },
                        "comments": {
                          "type": "string"
                        },
                        "startDateActive": {
                          "type": "string",
                          "format": "date-time"
                        },
                        "endDateActive": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "shiftStartTime": {
                          "type": "string"
                        },
                        "shiftEndTime": {
                          "type": "string"
                        },
                        "holidays": {
                          "type": "boolean"
                        },
                        "monday": {
                          "type": "boolean"
                        },
                        "tuesday": {
                          "type": "boolean"
                        },
                        "wednesday": {
                          "type": "boolean"
                        },
                        "thursday": {
                          "type": "boolean"
                        },
                        "friday": {
                          "type": "boolean"
                        },
                        "saturday": {
                          "type": "boolean"
                        },
                        "sunday": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "holidays",
                        "monday",
                        "tuesday",
                        "wednesday",
                        "thursday",
                        "friday",
                        "saturday",
                        "sunday"
                      ],
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "siteEquipmentName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Equipment updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External setup"
        ],
        "summary": "Delete equipment",
        "operationId": "deleteSiteEquipment",
        "security": [
          {
            "bearerApiKey": [
              "setup:write"
            ]
          },
          {
            "headerApiKey": [
              "setup:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "path",
            "required": true,
            "description": "Equipment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Equipment deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/compensations": {
      "get": {
        "tags": [
          "External compensation"
        ],
        "summary": "List compensation definitions",
        "operationId": "listCompensations",
        "security": [
          {
            "bearerApiKey": [
              "compensation:read"
            ]
          },
          {
            "headerApiKey": [
              "compensation:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External compensation"
        ],
        "summary": "Create compensation definition",
        "operationId": "createCompensation",
        "security": [
          {
            "bearerApiKey": [
              "compensation:write"
            ]
          },
          {
            "headerApiKey": [
              "compensation:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "compensationName": {
                    "type": "string",
                    "minLength": 1
                  },
                  "lines": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "amount": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "overtimeAmount": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "holidayAmount": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "ccy": {
                          "type": "string",
                          "maxLength": 15,
                          "default": "EUR"
                        },
                        "startDateActive": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "not": {}
                                },
                                {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "endDateActive": {
                          "anyOf": [
                            {
                              "anyOf": [
                                {
                                  "not": {}
                                },
                                {
                                  "type": "string",
                                  "format": "date-time"
                                }
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "additionalProperties": false
                    },
                    "default": []
                  }
                },
                "required": [
                  "compensationName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "compensationName": "Default hourly",
                "lines": [
                  {
                    "amount": 12.5,
                    "overtimeAmount": 18.75,
                    "holidayAmount": 25,
                    "ccy": "EUR"
                  }
                ]
              }
            }
          }
        },
        "x-example": {
          "compensationName": "Default hourly",
          "lines": [
            {
              "amount": 12.5,
              "overtimeAmount": 18.75,
              "holidayAmount": 25,
              "ccy": "EUR"
            }
          ]
        },
        "responses": {
          "201": {
            "description": "Compensation definition created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/employees/{employeeId}/compensations": {
      "post": {
        "tags": [
          "External compensation"
        ],
        "summary": "Assign compensation to employee",
        "operationId": "assignEmployeeCompensation",
        "security": [
          {
            "bearerApiKey": [
              "compensation:write"
            ]
          },
          {
            "headerApiKey": [
              "compensation:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "employeeId",
            "in": "path",
            "required": true,
            "description": "Employee party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "compensationHeaderId": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "format": "date-time"
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "format": "date-time"
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "compensationHeaderId"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "compensationHeaderId": 45,
                "startDateActive": "2026-08-01T00:00:00.000Z"
              }
            }
          }
        },
        "x-example": {
          "compensationHeaderId": 45,
          "startDateActive": "2026-08-01T00:00:00.000Z"
        },
        "responses": {
          "201": {
            "description": "Compensation assigned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/materials": {
      "get": {
        "tags": [
          "External materials"
        ],
        "summary": "List materials",
        "operationId": "listMaterials",
        "security": [
          {
            "bearerApiKey": [
              "materials:read"
            ]
          },
          {
            "headerApiKey": [
              "materials:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "materialId": {
                            "type": "number"
                          },
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "dimensionType": {
                            "type": "string"
                          },
                          "referenceId": {
                            "type": "string"
                          },
                          "price": {
                            "anyOf": [
                              {
                                "type": "number",
                                "minimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "ccy": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 30
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "string",
                                "const": ""
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "materialId",
                          "startDateActive"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External materials"
        ],
        "summary": "Create material",
        "operationId": "createMaterial",
        "security": [
          {
            "bearerApiKey": [
              "materials:write"
            ]
          },
          {
            "headerApiKey": [
              "materials:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "dimensionType": {
                    "type": "string"
                  },
                  "referenceId": {
                    "type": "string"
                  },
                  "price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ccy": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "string",
                        "const": ""
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "dimensionType",
                  "startDateActive"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Material created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/materials/{materialId}": {
      "get": {
        "tags": [
          "External materials"
        ],
        "summary": "Get material",
        "operationId": "getMaterial",
        "security": [
          {
            "bearerApiKey": [
              "materials:read"
            ]
          },
          {
            "headerApiKey": [
              "materials:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "materialId",
            "in": "path",
            "required": true,
            "description": "Material id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "description": {
                      "type": "string"
                    },
                    "dimensionType": {
                      "type": "string"
                    },
                    "referenceId": {
                      "type": "string"
                    },
                    "price": {
                      "anyOf": [
                        {
                          "type": "number",
                          "minimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ccy": {
                      "anyOf": [
                        {
                          "type": "string",
                          "maxLength": 30
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "startDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endDateActive": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "string",
                          "const": ""
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "attachments": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "attachmentId": {
                                "type": "number"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "fileName": {
                                "type": "string"
                              },
                              "fileType": {
                                "type": "string"
                              },
                              "size": {
                                "type": "number"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    },
                    "notes": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "noteId": {
                                "type": "number"
                              },
                              "note": {
                                "type": "string"
                              },
                              "editable": {
                                "type": "boolean"
                              },
                              "description": {
                                "type": "string"
                              },
                              "attribute1": {
                                "type": "string"
                              },
                              "attribute2": {
                                "type": "string"
                              },
                              "attribute3": {
                                "type": "string"
                              },
                              "attribute4": {
                                "type": "string"
                              },
                              "attribute5": {
                                "type": "string"
                              },
                              "attribute6": {
                                "type": "string"
                              },
                              "attribute7": {
                                "type": "string"
                              },
                              "attribute8": {
                                "type": "string"
                              },
                              "attribute9": {
                                "type": "string"
                              },
                              "attribute10": {
                                "type": "string"
                              },
                              "attribute11": {
                                "type": "string"
                              },
                              "attribute12": {
                                "type": "string"
                              },
                              "attribute13": {
                                "type": "string"
                              },
                              "attribute14": {
                                "type": "string"
                              },
                              "attribute15": {
                                "type": "string"
                              },
                              "createDate": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "createdBy": {
                                "type": "string"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "startDateActive"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External materials"
        ],
        "summary": "Update material",
        "operationId": "updateMaterial",
        "security": [
          {
            "bearerApiKey": [
              "materials:write"
            ]
          },
          {
            "headerApiKey": [
              "materials:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "materialId",
            "in": "path",
            "required": true,
            "description": "Material id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "dimensionType": {
                    "type": "string"
                  },
                  "referenceId": {
                    "type": "string"
                  },
                  "price": {
                    "anyOf": [
                      {
                        "type": "number",
                        "minimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "ccy": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "string",
                        "const": ""
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "name",
                  "dimensionType",
                  "startDateActive"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Material updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/suppliers": {
      "get": {
        "tags": [
          "External suppliers"
        ],
        "summary": "List suppliers",
        "description": "Returns suppliers linked to the API key's organization.",
        "operationId": "listSuppliers",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:read"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "Search supplier name, number, service type, or address.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "serviceType",
            "in": "query",
            "required": false,
            "description": "Filter by supplier service type code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort direction (ASC or DESC).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyId": {
                            "type": "number"
                          },
                          "partyName": {
                            "type": "string"
                          },
                          "partyNumber": {
                            "type": "string"
                          },
                          "partyType": {
                            "type": "string",
                            "enum": [
                              "PERSON",
                              "ORGANIZATION",
                              "BUILDING",
                              "SUPPLIER"
                            ]
                          },
                          "logo": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "email": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "isSupplier": {
                            "type": "boolean"
                          },
                          "isClient": {
                            "type": "boolean"
                          },
                          "primaryLocation": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "addressLine1": {
                                    "type": "string"
                                  },
                                  "addressLine2": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "addressLine3": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "addressLine4": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "city": {
                                    "type": "string"
                                  },
                                  "county": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "country": {
                                    "type": "string"
                                  },
                                  "postalCode": {
                                    "type": "string"
                                  },
                                  "longitude": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "latitude": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  }
                                },
                                "required": [
                                  "addressLine1",
                                  "city",
                                  "country",
                                  "postalCode"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "contactPoints": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "contactPointId": {
                                  "type": "number"
                                },
                                "siteId": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "contactPointType": {
                                  "type": "string",
                                  "enum": [
                                    "PHONE",
                                    "EMAIL",
                                    "HOME_PHONE",
                                    "RELATIVE_PHONE",
                                    "TELEGRAM",
                                    "WHATSAPP",
                                    "WEBSITE",
                                    "SKYPE"
                                  ]
                                },
                                "text": {
                                  "type": "string"
                                },
                                "description": {
                                  "type": "string"
                                },
                                "attribute1": {
                                  "type": "string"
                                },
                                "attribute2": {
                                  "type": "string"
                                },
                                "attribute3": {
                                  "type": "string"
                                },
                                "attribute4": {
                                  "type": "string"
                                },
                                "attribute5": {
                                  "type": "string"
                                },
                                "attribute6": {
                                  "type": "string"
                                },
                                "attribute7": {
                                  "type": "string"
                                },
                                "attribute8": {
                                  "type": "string"
                                },
                                "attribute9": {
                                  "type": "string"
                                },
                                "attribute10": {
                                  "type": "string"
                                },
                                "attribute11": {
                                  "type": "string"
                                },
                                "attribute12": {
                                  "type": "string"
                                },
                                "attribute13": {
                                  "type": "string"
                                },
                                "attribute14": {
                                  "type": "string"
                                },
                                "attribute15": {
                                  "type": "string"
                                },
                                "attachments": {
                                  "type": "object",
                                  "properties": {
                                    "count": {
                                      "type": "number"
                                    },
                                    "list": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "attachmentId": {
                                            "type": "number"
                                          },
                                          "editable": {
                                            "type": "boolean"
                                          },
                                          "fileName": {
                                            "type": "string"
                                          },
                                          "fileType": {
                                            "type": "string"
                                          },
                                          "size": {
                                            "type": "number"
                                          },
                                          "description": {
                                            "type": "string"
                                          },
                                          "attribute1": {
                                            "type": "string"
                                          },
                                          "attribute2": {
                                            "type": "string"
                                          },
                                          "attribute3": {
                                            "type": "string"
                                          },
                                          "attribute4": {
                                            "type": "string"
                                          },
                                          "attribute5": {
                                            "type": "string"
                                          },
                                          "attribute6": {
                                            "type": "string"
                                          },
                                          "attribute7": {
                                            "type": "string"
                                          },
                                          "attribute8": {
                                            "type": "string"
                                          },
                                          "attribute9": {
                                            "type": "string"
                                          },
                                          "attribute10": {
                                            "type": "string"
                                          },
                                          "attribute11": {
                                            "type": "string"
                                          },
                                          "attribute12": {
                                            "type": "string"
                                          },
                                          "attribute13": {
                                            "type": "string"
                                          },
                                          "attribute14": {
                                            "type": "string"
                                          },
                                          "attribute15": {
                                            "type": "string"
                                          },
                                          "createDate": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "createdBy": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "count",
                                    "list"
                                  ],
                                  "additionalProperties": false
                                },
                                "notes": {
                                  "type": "object",
                                  "properties": {
                                    "count": {
                                      "type": "number"
                                    },
                                    "list": {
                                      "type": "array",
                                      "items": {
                                        "type": "object",
                                        "properties": {
                                          "noteId": {
                                            "type": "number"
                                          },
                                          "note": {
                                            "type": "string"
                                          },
                                          "editable": {
                                            "type": "boolean"
                                          },
                                          "description": {
                                            "type": "string"
                                          },
                                          "attribute1": {
                                            "type": "string"
                                          },
                                          "attribute2": {
                                            "type": "string"
                                          },
                                          "attribute3": {
                                            "type": "string"
                                          },
                                          "attribute4": {
                                            "type": "string"
                                          },
                                          "attribute5": {
                                            "type": "string"
                                          },
                                          "attribute6": {
                                            "type": "string"
                                          },
                                          "attribute7": {
                                            "type": "string"
                                          },
                                          "attribute8": {
                                            "type": "string"
                                          },
                                          "attribute9": {
                                            "type": "string"
                                          },
                                          "attribute10": {
                                            "type": "string"
                                          },
                                          "attribute11": {
                                            "type": "string"
                                          },
                                          "attribute12": {
                                            "type": "string"
                                          },
                                          "attribute13": {
                                            "type": "string"
                                          },
                                          "attribute14": {
                                            "type": "string"
                                          },
                                          "attribute15": {
                                            "type": "string"
                                          },
                                          "createDate": {
                                            "type": "string",
                                            "format": "date-time"
                                          },
                                          "createdBy": {
                                            "type": "string"
                                          }
                                        },
                                        "additionalProperties": false
                                      }
                                    }
                                  },
                                  "required": [
                                    "count",
                                    "list"
                                  ],
                                  "additionalProperties": false
                                }
                              },
                              "required": [
                                "contactPointId",
                                "contactPointType",
                                "text"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "serviceTypes": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "serviceType": {
                                  "type": "string"
                                },
                                "meaning": {
                                  "type": "string"
                                }
                              },
                              "required": [
                                "serviceType"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External suppliers"
        ],
        "summary": "Create supplier",
        "operationId": "createSupplier",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:write"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "origSystemReference": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "partyType": {
                    "type": "string",
                    "const": "SUPPLIER",
                    "default": "SUPPLIER"
                  },
                  "supplierName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "person": {
                    "type": "object",
                    "properties": {
                      "personFirstName": {
                        "type": "string"
                      },
                      "personMiddleName": {
                        "type": "string"
                      },
                      "personLastName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "personFirstName",
                      "personLastName"
                    ],
                    "additionalProperties": false
                  },
                  "organization": {
                    "type": "object",
                    "properties": {
                      "organizationName": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "organizationName"
                    ],
                    "additionalProperties": false
                  },
                  "primaryLocation": {
                    "type": "object",
                    "properties": {
                      "addressLine1": {
                        "type": "string"
                      },
                      "addressLine2": {
                        "type": "string"
                      },
                      "addressLine3": {
                        "type": "string"
                      },
                      "addressLine4": {
                        "type": "string"
                      },
                      "city": {
                        "type": "string"
                      },
                      "county": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "postalCode": {
                        "type": "string"
                      },
                      "longitude": {
                        "type": "string"
                      },
                      "latitude": {
                        "type": "string"
                      },
                      "attribute1": {
                        "type": "string"
                      },
                      "attribute2": {
                        "type": "string"
                      },
                      "attribute3": {
                        "type": "string"
                      },
                      "attribute4": {
                        "type": "string"
                      },
                      "attribute5": {
                        "type": "string"
                      },
                      "attribute6": {
                        "type": "string"
                      },
                      "attribute7": {
                        "type": "string"
                      },
                      "attribute8": {
                        "type": "string"
                      },
                      "attribute9": {
                        "type": "string"
                      },
                      "attribute10": {
                        "type": "string"
                      },
                      "attribute11": {
                        "type": "string"
                      },
                      "attribute12": {
                        "type": "string"
                      },
                      "attribute13": {
                        "type": "string"
                      },
                      "attribute14": {
                        "type": "string"
                      },
                      "attribute15": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "addressLine1",
                      "city",
                      "county",
                      "country",
                      "postalCode"
                    ],
                    "additionalProperties": false
                  },
                  "taxpayerNumber": {
                    "type": "string",
                    "maxLength": 30
                  },
                  "ssnNumber": {
                    "type": "string",
                    "maxLength": 100
                  },
                  "comments": {
                    "type": "string",
                    "maxLength": 255
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "contactPoints": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "siteId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "contactPointType": {
                          "type": "string",
                          "enum": [
                            "PHONE",
                            "EMAIL",
                            "HOME_PHONE",
                            "RELATIVE_PHONE",
                            "TELEGRAM",
                            "WHATSAPP",
                            "WEBSITE",
                            "SKYPE"
                          ]
                        },
                        "text": {
                          "type": "string"
                        },
                        "description": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        },
                        "attachments": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "number"
                            },
                            "list": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "attachmentId": {
                                    "type": "number"
                                  },
                                  "editable": {
                                    "type": "boolean"
                                  },
                                  "fileName": {
                                    "type": "string"
                                  },
                                  "fileType": {
                                    "type": "string"
                                  },
                                  "size": {
                                    "type": "number"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "attribute1": {
                                    "type": "string"
                                  },
                                  "attribute2": {
                                    "type": "string"
                                  },
                                  "attribute3": {
                                    "type": "string"
                                  },
                                  "attribute4": {
                                    "type": "string"
                                  },
                                  "attribute5": {
                                    "type": "string"
                                  },
                                  "attribute6": {
                                    "type": "string"
                                  },
                                  "attribute7": {
                                    "type": "string"
                                  },
                                  "attribute8": {
                                    "type": "string"
                                  },
                                  "attribute9": {
                                    "type": "string"
                                  },
                                  "attribute10": {
                                    "type": "string"
                                  },
                                  "attribute11": {
                                    "type": "string"
                                  },
                                  "attribute12": {
                                    "type": "string"
                                  },
                                  "attribute13": {
                                    "type": "string"
                                  },
                                  "attribute14": {
                                    "type": "string"
                                  },
                                  "attribute15": {
                                    "type": "string"
                                  },
                                  "createDate": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "createdBy": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "count",
                            "list"
                          ],
                          "additionalProperties": false
                        },
                        "notes": {
                          "type": "object",
                          "properties": {
                            "count": {
                              "type": "number"
                            },
                            "list": {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "properties": {
                                  "noteId": {
                                    "type": "number"
                                  },
                                  "note": {
                                    "type": "string"
                                  },
                                  "editable": {
                                    "type": "boolean"
                                  },
                                  "description": {
                                    "type": "string"
                                  },
                                  "attribute1": {
                                    "type": "string"
                                  },
                                  "attribute2": {
                                    "type": "string"
                                  },
                                  "attribute3": {
                                    "type": "string"
                                  },
                                  "attribute4": {
                                    "type": "string"
                                  },
                                  "attribute5": {
                                    "type": "string"
                                  },
                                  "attribute6": {
                                    "type": "string"
                                  },
                                  "attribute7": {
                                    "type": "string"
                                  },
                                  "attribute8": {
                                    "type": "string"
                                  },
                                  "attribute9": {
                                    "type": "string"
                                  },
                                  "attribute10": {
                                    "type": "string"
                                  },
                                  "attribute11": {
                                    "type": "string"
                                  },
                                  "attribute12": {
                                    "type": "string"
                                  },
                                  "attribute13": {
                                    "type": "string"
                                  },
                                  "attribute14": {
                                    "type": "string"
                                  },
                                  "attribute15": {
                                    "type": "string"
                                  },
                                  "createDate": {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  "createdBy": {
                                    "type": "string"
                                  }
                                },
                                "additionalProperties": false
                              }
                            }
                          },
                          "required": [
                            "count",
                            "list"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "required": [
                        "contactPointType",
                        "text"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "serviceTypes": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 30
                    }
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "supplierName": "Riga Lift Service",
                "organization": {
                  "organizationName": "Riga Lift Service"
                },
                "taxpayerNumber": "LV40000000000",
                "primaryLocation": {
                  "addressLine1": "Brivibas iela 1",
                  "city": "Riga",
                  "country": "LV",
                  "postalCode": "LV-1010"
                },
                "contactPoints": [
                  {
                    "contactPointType": "EMAIL",
                    "text": "service@example.com"
                  },
                  {
                    "contactPointType": "PHONE",
                    "text": "+37120000000"
                  }
                ],
                "serviceTypes": [
                  "ELEVATOR_MAINTENANCE"
                ]
              }
            }
          }
        },
        "x-example": {
          "supplierName": "Riga Lift Service",
          "organization": {
            "organizationName": "Riga Lift Service"
          },
          "taxpayerNumber": "LV40000000000",
          "primaryLocation": {
            "addressLine1": "Brivibas iela 1",
            "city": "Riga",
            "country": "LV",
            "postalCode": "LV-1010"
          },
          "contactPoints": [
            {
              "contactPointType": "EMAIL",
              "text": "service@example.com"
            },
            {
              "contactPointType": "PHONE",
              "text": "+37120000000"
            }
          ],
          "serviceTypes": [
            "ELEVATOR_MAINTENANCE"
          ]
        },
        "responses": {
          "201": {
            "description": "Supplier created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/suppliers/{supplierPartyId}": {
      "get": {
        "tags": [
          "External suppliers"
        ],
        "summary": "Get supplier details",
        "description": "Includes supplier services, contacts, location, attachments, notes, agreements, and employees.",
        "operationId": "getSupplier",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:read"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "supplierPartyId",
            "in": "path",
            "required": true,
            "description": "Supplier party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "partyId": {
                      "type": "number"
                    },
                    "partyName": {
                      "type": "string"
                    },
                    "partyNumber": {
                      "type": "string"
                    },
                    "partyType": {
                      "type": "string",
                      "enum": [
                        "PERSON",
                        "ORGANIZATION",
                        "BUILDING",
                        "SUPPLIER"
                      ]
                    },
                    "logo": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "email": {
                      "type": "string"
                    },
                    "phone": {
                      "type": "string"
                    },
                    "isSupplier": {
                      "type": "boolean"
                    },
                    "isClient": {
                      "type": "boolean"
                    },
                    "primaryLocation": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "addressLine1": {
                              "type": "string"
                            },
                            "addressLine2": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "addressLine3": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "addressLine4": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "city": {
                              "type": "string"
                            },
                            "county": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "country": {
                              "type": "string"
                            },
                            "postalCode": {
                              "type": "string"
                            },
                            "longitude": {
                              "type": [
                                "string",
                                "null"
                              ]
                            },
                            "latitude": {
                              "type": [
                                "string",
                                "null"
                              ]
                            }
                          },
                          "required": [
                            "addressLine1",
                            "city",
                            "country",
                            "postalCode"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "contactPoints": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "contactPointId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "contactPointType": {
                            "type": "string",
                            "enum": [
                              "PHONE",
                              "EMAIL",
                              "HOME_PHONE",
                              "RELATIVE_PHONE",
                              "TELEGRAM",
                              "WHATSAPP",
                              "WEBSITE",
                              "SKYPE"
                            ]
                          },
                          "text": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          },
                          "attachments": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "attachmentId": {
                                      "type": "number"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "fileName": {
                                      "type": "string"
                                    },
                                    "fileType": {
                                      "type": "string"
                                    },
                                    "size": {
                                      "type": "number"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          },
                          "notes": {
                            "type": "object",
                            "properties": {
                              "count": {
                                "type": "number"
                              },
                              "list": {
                                "type": "array",
                                "items": {
                                  "type": "object",
                                  "properties": {
                                    "noteId": {
                                      "type": "number"
                                    },
                                    "note": {
                                      "type": "string"
                                    },
                                    "editable": {
                                      "type": "boolean"
                                    },
                                    "description": {
                                      "type": "string"
                                    },
                                    "attribute1": {
                                      "type": "string"
                                    },
                                    "attribute2": {
                                      "type": "string"
                                    },
                                    "attribute3": {
                                      "type": "string"
                                    },
                                    "attribute4": {
                                      "type": "string"
                                    },
                                    "attribute5": {
                                      "type": "string"
                                    },
                                    "attribute6": {
                                      "type": "string"
                                    },
                                    "attribute7": {
                                      "type": "string"
                                    },
                                    "attribute8": {
                                      "type": "string"
                                    },
                                    "attribute9": {
                                      "type": "string"
                                    },
                                    "attribute10": {
                                      "type": "string"
                                    },
                                    "attribute11": {
                                      "type": "string"
                                    },
                                    "attribute12": {
                                      "type": "string"
                                    },
                                    "attribute13": {
                                      "type": "string"
                                    },
                                    "attribute14": {
                                      "type": "string"
                                    },
                                    "attribute15": {
                                      "type": "string"
                                    },
                                    "createDate": {
                                      "type": "string",
                                      "format": "date-time"
                                    },
                                    "createdBy": {
                                      "type": "string"
                                    }
                                  },
                                  "additionalProperties": false
                                }
                              }
                            },
                            "required": [
                              "count",
                              "list"
                            ],
                            "additionalProperties": false
                          }
                        },
                        "required": [
                          "contactPointId",
                          "contactPointType",
                          "text"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "serviceTypes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "serviceType": {
                            "type": "string"
                          },
                          "meaning": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "serviceType"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "person": {
                      "type": "object",
                      "properties": {
                        "personFirstName": {
                          "type": "string"
                        },
                        "personMiddleName": {
                          "type": "string"
                        },
                        "personLastName": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "personFirstName",
                        "personLastName"
                      ],
                      "additionalProperties": false
                    },
                    "organization": {
                      "type": "object",
                      "properties": {
                        "organizationName": {
                          "type": "string"
                        },
                        "attribute1": {
                          "type": "string"
                        },
                        "attribute2": {
                          "type": "string"
                        },
                        "attribute3": {
                          "type": "string"
                        },
                        "attribute4": {
                          "type": "string"
                        },
                        "attribute5": {
                          "type": "string"
                        },
                        "attribute6": {
                          "type": "string"
                        },
                        "attribute7": {
                          "type": "string"
                        },
                        "attribute8": {
                          "type": "string"
                        },
                        "attribute9": {
                          "type": "string"
                        },
                        "attribute10": {
                          "type": "string"
                        },
                        "attribute11": {
                          "type": "string"
                        },
                        "attribute12": {
                          "type": "string"
                        },
                        "attribute13": {
                          "type": "string"
                        },
                        "attribute14": {
                          "type": "string"
                        },
                        "attribute15": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "organizationName"
                      ],
                      "additionalProperties": false
                    },
                    "taxpayerNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "comments": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "startDateActive": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "endDateActive": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "attachments": {
                      "$ref": "#/properties/contactPoints/items/properties/attachments"
                    },
                    "notes": {
                      "$ref": "#/properties/contactPoints/items/properties/notes"
                    },
                    "agreements": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "agreementId": {
                                "type": "number"
                              },
                              "scopeType": {
                                "type": "string",
                                "enum": [
                                  "OWN_COMPANY",
                                  "CLIENT",
                                  "CLIENT_SITE",
                                  "EQUIPMENT"
                                ]
                              },
                              "clientPartyId": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "clientPartyName": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "clientSiteId": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "clientSiteName": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "address": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "siteEquipmentId": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "siteEquipmentName": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "supplierPartyId": {
                                "type": "number"
                              },
                              "supplierPartyName": {
                                "type": "string"
                              },
                              "supplierPartyType": {
                                "type": "string",
                                "enum": [
                                  "PERSON",
                                  "ORGANIZATION",
                                  "BUILDING",
                                  "SUPPLIER"
                                ]
                              },
                              "supplierServiceTypes": {
                                "type": "array",
                                "items": {
                                  "type": "string"
                                }
                              },
                              "primaryContactPartyId": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "primaryContactPartyName": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "responsiblePartyId": {
                                "type": "number"
                              },
                              "responsiblePartyName": {
                                "type": "string"
                              },
                              "agreementNumber": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "title": {
                                "type": "string"
                              },
                              "description": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "status": {
                                "type": "string",
                                "enum": [
                                  "ACTIVE",
                                  "EXPIRED",
                                  "TERMINATED"
                                ]
                              },
                              "startDateActive": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "endDateActive": {
                                "type": "string",
                                "format": "date-time"
                              },
                              "daysUntilExpiry": {
                                "type": "number"
                              }
                            },
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    },
                    "employees": {
                      "type": "object",
                      "properties": {
                        "count": {
                          "type": "number"
                        },
                        "list": {
                          "type": "array",
                          "items": {
                            "type": "object",
                            "properties": {
                              "partyId": {
                                "type": "number"
                              },
                              "partyName": {
                                "type": "string"
                              },
                              "partyNumber": {
                                "type": "string"
                              },
                              "personFirstName": {
                                "type": "string"
                              },
                              "personMiddleName": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "personLastName": {
                                "type": "string"
                              },
                              "email": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "phone": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "jobTitle": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "avatar": {
                                "type": [
                                  "string",
                                  "null"
                                ]
                              },
                              "appUserId": {
                                "type": [
                                  "number",
                                  "null"
                                ]
                              },
                              "systemUser": {
                                "type": "boolean"
                              },
                              "supplierManager": {
                                "type": "boolean"
                              },
                              "lastLoginDate": {
                                "anyOf": [
                                  {
                                    "type": "string",
                                    "format": "date-time"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              }
                            },
                            "required": [
                              "systemUser"
                            ],
                            "additionalProperties": false
                          }
                        }
                      },
                      "required": [
                        "count",
                        "list"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/suppliers/{supplierPartyId}/employees": {
      "get": {
        "tags": [
          "External suppliers"
        ],
        "summary": "List supplier employees",
        "operationId": "listSupplierEmployees",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:read"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "supplierPartyId",
            "in": "path",
            "required": true,
            "description": "Supplier party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "Search employee name or contact details.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "description": "Sort direction (ASC or DESC).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyId": {
                            "type": "number"
                          },
                          "partyName": {
                            "type": "string"
                          },
                          "partyNumber": {
                            "type": "string"
                          },
                          "personFirstName": {
                            "type": "string"
                          },
                          "personMiddleName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "personLastName": {
                            "type": "string"
                          },
                          "email": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "phone": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "jobTitle": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "avatar": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "appUserId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "systemUser": {
                            "type": "boolean"
                          },
                          "supplierManager": {
                            "type": "boolean"
                          },
                          "lastLoginDate": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "systemUser"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External suppliers"
        ],
        "summary": "Create supplier employee",
        "description": "Creates a supplier contact. Set systemUser=true to create application access and send a supplier-workspace invitation; supplier managers must be application users.",
        "operationId": "createSupplierEmployee",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:write"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "supplierPartyId",
            "in": "path",
            "required": true,
            "description": "Supplier party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "personFirstName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "personMiddleName": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "personLastName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "jobTitle": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "supplierManager": {
                    "type": "boolean"
                  },
                  "systemUser": {
                    "type": "boolean"
                  },
                  "countryCode": {
                    "type": "string",
                    "maxLength": 3
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "personFirstName",
                  "personLastName"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "personFirstName": "Janis",
                "personLastName": "Berzins",
                "email": "janis.berzins@example.com",
                "phone": "+37120000001",
                "jobTitle": "Service manager",
                "supplierManager": true,
                "countryCode": "LVA"
              }
            }
          }
        },
        "x-example": {
          "personFirstName": "Janis",
          "personLastName": "Berzins",
          "email": "janis.berzins@example.com",
          "phone": "+37120000001",
          "jobTitle": "Service manager",
          "supplierManager": true,
          "countryCode": "LVA"
        },
        "responses": {
          "201": {
            "description": "Supplier employee created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/suppliers/{supplierPartyId}/employees/{employeePartyId}": {
      "patch": {
        "tags": [
          "External suppliers"
        ],
        "summary": "Update supplier employee",
        "operationId": "updateSupplierEmployee",
        "security": [
          {
            "bearerApiKey": [
              "suppliers:write"
            ]
          },
          {
            "headerApiKey": [
              "suppliers:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "supplierPartyId",
            "in": "path",
            "required": true,
            "description": "Supplier party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "employeePartyId",
            "in": "path",
            "required": true,
            "description": "Employee party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "personFirstName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "personMiddleName": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "personLastName": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 100
                  },
                  "email": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "email"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "phone": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "jobTitle": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 100
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "supplierManager": {
                    "type": "boolean"
                  },
                  "systemUser": {
                    "type": "boolean"
                  },
                  "countryCode": {
                    "type": "string",
                    "maxLength": 3
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "replacementManagerPartyId": {
                    "type": "number"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "jobTitle": "Senior service manager",
                "supplierManager": true
              }
            }
          }
        },
        "x-example": {
          "jobTitle": "Senior service manager",
          "supplierManager": true
        },
        "responses": {
          "200": {
            "description": "Supplier employee updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/suppliers/{supplierPartyId}/agreements": {
      "get": {
        "tags": [
          "External agreements"
        ],
        "summary": "List agreements for supplier",
        "operationId": "listSupplierAgreements",
        "security": [
          {
            "bearerApiKey": [
              "agreements:read"
            ]
          },
          {
            "headerApiKey": [
              "agreements:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "supplierPartyId",
            "in": "path",
            "required": true,
            "description": "Supplier party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "Search agreement, supplier, client, site, equipment, or address.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by agreement status (ACTIVE, EXPIRED, or TERMINATED).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "expiryBucket",
            "in": "query",
            "required": false,
            "description": "Filter by expiry bucket (expired, 15, 30, or 60).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "clientPartyId",
            "in": "query",
            "required": false,
            "description": "Filter by client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "agreementId": {
                            "type": "number"
                          },
                          "scopeType": {
                            "type": "string",
                            "enum": [
                              "OWN_COMPANY",
                              "CLIENT",
                              "CLIENT_SITE",
                              "EQUIPMENT"
                            ]
                          },
                          "clientPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "clientPartyName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "clientSiteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "clientSiteName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "address": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "siteEquipmentId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "siteEquipmentName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "supplierPartyId": {
                            "type": "number"
                          },
                          "supplierPartyName": {
                            "type": "string"
                          },
                          "supplierPartyType": {
                            "type": "string",
                            "enum": [
                              "PERSON",
                              "ORGANIZATION",
                              "BUILDING",
                              "SUPPLIER"
                            ]
                          },
                          "supplierServiceTypes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "primaryContactPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "primaryContactPartyName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "responsiblePartyId": {
                            "type": "number"
                          },
                          "responsiblePartyName": {
                            "type": "string"
                          },
                          "agreementNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "ACTIVE",
                              "EXPIRED",
                              "TERMINATED"
                            ]
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "daysUntilExpiry": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/agreements": {
      "get": {
        "tags": [
          "External agreements"
        ],
        "summary": "List agreements",
        "operationId": "listAgreements",
        "security": [
          {
            "bearerApiKey": [
              "agreements:read"
            ]
          },
          {
            "headerApiKey": [
              "agreements:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "description": "Search agreement, supplier, client, site, equipment, or address.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by agreement status (ACTIVE, EXPIRED, or TERMINATED).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "expiryBucket",
            "in": "query",
            "required": false,
            "description": "Filter by expiry bucket (expired, 15, 30, or 60).",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "supplierPartyId",
            "in": "query",
            "required": false,
            "description": "Filter by supplier party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "clientPartyId",
            "in": "query",
            "required": false,
            "description": "Filter by client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "agreementId": {
                            "type": "number"
                          },
                          "scopeType": {
                            "type": "string",
                            "enum": [
                              "OWN_COMPANY",
                              "CLIENT",
                              "CLIENT_SITE",
                              "EQUIPMENT"
                            ]
                          },
                          "clientPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "clientPartyName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "clientSiteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "clientSiteName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "address": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "siteEquipmentId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "siteEquipmentName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "supplierPartyId": {
                            "type": "number"
                          },
                          "supplierPartyName": {
                            "type": "string"
                          },
                          "supplierPartyType": {
                            "type": "string",
                            "enum": [
                              "PERSON",
                              "ORGANIZATION",
                              "BUILDING",
                              "SUPPLIER"
                            ]
                          },
                          "supplierServiceTypes": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          },
                          "primaryContactPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "primaryContactPartyName": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "responsiblePartyId": {
                            "type": "number"
                          },
                          "responsiblePartyName": {
                            "type": "string"
                          },
                          "agreementNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "description": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "ACTIVE",
                              "EXPIRED",
                              "TERMINATED"
                            ]
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "daysUntilExpiry": {
                            "type": "number"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External agreements"
        ],
        "summary": "Create agreement",
        "operationId": "createAgreement",
        "security": [
          {
            "bearerApiKey": [
              "agreements:write"
            ]
          },
          {
            "headerApiKey": [
              "agreements:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scopeType": {
                    "type": "string",
                    "enum": [
                      "OWN_COMPANY",
                      "CLIENT",
                      "CLIENT_SITE",
                      "EQUIPMENT"
                    ]
                  },
                  "clientPartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "clientSiteId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "siteEquipmentId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "supplierPartyId": {
                    "type": "number"
                  },
                  "primaryContactPartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "responsiblePartyId": {
                    "type": "number"
                  },
                  "agreementNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 160
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "ACTIVE",
                      "EXPIRED",
                      "TERMINATED"
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "required": [
                  "scopeType",
                  "supplierPartyId",
                  "responsiblePartyId",
                  "title",
                  "startDateActive",
                  "endDateActive"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "scopeType": "CLIENT",
                "clientPartyId": 140,
                "supplierPartyId": 139,
                "primaryContactPartyId": 142,
                "responsiblePartyId": 71,
                "agreementNumber": "AGR-2026-001",
                "title": "Lift maintenance",
                "description": "Preventive maintenance and emergency call-outs.",
                "status": "ACTIVE",
                "startDateActive": "2026-09-20T00:00:00.000Z",
                "endDateActive": "2027-09-19T23:59:59.999Z"
              }
            }
          }
        },
        "x-example": {
          "scopeType": "CLIENT",
          "clientPartyId": 140,
          "supplierPartyId": 139,
          "primaryContactPartyId": 142,
          "responsiblePartyId": 71,
          "agreementNumber": "AGR-2026-001",
          "title": "Lift maintenance",
          "description": "Preventive maintenance and emergency call-outs.",
          "status": "ACTIVE",
          "startDateActive": "2026-09-20T00:00:00.000Z",
          "endDateActive": "2027-09-19T23:59:59.999Z"
        },
        "responses": {
          "201": {
            "description": "Agreement created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/agreements/stats": {
      "get": {
        "tags": [
          "External agreements"
        ],
        "summary": "Get agreement expiry statistics",
        "operationId": "getAgreementStats",
        "security": [
          {
            "bearerApiKey": [
              "agreements:read"
            ]
          },
          {
            "headerApiKey": [
              "agreements:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "expired": {
                      "type": "number"
                    },
                    "expiring15Days": {
                      "type": "number"
                    },
                    "expiring30Days": {
                      "type": "number"
                    },
                    "expiring60Days": {
                      "type": "number"
                    },
                    "active": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "expired",
                    "expiring15Days",
                    "expiring30Days",
                    "expiring60Days",
                    "active"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/agreements/{agreementId}": {
      "get": {
        "tags": [
          "External agreements"
        ],
        "summary": "Get agreement",
        "operationId": "getAgreement",
        "security": [
          {
            "bearerApiKey": [
              "agreements:read"
            ]
          },
          {
            "headerApiKey": [
              "agreements:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "required": true,
            "description": "Agreement id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "agreementId": {
                      "type": "number"
                    },
                    "scopeType": {
                      "type": "string",
                      "enum": [
                        "OWN_COMPANY",
                        "CLIENT",
                        "CLIENT_SITE",
                        "EQUIPMENT"
                      ]
                    },
                    "clientPartyId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "clientPartyName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "clientSiteId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "clientSiteName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "address": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "siteEquipmentId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "siteEquipmentName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "supplierPartyId": {
                      "type": "number"
                    },
                    "supplierPartyName": {
                      "type": "string"
                    },
                    "supplierPartyType": {
                      "type": "string",
                      "enum": [
                        "PERSON",
                        "ORGANIZATION",
                        "BUILDING",
                        "SUPPLIER"
                      ]
                    },
                    "supplierServiceTypes": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "primaryContactPartyId": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "primaryContactPartyName": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "responsiblePartyId": {
                      "type": "number"
                    },
                    "responsiblePartyName": {
                      "type": "string"
                    },
                    "agreementNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "title": {
                      "type": "string"
                    },
                    "description": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "ACTIVE",
                        "EXPIRED",
                        "TERMINATED"
                      ]
                    },
                    "startDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "endDateActive": {
                      "type": "string",
                      "format": "date-time"
                    },
                    "daysUntilExpiry": {
                      "type": "number"
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External agreements"
        ],
        "summary": "Update agreement",
        "operationId": "updateAgreement",
        "security": [
          {
            "bearerApiKey": [
              "agreements:write"
            ]
          },
          {
            "headerApiKey": [
              "agreements:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "required": true,
            "description": "Agreement id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scopeType": {
                    "type": "string",
                    "enum": [
                      "OWN_COMPANY",
                      "CLIENT",
                      "CLIENT_SITE",
                      "EQUIPMENT"
                    ]
                  },
                  "clientPartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "clientSiteId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "siteEquipmentId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "supplierPartyId": {
                    "type": "number"
                  },
                  "primaryContactPartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "responsiblePartyId": {
                    "type": "number"
                  },
                  "agreementNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 160
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 200
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "ACTIVE",
                      "EXPIRED",
                      "TERMINATED"
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              },
              "example": {
                "title": "Updated lift maintenance",
                "endDateActive": "2028-09-19T23:59:59.999Z"
              }
            }
          }
        },
        "x-example": {
          "title": "Updated lift maintenance",
          "endDateActive": "2028-09-19T23:59:59.999Z"
        },
        "responses": {
          "200": {
            "description": "Agreement updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External agreements"
        ],
        "summary": "Terminate agreement",
        "description": "Marks the agreement as TERMINATED; no agreement history is physically deleted.",
        "operationId": "terminateAgreement",
        "security": [
          {
            "bearerApiKey": [
              "agreements:write"
            ]
          },
          {
            "headerApiKey": [
              "agreements:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "required": true,
            "description": "Agreement id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Agreement terminated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/work-orders": {
      "get": {
        "tags": [
          "External work orders"
        ],
        "summary": "List CRM work orders",
        "operationId": "listWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:read"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "includeRecurringOccurrences",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "workOrderId": {
                            "type": "number"
                          },
                          "referenceNumber": {
                            "type": "string"
                          },
                          "locationAddress": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "clientSiteId": {
                            "type": "number"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "assignmentType": {
                            "type": "string",
                            "enum": [
                              "MAINTENANCE",
                              "CLIENT_REQUEST"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          },
                          "priorityColor": {
                            "type": "string"
                          },
                          "completed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "COMPLETED",
                              "CANCELLED"
                            ]
                          },
                          "totalHours": {
                            "type": "number"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "entrance": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "equipmentName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External work orders"
        ],
        "summary": "Create CRM work order",
        "operationId": "createWorkOrder",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:write"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scheduleId": {
                    "type": "number"
                  },
                  "scheduleEntryId": {
                    "type": "number"
                  },
                  "locationId": {
                    "type": "number"
                  },
                  "clientId": {
                    "type": "number"
                  },
                  "clientSiteId": {
                    "type": "number"
                  },
                  "clientSiteEquipmentId": {
                    "type": "number"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "ADHOC",
                      "REPORT",
                      "WORK_ORDER",
                      "CLIENT",
                      "LUNCH",
                      "DRIVING",
                      "ON_CALL"
                    ]
                  },
                  "actionType": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "summary": {
                    "type": "string"
                  },
                  "assignmentType": {
                    "type": "string",
                    "enum": [
                      "MAINTENANCE",
                      "CLIENT_REQUEST"
                    ]
                  },
                  "priority": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "anyTime": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Work order created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/work-orders/{workOrderId}": {
      "get": {
        "tags": [
          "External work orders"
        ],
        "summary": "Get CRM work order",
        "operationId": "getWorkOrder",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:read"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External work orders"
        ],
        "summary": "Update CRM work order",
        "operationId": "updateWorkOrder",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:write"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "scheduleId": {
                    "type": "number"
                  },
                  "scheduleEntryId": {
                    "type": "number"
                  },
                  "locationId": {
                    "type": "number"
                  },
                  "clientId": {
                    "type": "number"
                  },
                  "clientSiteId": {
                    "type": "number"
                  },
                  "clientSiteEquipmentId": {
                    "type": "number"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "ADHOC",
                      "REPORT",
                      "WORK_ORDER",
                      "CLIENT",
                      "LUNCH",
                      "DRIVING",
                      "ON_CALL"
                    ]
                  },
                  "actionType": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "summary": {
                    "type": "string"
                  },
                  "assignmentType": {
                    "type": "string",
                    "enum": [
                      "MAINTENANCE",
                      "CLIENT_REQUEST"
                    ]
                  },
                  "priority": {
                    "anyOf": [
                      {
                        "anyOf": [
                          {
                            "not": {}
                          },
                          {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          }
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "anyTime": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Work order updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/clients/{clientId}/work-orders": {
      "get": {
        "tags": [
          "External work orders"
        ],
        "summary": "List CRM client work orders",
        "operationId": "listClientWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:read"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "workOrderId": {
                            "type": "number"
                          },
                          "referenceNumber": {
                            "type": "string"
                          },
                          "locationAddress": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "clientSiteId": {
                            "type": "number"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "assignmentType": {
                            "type": "string",
                            "enum": [
                              "MAINTENANCE",
                              "CLIENT_REQUEST"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          },
                          "priorityColor": {
                            "type": "string"
                          },
                          "completed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "COMPLETED",
                              "CANCELLED"
                            ]
                          },
                          "totalHours": {
                            "type": "number"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "entrance": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "equipmentName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/sites/{siteId}/work-orders": {
      "get": {
        "tags": [
          "External work orders"
        ],
        "summary": "List CRM site work orders",
        "operationId": "listSiteWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "work-orders:read"
            ]
          },
          {
            "headerApiKey": [
              "work-orders:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "workOrderId": {
                            "type": "number"
                          },
                          "referenceNumber": {
                            "type": "string"
                          },
                          "locationAddress": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "clientSiteId": {
                            "type": "number"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "assignmentType": {
                            "type": "string",
                            "enum": [
                              "MAINTENANCE",
                              "CLIENT_REQUEST"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          },
                          "priorityColor": {
                            "type": "string"
                          },
                          "completed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "COMPLETED",
                              "CANCELLED"
                            ]
                          },
                          "totalHours": {
                            "type": "number"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "entrance": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "equipmentName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/work-orders/{workOrderId}/statistics": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Get work order statistics",
        "operationId": "getWorkOrderStatistics",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalHours": {
                      "type": "number"
                    },
                    "totalPersonHours": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyName": {
                            "type": "string"
                          },
                          "partyId": {
                            "type": "number"
                          },
                          "hours": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "hours": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "totalTypeHours": {
                      "$ref": "#/properties/totalPersonHours/items/properties/hours"
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/clients/{clientId}/work-orders/statistics": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Get client work order statistics",
        "operationId": "getClientWorkOrderStatistics",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "assignmentType",
            "in": "query",
            "required": false,
            "description": "Filter by work order assignment type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalHours": {
                      "type": "number"
                    },
                    "totalPersonHours": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyName": {
                            "type": "string"
                          },
                          "partyId": {
                            "type": "number"
                          },
                          "hours": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "hours": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "totalTypeHours": {
                      "$ref": "#/properties/totalPersonHours/items/properties/hours"
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/sites/{siteId}/work-orders/statistics": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Get site work order statistics",
        "operationId": "getSiteWorkOrderStatistics",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "assignmentType",
            "in": "query",
            "required": false,
            "description": "Filter by work order assignment type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalHours": {
                      "type": "number"
                    },
                    "totalPersonHours": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyName": {
                            "type": "string"
                          },
                          "partyId": {
                            "type": "number"
                          },
                          "hours": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "hours": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "totalTypeHours": {
                      "$ref": "#/properties/totalPersonHours/items/properties/hours"
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/clients/{clientId}/sites/{siteId}/work-orders/statistics": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Get client-site work order statistics",
        "operationId": "getClientSiteWorkOrderStatistics",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "assignmentType",
            "in": "query",
            "required": false,
            "description": "Filter by work order assignment type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "totalHours": {
                      "type": "number"
                    },
                    "totalPersonHours": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "partyName": {
                            "type": "string"
                          },
                          "partyId": {
                            "type": "number"
                          },
                          "hours": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string"
                                },
                                "hours": {
                                  "type": "number"
                                }
                              },
                              "additionalProperties": false
                            }
                          }
                        },
                        "additionalProperties": false
                      }
                    },
                    "totalTypeHours": {
                      "$ref": "#/properties/totalPersonHours/items/properties/hours"
                    }
                  },
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/work-orders/{workOrderId}/report/pdf": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Download work order PDF report",
        "operationId": "downloadWorkOrderPdfReport",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/work-orders/{workOrderId}/report/excel": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Download work order Excel report",
        "operationId": "downloadWorkOrderExcelReport",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/work-orders/{workOrderId}/report/csv": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Download work order CSV report",
        "operationId": "downloadWorkOrderCsvReport",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/clients/{clientId}/work-orders/statistics/report/pdf": {
      "get": {
        "tags": [
          "External work order reporting"
        ],
        "summary": "Download client work order statistics PDF report",
        "operationId": "downloadClientWorkOrderStatisticsPdfReport",
        "security": [
          {
            "bearerApiKey": [
              "work-order-reports:read"
            ]
          },
          {
            "headerApiKey": [
              "work-order-reports:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "assignmentType",
            "in": "query",
            "required": false,
            "description": "Filter by work order assignment type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/meter-readings": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List apartment meter readings",
        "operationId": "listBuildingMeterReadings",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteEquipmentId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "readingType": {
                            "type": "string",
                            "default": "METER"
                          },
                          "readingValue": {
                            "type": "number",
                            "minimum": 0
                          },
                          "readingDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "source": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "REPORTED",
                              "CONFIRMED",
                              "REJECTED",
                              "SYNCED"
                            ]
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "comments": {
                            "type": "string"
                          },
                          "reportedByPartyId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reportingPeriodStart": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reportingPeriodEnd": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "submissionDueDate": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "providerReporterReference": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 150
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "correctsMeterReadingId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meterReadingId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "validationStatus": {
                            "type": "string",
                            "enum": [
                              "PASS",
                              "REQUIRES_APPROVAL",
                              "APPROVED",
                              "REJECTED"
                            ]
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "recordedByUserId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "version": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          }
                        },
                        "required": [
                          "siteEquipmentId",
                          "readingValue",
                          "meterReadingId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create apartment meter reading",
        "operationId": "createBuildingMeterReading",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteEquipmentId": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "readingType": {
                    "type": "string",
                    "default": "METER"
                  },
                  "readingValue": {
                    "type": "number",
                    "minimum": 0
                  },
                  "readingDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "source": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "REPORTED",
                      "CONFIRMED",
                      "REJECTED",
                      "SYNCED"
                    ]
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "reportedByPartyId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodStart": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodEnd": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "submissionDueDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "providerReporterReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "correctsMeterReadingId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "siteEquipmentId",
                  "readingValue"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Meter reading created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/meters": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List configured apartment meters",
        "description": "Returns eligible apartment meter definitions, units, precision, rollover, and verification validity.",
        "operationId": "listApartmentMeters",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "meterId": {
                            "type": "number"
                          },
                          "label": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "typeLabel": {
                            "type": "string"
                          },
                          "subtype": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "subtypeLabel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "serialNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "unit": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "unitLabel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "readingPrecision": {
                            "type": "number"
                          },
                          "rolloverValue": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "verificationValidFrom": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationValidUntil": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canSubmit": {
                            "type": "boolean"
                          },
                          "ineligibleReason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "validityStatus": {
                            "type": "string",
                            "enum": [
                              "VALID",
                              "EXPIRED",
                              "INELIGIBLE"
                            ]
                          },
                          "active": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "meterId",
                          "label",
                          "type",
                          "typeLabel",
                          "subtype",
                          "subtypeLabel",
                          "serialNumber",
                          "unit",
                          "unitLabel",
                          "readingPrecision",
                          "rolloverValue",
                          "verificationValidFrom",
                          "verificationValidUntil",
                          "canSubmit",
                          "ineligibleReason",
                          "validityStatus",
                          "active"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create an apartment meter",
        "description": "Creates a validated meter definition for one apartment.",
        "operationId": "createApartmentMeter",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "subtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "active": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "label",
                  "type",
                  "unit"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Apartment meter created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/meters/{meterId}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update an apartment meter",
        "description": "Updates the meter classification, unit, precision, rollover, verification period, or active state.",
        "operationId": "updateApartmentMeter",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "meterId",
            "in": "path",
            "required": true,
            "description": "Meter equipment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "subtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "active": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "label",
                  "type",
                  "unit"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/meter-readings/{id}/corrections": {
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Correct an apartment meter reading",
        "description": "Creates an immutable correction linked to the original reading; the original value is never overwritten.",
        "operationId": "correctApartmentMeterReading",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Original meter reading id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "readingValue": {
                    "type": "number",
                    "minimum": 0
                  },
                  "readingDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "reportedByPartyId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodStart": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodEnd": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "submissionDueDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "readingValue"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Correction created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/agreements": {
      "get": {
        "tags": [
          "External building ownership"
        ],
        "summary": "List apartment ownership and tenancy agreements",
        "description": "Returns scoped agreement participants, legal basis, validity, invoicing preferences, and provider identity metadata.",
        "operationId": "listApartmentAgreements",
        "security": [
          {
            "bearerApiKey": [
              "building-ownership:read"
            ]
          },
          {
            "headerApiKey": [
              "building-ownership:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by agreement status.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "apartmentAgreementId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "apartmentLegalInstrumentId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "buildingPartyId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "siteId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "agreementCode": {
                            "type": "string"
                          },
                          "validFrom": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "validTo": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "DRAFT",
                              "ACTIVE",
                              "EXPIRED",
                              "TERMINATED"
                            ]
                          },
                          "currencyCode": {
                            "type": "string"
                          },
                          "invoicingPreferences": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "currentRevisionNo": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "source": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "provider": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 50
                                  },
                                  "tenantKey": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100
                                  },
                                  "organizationKey": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100
                                  },
                                  "resourceCode": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 100
                                  },
                                  "externalId": {
                                    "type": "string",
                                    "minLength": 1,
                                    "maxLength": 200
                                  },
                                  "externalCode": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 200
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "version": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 150
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  },
                                  "counter": {
                                    "anyOf": [
                                      {
                                        "type": "string",
                                        "pattern": "^\\d+$",
                                        "maxLength": 19
                                      },
                                      {
                                        "type": "null"
                                      }
                                    ]
                                  }
                                },
                                "required": [
                                  "provider",
                                  "tenantKey",
                                  "organizationKey",
                                  "resourceCode",
                                  "externalId"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "legalInstrument": {
                            "anyOf": [
                              {
                                "type": "object",
                                "properties": {
                                  "type": {
                                    "type": "string"
                                  },
                                  "title": {
                                    "type": "string"
                                  },
                                  "documentNumber": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "issuer": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "issuedDate": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "signedDate": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "validFrom": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "validTo": {
                                    "type": [
                                      "string",
                                      "null"
                                    ]
                                  },
                                  "status": {
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type",
                                  "title",
                                  "documentNumber",
                                  "issuer",
                                  "issuedDate",
                                  "signedDate",
                                  "validFrom",
                                  "validTo",
                                  "status"
                                ],
                                "additionalProperties": false
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "parties": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "partyId": {
                                  "type": "integer",
                                  "exclusiveMinimum": 0
                                },
                                "partyName": {
                                  "type": "string"
                                },
                                "role": {
                                  "type": "string"
                                },
                                "ownershipShare": {
                                  "type": [
                                    "number",
                                    "null"
                                  ]
                                },
                                "validFrom": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "validTo": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                },
                                "active": {
                                  "type": "boolean"
                                }
                              },
                              "required": [
                                "partyId",
                                "partyName",
                                "role",
                                "ownershipShare",
                                "validFrom",
                                "validTo",
                                "active"
                              ],
                              "additionalProperties": false
                            }
                          }
                        },
                        "required": [
                          "apartmentAgreementId",
                          "apartmentLegalInstrumentId",
                          "buildingPartyId",
                          "siteId",
                          "agreementCode",
                          "validFrom",
                          "validTo",
                          "status",
                          "currencyCode",
                          "invoicingPreferences",
                          "currentRevisionNo",
                          "source",
                          "legalInstrument",
                          "parties"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building ownership"
        ],
        "summary": "Create an apartment ownership or tenancy agreement",
        "description": "Creates a scoped agreement, optional legal basis, and owner/tenant/payer/representative participants. It does not create portal access.",
        "operationId": "createApartmentAgreement",
        "security": [
          {
            "bearerApiKey": [
              "building-ownership:write"
            ]
          },
          {
            "headerApiKey": [
              "building-ownership:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "agreementCode": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 150
                  },
                  "validFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "validTo": {
                    "anyOf": [
                      {
                        "$ref": "#/properties/validFrom/anyOf/0"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "DRAFT",
                      "ACTIVE",
                      "EXPIRED",
                      "TERMINATED"
                    ],
                    "default": "DRAFT"
                  },
                  "currencyCode": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$",
                    "default": "EUR"
                  },
                  "invoicingPreferences": {
                    "type": "object",
                    "additionalProperties": {}
                  },
                  "parties": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "partyId": {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "OWNER",
                            "TENANT",
                            "PAYER",
                            "REPRESENTATIVE"
                          ]
                        },
                        "ownershipShare": {
                          "anyOf": [
                            {
                              "type": "number",
                              "exclusiveMinimum": 0,
                              "maximum": 1
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "validFrom": {
                          "anyOf": [
                            {
                              "$ref": "#/properties/validFrom/anyOf/0"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "validTo": {
                          "anyOf": [
                            {
                              "$ref": "#/properties/validFrom/anyOf/0"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "active": {
                          "type": "boolean",
                          "default": true
                        }
                      },
                      "required": [
                        "partyId",
                        "role"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1,
                    "maxItems": 20
                  },
                  "legalInstrument": {
                    "type": "object",
                    "properties": {
                      "type": {
                        "type": "string",
                        "enum": [
                          "PURCHASE_DEED",
                          "LEASE",
                          "MANAGEMENT_AGREEMENT",
                          "MUNICIPAL_DECISION",
                          "COURT_DECISION",
                          "OTHER"
                        ]
                      },
                      "title": {
                        "type": "string",
                        "minLength": 1,
                        "maxLength": 255
                      },
                      "documentNumber": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 150
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "issuer": {
                        "anyOf": [
                          {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 255
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "issuedDate": {
                        "anyOf": [
                          {
                            "$ref": "#/properties/validFrom/anyOf/0"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "signedDate": {
                        "anyOf": [
                          {
                            "$ref": "#/properties/validFrom/anyOf/0"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "validFrom": {
                        "anyOf": [
                          {
                            "$ref": "#/properties/validFrom/anyOf/0"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "validTo": {
                        "anyOf": [
                          {
                            "$ref": "#/properties/validFrom/anyOf/0"
                          },
                          {
                            "type": "null"
                          }
                        ]
                      },
                      "status": {
                        "type": "string",
                        "enum": [
                          "DRAFT",
                          "ACTIVE",
                          "EXPIRED",
                          "TERMINATED"
                        ],
                        "default": "DRAFT"
                      },
                      "safeMetadata": {
                        "type": "object",
                        "additionalProperties": {}
                      },
                      "source": {
                        "type": "object",
                        "properties": {
                          "provider": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 50
                          },
                          "tenantKey": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "organizationKey": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "resourceCode": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 100
                          },
                          "externalId": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 200
                          },
                          "externalCode": {
                            "anyOf": [
                              {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 200
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "version": {
                            "anyOf": [
                              {
                                "type": "string",
                                "minLength": 1,
                                "maxLength": 150
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "counter": {
                            "anyOf": [
                              {
                                "type": "string",
                                "pattern": "^\\d+$",
                                "maxLength": 19
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "provider",
                          "tenantKey",
                          "organizationKey",
                          "resourceCode",
                          "externalId"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "required": [
                      "type",
                      "title"
                    ],
                    "additionalProperties": false
                  },
                  "source": {
                    "$ref": "#/properties/legalInstrument/properties/source"
                  }
                },
                "required": [
                  "agreementCode",
                  "parties"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Apartment agreement created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/apartment-agreements/{agreementId}": {
      "patch": {
        "tags": [
          "External building ownership"
        ],
        "summary": "Update an apartment agreement",
        "description": "Updates validity, status, currency, or invoicing preferences and increments the agreement revision.",
        "operationId": "updateApartmentAgreement",
        "security": [
          {
            "bearerApiKey": [
              "building-ownership:write"
            ]
          },
          {
            "headerApiKey": [
              "building-ownership:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "agreementId",
            "in": "path",
            "required": true,
            "description": "Apartment agreement id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "validFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "validTo": {
                    "anyOf": [
                      {
                        "$ref": "#/properties/validFrom/anyOf/0"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "DRAFT",
                      "ACTIVE",
                      "EXPIRED",
                      "TERMINATED"
                    ]
                  },
                  "currencyCode": {
                    "type": "string",
                    "pattern": "^[A-Z]{3}$"
                  },
                  "invoicingPreferences": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/financial-documents": {
      "get": {
        "tags": [
          "External building finance"
        ],
        "summary": "List canonical apartment bills",
        "description": "Returns canonical apartment invoices, debit notes, credit notes, and statements after reconciliation.",
        "operationId": "listApartmentFinancialDocuments",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:read"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "payerPartyId": {
                            "type": "number"
                          },
                          "documentType": {
                            "type": "string",
                            "enum": [
                              "INVOICE",
                              "DEBT"
                            ]
                          },
                          "documentKind": {
                            "type": "string",
                            "enum": [
                              "INVOICE",
                              "CREDIT_NOTE",
                              "DEBIT_NOTE",
                              "ACCOUNT_STATEMENT"
                            ]
                          },
                          "documentState": {
                            "type": "string",
                            "enum": [
                              "DRAFT",
                              "ISSUED",
                              "CANCELLED",
                              "SUPERSEDED"
                            ]
                          },
                          "documentNumber": {
                            "type": "string"
                          },
                          "periodStart": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "periodEnd": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "issueDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "dueDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "currencyCode": {
                            "type": "string",
                            "default": "EUR"
                          },
                          "amount": {
                            "type": "number",
                            "default": 0
                          },
                          "paidAmount": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "PARTIAL",
                              "PAID",
                              "OVERDUE",
                              "CANCELLED"
                            ]
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "locale": {
                            "type": "string",
                            "minLength": 2,
                            "maxLength": 10
                          },
                          "supersedesFinancialDocumentId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "financialDocumentId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "currentRevisionNo": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "documentType",
                          "financialDocumentId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/apartments/{siteId}/payments": {
      "get": {
        "tags": [
          "External building finance"
        ],
        "summary": "List canonical apartment payments",
        "description": "Returns payments explicitly scoped to the apartment and active organization.",
        "operationId": "listApartmentPayments",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:read"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "payerPartyId": {
                            "type": "number"
                          },
                          "financialDocumentId": {
                            "type": "number"
                          },
                          "paymentDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "currencyCode": {
                            "type": "string",
                            "default": "EUR"
                          },
                          "amount": {
                            "type": "number",
                            "default": 0
                          },
                          "status": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "buildingPaymentId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "buildingPaymentId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/financial-documents/{id}/details": {
      "get": {
        "tags": [
          "External building finance"
        ],
        "summary": "Get canonical bill details",
        "description": "Returns a scoped canonical bill with normalized positions and payment allocations. Raw provider payloads are excluded.",
        "operationId": "getCanonicalFinancialDocument",
        "security": [
          {
            "bearerApiKey": [
              "building-finance:read"
            ]
          },
          {
            "headerApiKey": [
              "building-finance:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Canonical financial document id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "financialDocumentId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "buildingPartyId": {
                      "type": "integer",
                      "exclusiveMinimum": 0
                    },
                    "siteId": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "payerPartyId": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "apartmentAgreementId": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "documentType": {
                      "type": "string"
                    },
                    "documentKind": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "documentState": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "documentNumber": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "periodStart": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "periodEnd": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "issueDate": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "dueDate": {
                      "anyOf": [
                        {
                          "type": "string",
                          "format": "date-time"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "currencyCode": {
                      "type": "string"
                    },
                    "amount": {
                      "type": "number"
                    },
                    "paidAmount": {
                      "type": "number"
                    },
                    "status": {
                      "type": "string"
                    },
                    "externalId": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "currentRevisionNo": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "supersedesFinancialDocumentId": {
                      "anyOf": [
                        {
                          "type": "integer",
                          "exclusiveMinimum": 0
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "lines": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "financialDocumentLineId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "lineNumber": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "itemCode": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "description": {
                            "type": "string"
                          },
                          "servicePeriodStart": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "servicePeriodEnd": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "quantity": {
                            "type": "number"
                          },
                          "unit": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "unitPrice": {
                            "type": "number"
                          },
                          "netAmount": {
                            "type": "number"
                          },
                          "taxRate": {
                            "type": "number"
                          },
                          "taxAmount": {
                            "type": "number"
                          },
                          "grossAmount": {
                            "type": "number"
                          },
                          "allocationMetadata": {
                            "type": "object",
                            "additionalProperties": {}
                          }
                        },
                        "required": [
                          "financialDocumentLineId",
                          "lineNumber",
                          "itemCode",
                          "description",
                          "servicePeriodStart",
                          "servicePeriodEnd",
                          "quantity",
                          "unit",
                          "unitPrice",
                          "netAmount",
                          "taxRate",
                          "taxAmount",
                          "grossAmount",
                          "allocationMetadata"
                        ],
                        "additionalProperties": false
                      }
                    },
                    "paymentAllocations": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "buildingPaymentAllocationId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "buildingPaymentId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "amount": {
                            "type": "number"
                          },
                          "currencyCode": {
                            "type": "string"
                          },
                          "allocationDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "status": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "buildingPaymentAllocationId",
                          "buildingPaymentId",
                          "amount",
                          "currencyCode",
                          "allocationDate",
                          "status"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "financialDocumentId",
                    "buildingPartyId",
                    "siteId",
                    "payerPartyId",
                    "apartmentAgreementId",
                    "documentType",
                    "documentKind",
                    "documentState",
                    "documentNumber",
                    "periodStart",
                    "periodEnd",
                    "issueDate",
                    "dueDate",
                    "currencyCode",
                    "amount",
                    "paidAmount",
                    "status",
                    "externalId",
                    "currentRevisionNo",
                    "supersedesFinancialDocumentId",
                    "lines",
                    "paymentAllocations"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/meters": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List communal building meters",
        "operationId": "listCommunalBuildingMeters",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "meterId": {
                            "type": "number"
                          },
                          "label": {
                            "type": "string"
                          },
                          "type": {
                            "type": "string"
                          },
                          "typeLabel": {
                            "type": "string"
                          },
                          "subtype": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "subtypeLabel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "serialNumber": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "unit": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "unitLabel": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "readingPrecision": {
                            "type": "number"
                          },
                          "rolloverValue": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "verificationValidFrom": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "verificationValidUntil": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "canSubmit": {
                            "type": "boolean"
                          },
                          "ineligibleReason": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "validityStatus": {
                            "type": "string",
                            "enum": [
                              "VALID",
                              "EXPIRED",
                              "INELIGIBLE"
                            ]
                          },
                          "active": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "meterId",
                          "label",
                          "type",
                          "typeLabel",
                          "subtype",
                          "subtypeLabel",
                          "serialNumber",
                          "unit",
                          "unitLabel",
                          "readingPrecision",
                          "rolloverValue",
                          "verificationValidFrom",
                          "verificationValidUntil",
                          "canSubmit",
                          "ineligibleReason",
                          "validityStatus",
                          "active"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create communal building meter",
        "operationId": "createCommunalBuildingMeter",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "subtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "active": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "label",
                  "type",
                  "unit"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Building meter created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/meters/{meterId}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update communal building meter",
        "operationId": "updateCommunalBuildingMeter",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "meterId",
            "in": "path",
            "required": true,
            "description": "Meter equipment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "type": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "subtype": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 30
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "serialNumber": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "unit": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "readingPrecision": {
                    "type": "integer",
                    "minimum": 0,
                    "maximum": 6,
                    "default": 3
                  },
                  "rolloverValue": {
                    "anyOf": [
                      {
                        "type": "number",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidFrom": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "verificationValidUntil": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "active": {
                    "type": "boolean",
                    "default": true
                  }
                },
                "required": [
                  "label",
                  "type",
                  "unit"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Building meter updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/meter-readings": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List communal building meter readings",
        "operationId": "listCommunalBuildingMeterReadings",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteEquipmentId": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "readingType": {
                            "type": "string",
                            "default": "METER"
                          },
                          "readingValue": {
                            "type": "number",
                            "minimum": 0
                          },
                          "readingDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "source": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "REPORTED",
                              "CONFIRMED",
                              "REJECTED",
                              "SYNCED"
                            ]
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "comments": {
                            "type": "string"
                          },
                          "reportedByPartyId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reportingPeriodStart": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "reportingPeriodEnd": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "submissionDueDate": {
                            "anyOf": [
                              {
                                "type": "string",
                                "format": "date-time"
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "providerReporterReference": {
                            "anyOf": [
                              {
                                "type": "string",
                                "maxLength": 150
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "correctsMeterReadingId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "meterReadingId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "validationStatus": {
                            "type": "string",
                            "enum": [
                              "PASS",
                              "REQUIRES_APPROVAL",
                              "APPROVED",
                              "REJECTED"
                            ]
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "recordedByUserId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "version": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          }
                        },
                        "required": [
                          "siteEquipmentId",
                          "readingValue",
                          "meterReadingId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create communal building meter reading",
        "operationId": "createCommunalBuildingMeterReading",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteEquipmentId": {
                    "type": "integer",
                    "exclusiveMinimum": 0
                  },
                  "readingType": {
                    "type": "string",
                    "default": "METER"
                  },
                  "readingValue": {
                    "type": "number",
                    "minimum": 0
                  },
                  "readingDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "source": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "REPORTED",
                      "CONFIRMED",
                      "REJECTED",
                      "SYNCED"
                    ]
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "reportedByPartyId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodStart": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "reportingPeriodEnd": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "submissionDueDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "providerReporterReference": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 150
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "correctsMeterReadingId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "siteEquipmentId",
                  "readingValue"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Building meter reading created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{clientId}/apartments/{siteId}/persons": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List apartment owners, tenants, payers, and contacts",
        "operationId": "listApartmentPersons",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "sitePartyRelationshipId": {
                            "type": "number"
                          },
                          "partyId": {
                            "type": "number"
                          },
                          "partyName": {
                            "type": "string"
                          },
                          "partyNumber": {
                            "type": "string"
                          },
                          "partyType": {
                            "type": "string",
                            "enum": [
                              "PERSON",
                              "ORGANIZATION",
                              "BUILDING",
                              "SUPPLIER"
                            ]
                          },
                          "type": {
                            "type": "string",
                            "enum": [
                              "OWNER",
                              "TENANT",
                              "PAYER",
                              "CONTACT_PERSON",
                              "DECLARED_PERSON"
                            ]
                          },
                          "maskedSsnNumber": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "primaryPerType": {
                            "type": "boolean"
                          },
                          "ownershipShare": {
                            "type": "number"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "sitePartyRelationshipId",
                          "partyId",
                          "partyName",
                          "partyNumber",
                          "partyType",
                          "type",
                          "active"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create apartment person relationship",
        "operationId": "createApartmentPerson",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partyId": {
                    "type": "number"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "OWNER",
                      "TENANT",
                      "PAYER",
                      "CONTACT_PERSON",
                      "DECLARED_PERSON"
                    ]
                  },
                  "primaryPerType": {
                    "type": "boolean"
                  },
                  "ownershipShare": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "party": {
                    "type": "object",
                    "properties": {
                      "partyType": {
                        "type": "string",
                        "enum": [
                          "PERSON",
                          "ORGANIZATION"
                        ],
                        "default": "PERSON"
                      },
                      "ssnNumber": {
                        "type": "string"
                      },
                      "person": {
                        "type": "object",
                        "properties": {
                          "personFirstName": {
                            "type": "string"
                          },
                          "personMiddleName": {
                            "type": "string"
                          },
                          "personLastName": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "personFirstName",
                          "personLastName"
                        ],
                        "additionalProperties": false
                      },
                      "organization": {
                        "type": "object",
                        "properties": {
                          "organizationName": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "organizationName"
                        ],
                        "additionalProperties": false
                      },
                      "contactPoints": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "siteId": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "contactPointType": {
                              "type": "string",
                              "enum": [
                                "PHONE",
                                "EMAIL",
                                "HOME_PHONE",
                                "RELATIVE_PHONE",
                                "TELEGRAM",
                                "WHATSAPP",
                                "WEBSITE",
                                "SKYPE"
                              ]
                            },
                            "text": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "attachments": {
                              "type": "object",
                              "properties": {
                                "count": {
                                  "type": "number"
                                },
                                "list": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "attachmentId": {
                                        "type": "number"
                                      },
                                      "editable": {
                                        "type": "boolean"
                                      },
                                      "fileName": {
                                        "type": "string"
                                      },
                                      "fileType": {
                                        "type": "string"
                                      },
                                      "size": {
                                        "type": "number"
                                      },
                                      "description": {
                                        "type": "string"
                                      },
                                      "attribute1": {
                                        "type": "string"
                                      },
                                      "attribute2": {
                                        "type": "string"
                                      },
                                      "attribute3": {
                                        "type": "string"
                                      },
                                      "attribute4": {
                                        "type": "string"
                                      },
                                      "attribute5": {
                                        "type": "string"
                                      },
                                      "attribute6": {
                                        "type": "string"
                                      },
                                      "attribute7": {
                                        "type": "string"
                                      },
                                      "attribute8": {
                                        "type": "string"
                                      },
                                      "attribute9": {
                                        "type": "string"
                                      },
                                      "attribute10": {
                                        "type": "string"
                                      },
                                      "attribute11": {
                                        "type": "string"
                                      },
                                      "attribute12": {
                                        "type": "string"
                                      },
                                      "attribute13": {
                                        "type": "string"
                                      },
                                      "attribute14": {
                                        "type": "string"
                                      },
                                      "attribute15": {
                                        "type": "string"
                                      },
                                      "createDate": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "createdBy": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "count",
                                "list"
                              ],
                              "additionalProperties": false
                            },
                            "notes": {
                              "type": "object",
                              "properties": {
                                "count": {
                                  "type": "number"
                                },
                                "list": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "noteId": {
                                        "type": "number"
                                      },
                                      "note": {
                                        "type": "string"
                                      },
                                      "editable": {
                                        "type": "boolean"
                                      },
                                      "description": {
                                        "type": "string"
                                      },
                                      "attribute1": {
                                        "type": "string"
                                      },
                                      "attribute2": {
                                        "type": "string"
                                      },
                                      "attribute3": {
                                        "type": "string"
                                      },
                                      "attribute4": {
                                        "type": "string"
                                      },
                                      "attribute5": {
                                        "type": "string"
                                      },
                                      "attribute6": {
                                        "type": "string"
                                      },
                                      "attribute7": {
                                        "type": "string"
                                      },
                                      "attribute8": {
                                        "type": "string"
                                      },
                                      "attribute9": {
                                        "type": "string"
                                      },
                                      "attribute10": {
                                        "type": "string"
                                      },
                                      "attribute11": {
                                        "type": "string"
                                      },
                                      "attribute12": {
                                        "type": "string"
                                      },
                                      "attribute13": {
                                        "type": "string"
                                      },
                                      "attribute14": {
                                        "type": "string"
                                      },
                                      "attribute15": {
                                        "type": "string"
                                      },
                                      "createDate": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "createdBy": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "count",
                                "list"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "contactPointType",
                            "text"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "additionalProperties": false
                  }
                },
                "required": [
                  "type"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Apartment person relationship created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{clientId}/apartments/{siteId}/persons/{relationshipId}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update apartment person relationship",
        "operationId": "updateApartmentPerson",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "relationshipId",
            "in": "path",
            "required": true,
            "description": "Site-party relationship id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partyId": {
                    "type": "number"
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "OWNER",
                      "TENANT",
                      "PAYER",
                      "CONTACT_PERSON",
                      "DECLARED_PERSON"
                    ]
                  },
                  "primaryPerType": {
                    "type": "boolean"
                  },
                  "ownershipShare": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "party": {
                    "type": "object",
                    "properties": {
                      "partyType": {
                        "type": "string",
                        "enum": [
                          "PERSON",
                          "ORGANIZATION"
                        ],
                        "default": "PERSON"
                      },
                      "ssnNumber": {
                        "type": "string"
                      },
                      "person": {
                        "type": "object",
                        "properties": {
                          "personFirstName": {
                            "type": "string"
                          },
                          "personMiddleName": {
                            "type": "string"
                          },
                          "personLastName": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "personFirstName",
                          "personLastName"
                        ],
                        "additionalProperties": false
                      },
                      "organization": {
                        "type": "object",
                        "properties": {
                          "organizationName": {
                            "type": "string"
                          },
                          "attribute1": {
                            "type": "string"
                          },
                          "attribute2": {
                            "type": "string"
                          },
                          "attribute3": {
                            "type": "string"
                          },
                          "attribute4": {
                            "type": "string"
                          },
                          "attribute5": {
                            "type": "string"
                          },
                          "attribute6": {
                            "type": "string"
                          },
                          "attribute7": {
                            "type": "string"
                          },
                          "attribute8": {
                            "type": "string"
                          },
                          "attribute9": {
                            "type": "string"
                          },
                          "attribute10": {
                            "type": "string"
                          },
                          "attribute11": {
                            "type": "string"
                          },
                          "attribute12": {
                            "type": "string"
                          },
                          "attribute13": {
                            "type": "string"
                          },
                          "attribute14": {
                            "type": "string"
                          },
                          "attribute15": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "organizationName"
                        ],
                        "additionalProperties": false
                      },
                      "contactPoints": {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "properties": {
                            "siteId": {
                              "type": [
                                "number",
                                "null"
                              ]
                            },
                            "contactPointType": {
                              "type": "string",
                              "enum": [
                                "PHONE",
                                "EMAIL",
                                "HOME_PHONE",
                                "RELATIVE_PHONE",
                                "TELEGRAM",
                                "WHATSAPP",
                                "WEBSITE",
                                "SKYPE"
                              ]
                            },
                            "text": {
                              "type": "string"
                            },
                            "description": {
                              "type": "string"
                            },
                            "attribute1": {
                              "type": "string"
                            },
                            "attribute2": {
                              "type": "string"
                            },
                            "attribute3": {
                              "type": "string"
                            },
                            "attribute4": {
                              "type": "string"
                            },
                            "attribute5": {
                              "type": "string"
                            },
                            "attribute6": {
                              "type": "string"
                            },
                            "attribute7": {
                              "type": "string"
                            },
                            "attribute8": {
                              "type": "string"
                            },
                            "attribute9": {
                              "type": "string"
                            },
                            "attribute10": {
                              "type": "string"
                            },
                            "attribute11": {
                              "type": "string"
                            },
                            "attribute12": {
                              "type": "string"
                            },
                            "attribute13": {
                              "type": "string"
                            },
                            "attribute14": {
                              "type": "string"
                            },
                            "attribute15": {
                              "type": "string"
                            },
                            "attachments": {
                              "type": "object",
                              "properties": {
                                "count": {
                                  "type": "number"
                                },
                                "list": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "attachmentId": {
                                        "type": "number"
                                      },
                                      "editable": {
                                        "type": "boolean"
                                      },
                                      "fileName": {
                                        "type": "string"
                                      },
                                      "fileType": {
                                        "type": "string"
                                      },
                                      "size": {
                                        "type": "number"
                                      },
                                      "description": {
                                        "type": "string"
                                      },
                                      "attribute1": {
                                        "type": "string"
                                      },
                                      "attribute2": {
                                        "type": "string"
                                      },
                                      "attribute3": {
                                        "type": "string"
                                      },
                                      "attribute4": {
                                        "type": "string"
                                      },
                                      "attribute5": {
                                        "type": "string"
                                      },
                                      "attribute6": {
                                        "type": "string"
                                      },
                                      "attribute7": {
                                        "type": "string"
                                      },
                                      "attribute8": {
                                        "type": "string"
                                      },
                                      "attribute9": {
                                        "type": "string"
                                      },
                                      "attribute10": {
                                        "type": "string"
                                      },
                                      "attribute11": {
                                        "type": "string"
                                      },
                                      "attribute12": {
                                        "type": "string"
                                      },
                                      "attribute13": {
                                        "type": "string"
                                      },
                                      "attribute14": {
                                        "type": "string"
                                      },
                                      "attribute15": {
                                        "type": "string"
                                      },
                                      "createDate": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "createdBy": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "count",
                                "list"
                              ],
                              "additionalProperties": false
                            },
                            "notes": {
                              "type": "object",
                              "properties": {
                                "count": {
                                  "type": "number"
                                },
                                "list": {
                                  "type": "array",
                                  "items": {
                                    "type": "object",
                                    "properties": {
                                      "noteId": {
                                        "type": "number"
                                      },
                                      "note": {
                                        "type": "string"
                                      },
                                      "editable": {
                                        "type": "boolean"
                                      },
                                      "description": {
                                        "type": "string"
                                      },
                                      "attribute1": {
                                        "type": "string"
                                      },
                                      "attribute2": {
                                        "type": "string"
                                      },
                                      "attribute3": {
                                        "type": "string"
                                      },
                                      "attribute4": {
                                        "type": "string"
                                      },
                                      "attribute5": {
                                        "type": "string"
                                      },
                                      "attribute6": {
                                        "type": "string"
                                      },
                                      "attribute7": {
                                        "type": "string"
                                      },
                                      "attribute8": {
                                        "type": "string"
                                      },
                                      "attribute9": {
                                        "type": "string"
                                      },
                                      "attribute10": {
                                        "type": "string"
                                      },
                                      "attribute11": {
                                        "type": "string"
                                      },
                                      "attribute12": {
                                        "type": "string"
                                      },
                                      "attribute13": {
                                        "type": "string"
                                      },
                                      "attribute14": {
                                        "type": "string"
                                      },
                                      "attribute15": {
                                        "type": "string"
                                      },
                                      "createDate": {
                                        "type": "string",
                                        "format": "date-time"
                                      },
                                      "createdBy": {
                                        "type": "string"
                                      }
                                    },
                                    "additionalProperties": false
                                  }
                                }
                              },
                              "required": [
                                "count",
                                "list"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "contactPointType",
                            "text"
                          ],
                          "additionalProperties": false
                        }
                      }
                    },
                    "additionalProperties": false
                  },
                  "active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Apartment person relationship updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "End apartment person relationship",
        "operationId": "deleteApartmentPerson",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "path",
            "required": true,
            "description": "Apartment site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "relationshipId",
            "in": "path",
            "required": true,
            "description": "Site-party relationship id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Apartment person relationship deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/house-seniors": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List house senior assignments for building",
        "operationId": "listBuildingHouseSeniors",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "relationshipId": {
                            "type": "number"
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "houseSeniorPartyId": {
                            "type": "number"
                          },
                          "houseSeniorName": {
                            "type": "string"
                          },
                          "phone": {
                            "type": "string"
                          },
                          "email": {
                            "type": "string"
                          },
                          "active": {
                            "type": "boolean"
                          },
                          "comments": {
                            "type": "string"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "relationshipId",
                          "buildingPartyId",
                          "houseSeniorPartyId",
                          "houseSeniorName",
                          "active"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Assign house senior to building",
        "operationId": "createBuildingHouseSenior",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partyId": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "comments": {
                    "type": "string"
                  }
                },
                "required": [
                  "partyId"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "House senior assigned.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/house-seniors/{relationshipId}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update house senior assignment",
        "operationId": "updateBuildingHouseSenior",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "relationshipId",
            "in": "path",
            "required": true,
            "description": "Relationship id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "partyId": {
                    "type": "number"
                  },
                  "startDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "endDateActive": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "comments": {
                    "type": "string"
                  },
                  "active": {
                    "type": "boolean"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "House senior assignment updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "End house senior assignment",
        "operationId": "deleteBuildingHouseSenior",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "relationshipId",
            "in": "path",
            "required": true,
            "description": "Relationship id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "House senior assignment deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/meter-readings/{id}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update meter reading",
        "operationId": "updateBuildingMeterReading",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Meter reading id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "REPORTED",
                      "CONFIRMED",
                      "REJECTED",
                      "SYNCED"
                    ]
                  },
                  "comments": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 255
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Meter reading updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "Delete meter reading",
        "operationId": "deleteBuildingMeterReading",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Meter reading id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Meter reading deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/financial-documents": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List building financial documents",
        "operationId": "listBuildingFinancialDocuments",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "payerPartyId": {
                            "type": "number"
                          },
                          "documentType": {
                            "type": "string",
                            "enum": [
                              "INVOICE",
                              "DEBT"
                            ]
                          },
                          "documentKind": {
                            "type": "string",
                            "enum": [
                              "INVOICE",
                              "CREDIT_NOTE",
                              "DEBIT_NOTE",
                              "ACCOUNT_STATEMENT"
                            ]
                          },
                          "documentState": {
                            "type": "string",
                            "enum": [
                              "DRAFT",
                              "ISSUED",
                              "CANCELLED",
                              "SUPERSEDED"
                            ]
                          },
                          "documentNumber": {
                            "type": "string"
                          },
                          "periodStart": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "periodEnd": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "issueDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "dueDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "currencyCode": {
                            "type": "string",
                            "default": "EUR"
                          },
                          "amount": {
                            "type": "number",
                            "default": 0
                          },
                          "paidAmount": {
                            "type": "number"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "PARTIAL",
                              "PAID",
                              "OVERDUE",
                              "CANCELLED"
                            ]
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "locale": {
                            "type": "string",
                            "minLength": 2,
                            "maxLength": 10
                          },
                          "supersedesFinancialDocumentId": {
                            "anyOf": [
                              {
                                "type": "integer",
                                "exclusiveMinimum": 0
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "financialDocumentId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "currentRevisionNo": {
                            "type": "integer",
                            "minimum": 0
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "documentType",
                          "financialDocumentId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create building financial document",
        "operationId": "createBuildingFinancialDocument",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "payerPartyId": {
                    "type": "number"
                  },
                  "documentType": {
                    "type": "string",
                    "enum": [
                      "INVOICE",
                      "DEBT"
                    ]
                  },
                  "documentKind": {
                    "type": "string",
                    "enum": [
                      "INVOICE",
                      "CREDIT_NOTE",
                      "DEBIT_NOTE",
                      "ACCOUNT_STATEMENT"
                    ]
                  },
                  "documentState": {
                    "type": "string",
                    "enum": [
                      "DRAFT",
                      "ISSUED",
                      "CANCELLED",
                      "SUPERSEDED"
                    ]
                  },
                  "documentNumber": {
                    "type": "string"
                  },
                  "periodStart": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "periodEnd": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "issueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "currencyCode": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "amount": {
                    "type": "number",
                    "default": 0
                  },
                  "paidAmount": {
                    "type": "number"
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "OPEN",
                      "PARTIAL",
                      "PAID",
                      "OVERDUE",
                      "CANCELLED"
                    ]
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": {}
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 10
                  },
                  "supersedesFinancialDocumentId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "required": [
                  "documentType"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Financial document created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/financial-documents/{id}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update financial document",
        "operationId": "updateBuildingFinancialDocument",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Financial document id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "payerPartyId": {
                    "type": "number"
                  },
                  "documentType": {
                    "type": "string",
                    "enum": [
                      "INVOICE",
                      "DEBT"
                    ]
                  },
                  "documentKind": {
                    "type": "string",
                    "enum": [
                      "INVOICE",
                      "CREDIT_NOTE",
                      "DEBIT_NOTE",
                      "ACCOUNT_STATEMENT"
                    ]
                  },
                  "documentNumber": {
                    "type": "string"
                  },
                  "periodStart": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "periodEnd": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "issueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "currencyCode": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "amount": {
                    "type": "number",
                    "default": 0
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "OPEN",
                      "PARTIAL",
                      "PAID",
                      "OVERDUE",
                      "CANCELLED"
                    ]
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": {}
                  },
                  "locale": {
                    "type": "string",
                    "minLength": 2,
                    "maxLength": 10
                  },
                  "supersedesFinancialDocumentId": {
                    "anyOf": [
                      {
                        "type": "integer",
                        "exclusiveMinimum": 0
                      },
                      {
                        "type": "null"
                      }
                    ]
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Financial document updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "Delete financial document",
        "operationId": "deleteBuildingFinancialDocument",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Financial document id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Financial document deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/payments": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List building payments",
        "operationId": "listBuildingPayments",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "payerPartyId": {
                            "type": "number"
                          },
                          "financialDocumentId": {
                            "type": "number"
                          },
                          "paymentDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "currencyCode": {
                            "type": "string",
                            "default": "EUR"
                          },
                          "amount": {
                            "type": "number",
                            "default": 0
                          },
                          "status": {
                            "type": "string"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "payload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "buildingPaymentId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": [
                              "number",
                              "null"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "synchronized": {
                            "type": "boolean"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "buildingPaymentId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create building payment",
        "operationId": "createBuildingPayment",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "payerPartyId": {
                    "type": "number"
                  },
                  "financialDocumentId": {
                    "type": "number"
                  },
                  "paymentDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "currencyCode": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "amount": {
                    "type": "number",
                    "default": 0
                  },
                  "status": {
                    "type": "string"
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Payment created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/payments/{id}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update payment",
        "operationId": "updateBuildingPayment",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "payerPartyId": {
                    "type": "number"
                  },
                  "paymentDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "currencyCode": {
                    "type": "string",
                    "default": "EUR"
                  },
                  "amount": {
                    "type": "number",
                    "default": 0
                  },
                  "status": {
                    "type": "string"
                  },
                  "externalId": {
                    "type": "string"
                  },
                  "payload": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "Delete payment",
        "operationId": "deleteBuildingPayment",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Payment id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Payment deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/buildings/{buildingPartyId}/tasks": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List building CRM tasks",
        "operationId": "listBuildingTasks",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "siteId": {
                            "type": "number"
                          },
                          "assignedPartyId": {
                            "type": "number"
                          },
                          "source": {
                            "type": "string"
                          },
                          "taskType": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string"
                          },
                          "priority": {
                            "type": "string"
                          },
                          "title": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          },
                          "dueDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "externalId": {
                            "type": "string"
                          },
                          "buildingTaskId": {
                            "type": "number"
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "title",
                          "buildingTaskId",
                          "buildingPartyId"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create building CRM task",
        "operationId": "createBuildingTask",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "buildingPartyId",
            "in": "path",
            "required": true,
            "description": "Building party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "assignedPartyId": {
                    "type": "number"
                  },
                  "source": {
                    "type": "string"
                  },
                  "taskType": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "externalId": {
                    "type": "string"
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Task created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/tasks/{id}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update building CRM task",
        "operationId": "updateBuildingTask",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Task id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "siteId": {
                    "type": "number"
                  },
                  "assignedPartyId": {
                    "type": "number"
                  },
                  "source": {
                    "type": "string"
                  },
                  "taskType": {
                    "type": "string"
                  },
                  "status": {
                    "type": "string"
                  },
                  "priority": {
                    "type": "string"
                  },
                  "title": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "dueDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "externalId": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/notifications": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List building notifications",
        "operationId": "listBuildingNotifications",
        "security": [
          {
            "bearerApiKey": [
              "building-management:read"
            ]
          },
          {
            "headerApiKey": [
              "building-management:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "targetType": {
                            "type": "string",
                            "enum": [
                              "BUILDING",
                              "APARTMENT",
                              "STAIRCASE",
                              "FLOOR",
                              "STREET",
                              "DISTRICT"
                            ]
                          },
                          "buildingPartyId": {
                            "type": "number"
                          },
                          "siteId": {
                            "type": "number"
                          },
                          "staircase": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 50
                          },
                          "floor": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 30
                          },
                          "street": {
                            "type": "string"
                          },
                          "district": {
                            "type": "string"
                          },
                          "channels": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            },
                            "default": [
                              "EMAIL"
                            ]
                          },
                          "title": {
                            "type": "string"
                          },
                          "message": {
                            "type": "string"
                          },
                          "emergency": {
                            "type": "boolean",
                            "default": false
                          },
                          "status": {
                            "type": "string"
                          },
                          "buildingNotificationId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": "number"
                          },
                          "recipientCount": {
                            "type": "number"
                          },
                          "sentDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "createdDate": {
                            "type": "string",
                            "format": "date-time"
                          }
                        },
                        "required": [
                          "targetType",
                          "title",
                          "message",
                          "buildingNotificationId",
                          "organizationPartyId",
                          "recipientCount"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Create or queue building notification",
        "operationId": "createBuildingNotification",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "targetType": {
                    "type": "string",
                    "enum": [
                      "BUILDING",
                      "APARTMENT",
                      "STAIRCASE",
                      "FLOOR",
                      "STREET",
                      "DISTRICT"
                    ]
                  },
                  "buildingPartyId": {
                    "type": "number"
                  },
                  "siteId": {
                    "type": "number"
                  },
                  "staircase": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "floor": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "street": {
                    "type": "string"
                  },
                  "district": {
                    "type": "string"
                  },
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "default": [
                      "EMAIL"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "emergency": {
                    "type": "boolean",
                    "default": false
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "required": [
                  "targetType",
                  "title",
                  "message"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Notification created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/notifications/{id}": {
      "patch": {
        "tags": [
          "External building management"
        ],
        "summary": "Update or send draft building notification",
        "operationId": "updateBuildingNotification",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Building notification id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "targetType": {
                    "type": "string",
                    "enum": [
                      "BUILDING",
                      "APARTMENT",
                      "STAIRCASE",
                      "FLOOR",
                      "STREET",
                      "DISTRICT"
                    ]
                  },
                  "buildingPartyId": {
                    "type": "number"
                  },
                  "siteId": {
                    "type": "number"
                  },
                  "staircase": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 50
                  },
                  "floor": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 30
                  },
                  "street": {
                    "type": "string"
                  },
                  "district": {
                    "type": "string"
                  },
                  "channels": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    },
                    "default": [
                      "EMAIL"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  },
                  "emergency": {
                    "type": "boolean",
                    "default": false
                  },
                  "status": {
                    "type": "string"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Notification updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "delete": {
        "tags": [
          "External building management"
        ],
        "summary": "Delete draft building notification",
        "operationId": "deleteBuildingNotification",
        "security": [
          {
            "bearerApiKey": [
              "building-management:write"
            ]
          },
          {
            "headerApiKey": [
              "building-management:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Building notification id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Notification deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/building-management/sync-attempts": {
      "get": {
        "tags": [
          "External building management"
        ],
        "summary": "List building-management sync attempts",
        "operationId": "listBuildingSyncAttempts",
        "security": [
          {
            "bearerApiKey": [
              "building-management:sync"
            ]
          },
          {
            "headerApiKey": [
              "building-management:sync"
            ]
          }
        ],
        "parameters": [
          {
            "name": "objectType",
            "in": "query",
            "required": false,
            "description": "Filter by sync object type.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "objectId",
            "in": "query",
            "required": false,
            "description": "Filter by object id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by sync status.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "buildingSyncAttemptId": {
                            "type": "number"
                          },
                          "agentId": {
                            "type": "number"
                          },
                          "organizationPartyId": {
                            "type": "number"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "objectType": {
                            "type": "string",
                            "enum": [
                              "METER_READING",
                              "FINANCIAL_DOCUMENT",
                              "PAYMENT"
                            ]
                          },
                          "objectId": {
                            "type": "number"
                          },
                          "direction": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "PENDING",
                              "SUCCESS",
                              "FAILED",
                              "CONFIG_MISSING"
                            ]
                          },
                          "endpoint": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "not": {}
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "requestPayload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "responsePayload": {
                            "type": "object",
                            "additionalProperties": {}
                          },
                          "errorMessage": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "not": {}
                                  },
                                  {
                                    "type": "string"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          },
                          "startedDate": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "finishedDate": {
                            "anyOf": [
                              {
                                "anyOf": [
                                  {
                                    "not": {}
                                  },
                                  {
                                    "type": "string",
                                    "format": "date-time"
                                  }
                                ]
                              },
                              {
                                "type": "null"
                              }
                            ]
                          }
                        },
                        "required": [
                          "buildingSyncAttemptId",
                          "agentId",
                          "organizationPartyId",
                          "provider",
                          "objectType",
                          "objectId",
                          "direction",
                          "status"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count",
                    "list"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/building-management/sync/{objectType}/{id}": {
      "post": {
        "tags": [
          "External building management"
        ],
        "summary": "Synchronize one building-management object",
        "operationId": "syncBuildingManagementObject",
        "security": [
          {
            "bearerApiKey": [
              "building-management:sync"
            ]
          },
          {
            "headerApiKey": [
              "building-management:sync"
            ]
          }
        ],
        "parameters": [
          {
            "name": "objectType",
            "in": "path",
            "required": true,
            "description": "METER_READING, FINANCIAL_DOCUMENT, or PAYMENT.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Object id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sync attempted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    },
                    "externalId": {
                      "type": "string"
                    },
                    "error": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/buildings": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection buildings",
        "operationId": "listInspectionBuildings",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "q",
            "in": "query",
            "required": false,
            "description": "Search by building name, number, or reference.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/buildings/{clientId}/history": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List building inspection history",
        "operationId": "listBuildingInspectionHistory",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/buildings/{clientId}/work-orders": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection work orders for building",
        "operationId": "listBuildingInspectionWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "clientId",
            "in": "path",
            "required": true,
            "description": "Client party id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "workOrderId": {
                            "type": "number"
                          },
                          "referenceNumber": {
                            "type": "string"
                          },
                          "locationAddress": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "clientSiteId": {
                            "type": "number"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "assignmentType": {
                            "type": "string",
                            "enum": [
                              "MAINTENANCE",
                              "CLIENT_REQUEST"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          },
                          "priorityColor": {
                            "type": "string"
                          },
                          "completed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "COMPLETED",
                              "CANCELLED"
                            ]
                          },
                          "totalHours": {
                            "type": "number"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "entrance": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "equipmentName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/work-orders/{workOrderId}/details": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "Get section-scoped inspection details for a work order",
        "operationId": "getWorkOrderInspectionDetails",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "workOrderId",
            "in": "path",
            "required": true,
            "description": "Work order id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/act-templates": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection act templates",
        "operationId": "listInspectionActTemplates",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/acts": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection acts",
        "operationId": "listInspectionActs",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": false,
            "description": "Number of rows to skip.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": false,
            "description": "Maximum number of rows to return.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "clientPartyId",
            "in": "query",
            "required": false,
            "description": "Filter by client party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by inspection status.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "actType",
            "in": "query",
            "required": false,
            "description": "Filter by inspection act type.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External inspections"
        ],
        "summary": "Create inspection act",
        "operationId": "createInspectionAct",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "clientPartyId": {
                    "type": "number"
                  },
                  "actTemplateId": {
                    "type": "number"
                  },
                  "parentActId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "actType": {
                    "type": "string",
                    "enum": [
                      "VISUAL_INSPECTION",
                      "TECHNICAL_SPECIALIST",
                      "PROPERTY_MANAGER",
                      "DEFECT",
                      "EXTRAORDINARY",
                      "ACCEPTANCE_HANDOVER",
                      "OTHER"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "buildingType": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "cadastralIdentifier": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "region": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "inspectionDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "extraordinary": {
                    "type": "boolean"
                  },
                  "extraordinaryReasonCode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "representativePresent": {
                    "type": "boolean"
                  },
                  "representativePartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  },
                  "createConfiguredChildren": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "clientPartyId",
                  "actType",
                  "title"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inspection act created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/acts/{actId}": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "Get inspection act details",
        "operationId": "getInspectionAct",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      },
      "patch": {
        "tags": [
          "External inspections"
        ],
        "summary": "Update inspection act",
        "operationId": "updateInspectionAct",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "status": {
                    "type": "string",
                    "enum": [
                      "DRAFT",
                      "ASSIGNED",
                      "IN_PROGRESS",
                      "SUBMITTED",
                      "REVIEW",
                      "APPROVED",
                      "REGISTERED",
                      "CANCELLED"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "buildingType": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "cadastralIdentifier": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "region": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "inspectionDate": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "extraordinary": {
                    "type": "boolean"
                  },
                  "extraordinaryReasonCode": {
                    "anyOf": [
                      {
                        "type": "string",
                        "minLength": 1
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "representativePresent": {
                    "type": "boolean"
                  },
                  "representativePartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inspection act updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/values": {
      "put": {
        "tags": [
          "External inspections"
        ],
        "summary": "Replace inspection act values",
        "operationId": "putInspectionActValues",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workOrderId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "values": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "templateItemId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "templateFieldId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "value": {},
                        "expectedUpdatedDate": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "overrideReason": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "additionalProperties": false
                    }
                  }
                },
                "required": [
                  "values"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Inspection act values updated.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/evidence": {
      "post": {
        "tags": [
          "External inspections"
        ],
        "summary": "Add inspection evidence metadata",
        "operationId": "createInspectionEvidence",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workOrderId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "templateItemId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "templateFieldId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "attachmentId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "replacesEvidenceId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "evidenceType": {
                    "type": "string",
                    "enum": [
                      "PHOTO",
                      "DIAGRAM",
                      "SCREENSHOT",
                      "DOCUMENT"
                    ]
                  },
                  "capturedAt": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "gpsLatitude": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "gpsLongitude": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "buildingPartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "annotation": {
                    "type": "object",
                    "additionalProperties": {}
                  },
                  "metadata": {
                    "$ref": "#/properties/annotation"
                  }
                },
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Evidence created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/defects": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection defects",
        "operationId": "listInspectionDefects",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External inspections"
        ],
        "summary": "Create inspection defect",
        "operationId": "createInspectionDefect",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workOrderId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "templateItemId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "status": {
                    "type": "string",
                    "enum": [
                      "OPEN",
                      "IN_PLAN",
                      "IN_PROGRESS",
                      "RESOLVED",
                      "CANCELLED"
                    ]
                  },
                  "title": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 500
                  },
                  "description": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 5000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "severity": {
                    "type": "string",
                    "enum": [
                      "LOW",
                      "MEDIUM",
                      "HIGH",
                      "CRITICAL"
                    ]
                  },
                  "recommendedAction": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "targetDate": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "riskDescription": {
                    "anyOf": [
                      {
                        "type": "string",
                        "maxLength": 2000
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Defect created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/work-orders": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List work orders linked to inspection act",
        "operationId": "listInspectionActWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "count": {
                      "type": "number"
                    },
                    "list": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "workOrderId": {
                            "type": "number"
                          },
                          "referenceNumber": {
                            "type": "string"
                          },
                          "locationAddress": {
                            "type": "string"
                          },
                          "clientName": {
                            "type": "string"
                          },
                          "clientSiteId": {
                            "type": "number"
                          },
                          "title": {
                            "type": "string"
                          },
                          "summary": {
                            "type": "string"
                          },
                          "assignmentType": {
                            "type": "string",
                            "enum": [
                              "MAINTENANCE",
                              "CLIENT_REQUEST"
                            ]
                          },
                          "priority": {
                            "type": "string",
                            "enum": [
                              "CRITICAL",
                              "HIGH",
                              "MEDIUM",
                              "LOW"
                            ]
                          },
                          "priorityColor": {
                            "type": "string"
                          },
                          "completed": {
                            "type": "boolean"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "OPEN",
                              "COMPLETED",
                              "CANCELLED"
                            ]
                          },
                          "totalHours": {
                            "type": "number"
                          },
                          "startDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "endDateActive": {
                            "type": "string",
                            "format": "date-time"
                          },
                          "siteName": {
                            "type": "string"
                          },
                          "entrance": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "equipmentName": {
                            "type": "string"
                          }
                        },
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "count"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      },
      "post": {
        "tags": [
          "External inspections"
        ],
        "summary": "Create work order from inspection act",
        "operationId": "createInspectionWorkOrder",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write",
              "work-orders:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write",
              "work-orders:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotencyKey": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 200
                  },
                  "defectId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "templateSectionId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "templateItemId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "assigneePartyId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "clientSiteId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "clientSiteEquipmentId": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "title": {
                    "type": "string"
                  },
                  "summary": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "assignmentType": {
                    "type": "string",
                    "enum": [
                      "MAINTENANCE",
                      "CLIENT_REQUEST"
                    ]
                  },
                  "priority": {
                    "anyOf": [
                      {
                        "type": "string",
                        "enum": [
                          "CRITICAL",
                          "HIGH",
                          "MEDIUM",
                          "LOW"
                        ]
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "startDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "endDateActive": {
                    "anyOf": [
                      {
                        "type": "string",
                        "format": "date-time"
                      },
                      {
                        "type": "null"
                      }
                    ]
                  },
                  "anyTime": {
                    "type": "boolean"
                  },
                  "metadata": {
                    "type": "object",
                    "additionalProperties": {}
                  }
                },
                "required": [
                  "title"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inspection work order created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "status": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "additionalProperties": false,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/section-work-orders": {
      "post": {
        "tags": [
          "External inspections"
        ],
        "summary": "Create section work orders for one inspection act",
        "operationId": "createInspectionSectionWorkOrders",
        "security": [
          {
            "bearerApiKey": [
              "inspections:write",
              "work-orders:write"
            ]
          },
          {
            "headerApiKey": [
              "inspections:write",
              "work-orders:write"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "idempotencyKey": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 200
                  },
                  "sections": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "templateSectionId": {
                          "type": "number"
                        },
                        "assigneePartyId": {
                          "type": "number"
                        },
                        "assigneePartyIds": {
                          "type": "array",
                          "items": {
                            "type": "integer",
                            "exclusiveMinimum": 0
                          },
                          "minItems": 1,
                          "maxItems": 50
                        },
                        "clientSiteId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "clientSiteEquipmentId": {
                          "type": [
                            "number",
                            "null"
                          ]
                        },
                        "title": {
                          "type": "string"
                        },
                        "summary": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "assignmentType": {
                          "type": "string",
                          "enum": [
                            "MAINTENANCE",
                            "CLIENT_REQUEST"
                          ]
                        },
                        "priority": {
                          "anyOf": [
                            {
                              "type": "string",
                              "enum": [
                                "CRITICAL",
                                "HIGH",
                                "MEDIUM",
                                "LOW"
                              ]
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "startDateActive": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "endDateActive": {
                          "anyOf": [
                            {
                              "type": "string",
                              "format": "date-time"
                            },
                            {
                              "type": "null"
                            }
                          ]
                        },
                        "anyTime": {
                          "type": "boolean"
                        },
                        "metadata": {
                          "type": "object",
                          "additionalProperties": {}
                        },
                        "replaceExisting": {
                          "type": "boolean"
                        },
                        "competencyOverrideReason": {
                          "anyOf": [
                            {
                              "type": "string",
                              "minLength": 10,
                              "maxLength": 1000
                            },
                            {
                              "type": "null"
                            }
                          ]
                        }
                      },
                      "required": [
                        "templateSectionId"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1
                  }
                },
                "required": [
                  "sections"
                ],
                "additionalProperties": false,
                "$schema": "http://json-schema.org/draft-07/schema#"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Inspection section work orders created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          },
          "404": {
            "description": "Resource was not found."
          }
        }
      }
    },
    "/inspections/acts/{actId}/statistics": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "Get inspection act rollup statistics",
        "operationId": "getInspectionActStatistics",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/inspections/acts/{actId}/versions": {
      "get": {
        "tags": [
          "External inspections"
        ],
        "summary": "List inspection act versions",
        "operationId": "listInspectionActVersions",
        "security": [
          {
            "bearerApiKey": [
              "inspections:read"
            ]
          },
          {
            "headerApiKey": [
              "inspections:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "actId",
            "in": "path",
            "required": true,
            "description": "Inspection act id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {},
                  "additionalProperties": true,
                  "$schema": "http://json-schema.org/draft-07/schema#"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    },
    "/attachments": {
      "get": {
        "tags": [
          "External attachments"
        ],
        "summary": "List attachment metadata",
        "operationId": "listAttachments",
        "security": [
          {
            "bearerApiKey": [
              "attachments:read"
            ]
          },
          {
            "headerApiKey": [
              "attachments:read"
            ]
          }
        ],
        "parameters": [
          {
            "name": "skip",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "take",
            "in": "query",
            "required": true,
            "schema": {
              "type": "number"
            }
          },
          {
            "name": "sort",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "ASC",
                "DESC"
              ]
            }
          },
          {
            "name": "orderBy",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "filter",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateFrom",
            "in": "query",
            "required": false,
            "description": "Inclusive start date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "dateTo",
            "in": "query",
            "required": false,
            "description": "Inclusive end date/time filter. ISO 8601 string.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "employeeId",
            "in": "query",
            "required": false,
            "description": "Filter by employee party id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "siteId",
            "in": "query",
            "required": false,
            "description": "Filter by site id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "equipmentId",
            "in": "query",
            "required": false,
            "description": "Filter by equipment id.",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "status",
            "in": "query",
            "required": false,
            "description": "Filter by status code.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "objectType",
            "in": "query",
            "required": false,
            "description": "Filter by attached object type.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "objectId",
            "in": "query",
            "required": false,
            "description": "Filter by attached object id.",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success."
          },
          "400": {
            "description": "Invalid request."
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "403": {
            "description": "API key does not include the required scope."
          }
        }
      }
    }
  }
}
