{
  "openapi": "3.1.0",
  "info": {
    "title": "DealPipe Public API",
    "version": "1.0.0",
    "description": "Org-scoped REST API for external integrations. All endpoints require an `Authorization: Bearer dp_live_...` token issued in the dashboard under Settings → API tokens. Tokens carry a subset of RBAC permissions called *scopes*; the effective permission set is `scopes ∩ creator-current-permissions` resolved at request time."
  },
  "servers": [
    {
      "url": "https://app.deal-pipe.de/api/v1",
      "description": "Dealpipe"
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "dp_live_*"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "requestId"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "requestId": {
                "type": "string"
              },
              "details": {}
            }
          }
        }
      },
      "Folder": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "orgId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "parentId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "color": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 32
          },
          "visibility": {
            "type": "string",
            "enum": [
              "private",
              "org"
            ]
          },
          "createdByUserId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Project": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "orgId": {
            "type": "string",
            "format": "uuid"
          },
          "name": {
            "type": "string"
          },
          "street": {
            "type": [
              "string",
              "null"
            ]
          },
          "houseNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "country": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "PropertyImage": {
        "type": "object",
        "description": "Signed, temporary link into the private `property-images` bucket. URLs expire after 1 hour — re-read the property instead of persisting them.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "category": {
            "type": [
              "string",
              "null"
            ]
          },
          "fileName": {
            "type": [
              "string",
              "null"
            ]
          },
          "sortOrder": {
            "type": [
              "integer",
              "null"
            ]
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "thumbnailUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          }
        }
      },
      "Pagination": {
        "type": "object",
        "properties": {
          "limit": {
            "type": "integer",
            "description": "Effective page size after clamping."
          },
          "offset": {
            "type": "integer"
          },
          "total": {
            "type": "integer",
            "description": "Total matches for the filter, ignoring limit/offset."
          },
          "hasMore": {
            "type": "boolean"
          }
        }
      },
      "Property": {
        "type": "object",
        "description": "Monetary and area values are decimal strings (e.g. \"320000.00\") so no precision is lost in JSON. Fields absent from this schema are internal and are never returned.",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "projectId": {
            "type": "string",
            "format": "uuid"
          },
          "orgId": {
            "type": "string",
            "format": "uuid"
          },
          "externalSourceId": {
            "type": [
              "string",
              "null"
            ],
            "description": "Your own id, if the unit was created via this API."
          },
          "unitIdentifier": {
            "type": [
              "string",
              "null"
            ]
          },
          "unitNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "street": {
            "type": [
              "string",
              "null"
            ]
          },
          "houseNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "latitude": {
            "type": [
              "string",
              "null"
            ]
          },
          "longitude": {
            "type": [
              "string",
              "null"
            ]
          },
          "etage": {
            "type": [
              "integer",
              "null"
            ]
          },
          "zimmer": {
            "type": [
              "string",
              "null"
            ]
          },
          "wohnflaecheQm": {
            "type": [
              "string",
              "null"
            ]
          },
          "nutzflaecheQm": {
            "type": [
              "string",
              "null"
            ]
          },
          "baujahr": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "frei",
              "auf_anfrage",
              "reserviert",
              "notarvorbereitung",
              "notartermin",
              "verkauft"
            ]
          },
          "visibility": {
            "type": "string",
            "enum": [
              "online",
              "offline",
              "pending_review"
            ]
          },
          "archived": {
            "type": "boolean"
          },
          "archivedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "kaufpreis": {
            "type": [
              "string",
              "null"
            ]
          },
          "kaufpreisStellplatz": {
            "type": [
              "string",
              "null"
            ]
          },
          "kaltmieteWohnung": {
            "type": [
              "string",
              "null"
            ]
          },
          "kaltmieteStellplatz": {
            "type": [
              "string",
              "null"
            ]
          },
          "hausgeldGesamt": {
            "type": [
              "string",
              "null"
            ]
          },
          "hausgeldNichtUmlagefaehig": {
            "type": [
              "string",
              "null"
            ]
          },
          "kaufpreisPerQm": {
            "type": [
              "string",
              "null"
            ]
          },
          "kaltmietePerQm": {
            "type": [
              "string",
              "null"
            ]
          },
          "bruttorendite": {
            "type": [
              "string",
              "null"
            ]
          },
          "bauzustand": {
            "type": [
              "string",
              "null"
            ]
          },
          "anlageklasse": {
            "type": [
              "string",
              "null"
            ]
          },
          "mietstatus": {
            "type": [
              "string",
              "null"
            ]
          },
          "vermietetSeit": {
            "type": [
              "string",
              "null"
            ]
          },
          "energieeffizienzklasse": {
            "type": [
              "string",
              "null"
            ]
          },
          "energieausweistyp": {
            "type": [
              "string",
              "null"
            ]
          },
          "energieverbrauch": {
            "type": [
              "string",
              "null"
            ]
          },
          "heizungsart": {
            "type": [
              "string",
              "null"
            ]
          },
          "isDenkmal": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "isErbbaupacht": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "videoUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "virtualTourUrl": {
            "type": [
              "string",
              "null"
            ]
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "updatedAt": {
            "type": "string",
            "format": "date-time"
          },
          "images": {
            "type": "array",
            "description": "Only present when `include=images` was requested.",
            "items": {
              "$ref": "#/components/schemas/PropertyImage"
            }
          }
        }
      },
      "ImportRun": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "orgId": {
            "type": "string",
            "format": "uuid"
          },
          "projectId": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "type": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed",
              "canceled"
            ]
          },
          "unitCount": {
            "type": "integer"
          },
          "documentCount": {
            "type": "integer"
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "completedAt": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Unit": {
        "type": "object",
        "properties": {
          "unitIdentifier": {
            "type": [
              "string",
              "null"
            ]
          },
          "street": {
            "type": [
              "string",
              "null"
            ]
          },
          "houseNumber": {
            "type": [
              "string",
              "null"
            ]
          },
          "postalCode": {
            "type": [
              "string",
              "null"
            ]
          },
          "city": {
            "type": [
              "string",
              "null"
            ]
          },
          "unitNumber": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9]*$"
          },
          "zimmer": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "wohnflaecheQm": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "kaufpreis": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "kaltmieteWohnung": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "baujahr": {
            "type": [
              "integer",
              "null"
            ]
          },
          "unitLocation": {
            "type": [
              "string",
              "null"
            ]
          },
          "etageLabel": {
            "type": [
              "string",
              "null"
            ],
            "description": "Floor label, e.g. UG, EG, OG, DG or a numeric floor."
          },
          "etage": {
            "type": [
              "integer",
              "null"
            ]
          },
          "visibility": {
            "type": "string",
            "enum": [
              "online",
              "offline",
              "pending_review"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "frei",
              "auf_anfrage",
              "reserviert",
              "notarvorbereitung",
              "notartermin",
              "verkauft"
            ]
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/folders": {
      "get": {
        "summary": "List folders",
        "description": "Requires scope: files:read",
        "parameters": [
          {
            "name": "parentId",
            "in": "query",
            "schema": {
              "type": [
                "string",
                "null"
              ],
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "folders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Folder"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create folder",
        "description": "Requires scope: files:upload",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 255
                  },
                  "parentId": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "format": "uuid"
                  },
                  "color": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 32
                  },
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "private",
                      "org"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "folder": {
                      "$ref": "#/components/schemas/Folder"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects": {
      "get": {
        "summary": "List projects",
        "description": "Requires scope: project:read",
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "projects": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Project"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create project",
        "description": "Requires scope: project:create",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1
                  },
                  "street": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "houseNumber": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "postalCode": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "city": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "state": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "country": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "visibility": {
                    "type": "string",
                    "enum": [
                      "online",
                      "offline",
                      "pending_review"
                    ],
                    "deprecated": true,
                    "description": "Accepted but ignored. Set visibility on each property instead."
                  },
                  "apiDataSource": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "apiDataReception": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{id}": {
      "get": {
        "summary": "Get project",
        "description": "Requires scope: project:read. Pass `include=properties` to get the project's units in the same response — that additionally requires scope: property:read.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "Comma-separated. `properties` (aliases: `units`, `einheiten`) embeds the units; `images` additionally attaches signed image URLs and only works together with `properties`.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "properties",
                  "images"
                ]
              }
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size. Max 200, or 50 when `include=images` is set. The effective value is echoed in `pagination.limit`.",
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "frei",
                  "auf_anfrage",
                  "reserviert",
                  "notarvorbereitung",
                  "notartermin",
                  "verkauft"
                ]
              }
            }
          },
          {
            "name": "visibility",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "online",
                  "offline",
                  "pending_review"
                ]
              }
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "description": "ISO 8601 timestamp. Returns units changed at or after it — use this to sync incrementally.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "description": "Archived (sold/closed) units are excluded by default.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "project": {
                      "$ref": "#/components/schemas/Project"
                    },
                    "properties": {
                      "type": "array",
                      "description": "Only present when `include=properties` was requested.",
                      "items": {
                        "$ref": "#/components/schemas/Property"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/properties": {
      "get": {
        "summary": "List properties",
        "description": "Accessible units in your org, newest first. Requires scope: property:read",
        "parameters": [
          {
            "name": "projectId",
            "in": "query",
            "description": "Restrict to one project.",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size. Max 200, or 50 when `include=images` is set. The effective value is echoed in `pagination.limit`.",
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "frei",
                  "auf_anfrage",
                  "reserviert",
                  "notarvorbereitung",
                  "notartermin",
                  "verkauft"
                ]
              }
            }
          },
          {
            "name": "visibility",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "online",
                  "offline",
                  "pending_review"
                ]
              }
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "description": "ISO 8601 timestamp. Returns units changed at or after it — use this to sync incrementally.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "description": "Archived (sold/closed) units are excluded by default.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "Comma-separated. `images` attaches signed image URLs (1 hour TTL, max 30 per unit).",
            "schema": {
              "type": "string",
              "enum": [
                "images"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "properties": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Property"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/properties/{id}": {
      "get": {
        "summary": "Get property",
        "description": "Requires scope: property:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "Comma-separated. `images` attaches signed image URLs (1 hour TTL, max 30 per unit).",
            "schema": {
              "type": "string",
              "enum": [
                "images"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "property": {
                      "$ref": "#/components/schemas/Property"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{id}/properties": {
      "get": {
        "summary": "List a project's properties",
        "description": "Same as `GET /properties?projectId={id}`, but 404s when the project doesn't exist. Requires scope: property:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size. Max 200, or 50 when `include=images` is set. The effective value is echoed in `pagination.limit`.",
            "schema": {
              "type": "integer",
              "default": 50,
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "offset",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 0
            }
          },
          {
            "name": "status",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "frei",
                  "auf_anfrage",
                  "reserviert",
                  "notarvorbereitung",
                  "notartermin",
                  "verkauft"
                ]
              }
            }
          },
          {
            "name": "visibility",
            "in": "query",
            "description": "Repeatable or comma-separated.",
            "style": "form",
            "explode": false,
            "schema": {
              "type": "array",
              "items": {
                "type": "string",
                "enum": [
                  "online",
                  "offline",
                  "pending_review"
                ]
              }
            }
          },
          {
            "name": "updatedSince",
            "in": "query",
            "description": "ISO 8601 timestamp. Returns units changed at or after it — use this to sync incrementally.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "description": "Archived (sold/closed) units are excluded by default.",
            "schema": {
              "type": "boolean",
              "default": false
            }
          },
          {
            "name": "include",
            "in": "query",
            "description": "Comma-separated. `images` attaches signed image URLs (1 hour TTL, max 30 per unit).",
            "schema": {
              "type": "string",
              "enum": [
                "images"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "properties": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Property"
                      }
                    },
                    "pagination": {
                      "$ref": "#/components/schemas/Pagination"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create property",
        "description": "Requires scope: property:create",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Unit"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "property": {
                      "$ref": "#/components/schemas/Property"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/projects/{id}/imports": {
      "post": {
        "summary": "Bulk-import properties",
        "description": "Synchronously creates up to 200 properties under the project, enforcing per-org plan limits (monthly units, max-online). Requires scope: property:import",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "units"
                ],
                "properties": {
                  "units": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 200,
                    "items": {
                      "$ref": "#/components/schemas/Unit"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Accepted (synchronous in v1)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "importRunId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "status": {
                      "type": "string",
                      "enum": [
                        "completed"
                      ]
                    },
                    "unitCount": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/imports/{id}": {
      "get": {
        "summary": "Get import status",
        "description": "Requires scope: property:read",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "import": {
                      "$ref": "#/components/schemas/ImportRun"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "402": {
            "description": "Quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  }
}
