openapi: 3.1.0
info:
  title: Immobrille API
  version: "1.1"
  summary: Immobilien-Services von Immobrille für andere Anwendungen.
  description: |
    REST/JSON-API für Projekt-Websites, Video-Rundgänge, Virtual Staging, Visualisierungen, Vorher/Nachher-Vergleiche,
    Immobilienbewertungen, Leads sowie Marktplatz (Möbel/Materialien) und 3D-Rundgänge.

    **Authentifizierung:** `Authorization: Bearer sk_test_…` (Sandbox) oder `sk_live_…` (Live). Alternativ `X-API-Key`.
    Jeder Key hat Scopes (`sites`, `videos`, `staging`, `valuations`, `leads`, `marketplace`).

    **Mandanten:** Mit `X-Tenant-Ref` ordnen Sie Ressourcen einem Ihrer Kunden (z. B. Maklerbüro) zu. Ohne Header gilt Ihr Standard-Mandant.

    **Sandbox:** Sandbox-Keys liefern sofort Beispielergebnisse (keine Kosten), damit der ganze Ablauf inkl. Webhooks testbar ist.
  contact: { name: Immobrille, email: hello@immobrille.ch, url: https://www.immobrille.ch/developers }
servers:
  - url: https://www.immobrille.ch/api/v1
    description: Produktion (Sandbox oder Live bestimmt der Key)
security:
  - bearerAuth: []
tags:
  - { name: Konto, description: Key prüfen }
  - { name: Projekt-Websites, description: "Landingpages für Immobilienprojekte anlegen, füllen und veröffentlichen (Scope `sites`)" }
  - { name: Video-Rundgänge, description: "Walkthrough-Video aus Inserat-Link oder Fotos (Scope `videos`)" }
  - { name: Virtual Staging, description: "Leere Räume einrichten (Scope `staging`)" }
  - { name: Visualisierung, description: "Aus Plan, Skizze oder Foto eine Visualisierung (Scope `staging`)" }
  - { name: Vorher/Nachher, description: "Vergleich zweier Bilder als einbettbarer Schieberegler (Scope `staging`)" }
  - { name: Bewertung, description: "Indikative Immobilienbewertung (Scope `valuations`)" }
  - { name: Leads, description: "Anfragen aus Projektseiten und Funnels (Scope `leads`)" }
  - { name: Marktplatz & 3D, description: "Möbel/Materialien, 3D-Rundgänge, Einrichtungs-Anfragen (Scope `marketplace`)" }
  - { name: Webhooks, description: Ereignisse empfangen }

paths:
  /me:
    get:
      tags: [Konto]
      summary: Key prüfen
      operationId: getMe
      responses:
        "200":
          description: Partner, Umgebung, Scopes
          content:
            application/json:
              schema:
                type: object
                properties:
                  partner: { type: object, properties: { id: { type: string }, slug: { type: string }, name: { type: string } } }
                  environment: { type: string, enum: [sandbox, live] }
                  scopes: { type: array, items: { type: string } }
                  rateLimit: { type: object, properties: { limit: { type: integer, example: 120 }, window: { type: string, example: 1m } } }
        "401": { $ref: "#/components/responses/Unauthorized" }

  /sites:
    get:
      tags: [Projekt-Websites]
      summary: Projektseiten auflisten
      operationId: listSites
      parameters: [{ $ref: "#/components/parameters/Limit" }, { $ref: "#/components/parameters/Before" }, { $ref: "#/components/parameters/TenantRef" }]
      responses:
        "200": { description: Liste, content: { application/json: { schema: { $ref: "#/components/schemas/SiteList" } } } }
        "401": { $ref: "#/components/responses/Unauthorized" }
    post:
      tags: [Projekt-Websites]
      summary: Projektseite anlegen
      description: Startet mit der Immobrille-Vorlage; mitgegebene `content`-Felder überschreiben die Vorlage. Mit `publish:true` sofort online.
      operationId: createSite
      parameters: [{ $ref: "#/components/parameters/TenantRef" }, { $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/SiteCreate" }
            example:
              name: Wohnen am Bach
              slug: wohnen-am-bach
              publish: false
              content:
                layout: modern
                headline: Sechs Wohnungen am Dorfbach.
                eyebrow: Bachstrasse 4, 5600 Lenzburg
                heroImage: https://example.ch/bilder/hero.jpg
                intro: { title: Ruhig wohnen im Grünen, text: Sechs Eigentumswohnungen mit Garten oder Terrasse., cta: { label: Wohnungen ansehen, href: "#wohnungen" } }
                inquiry: { title: Interesse?, to: verkauf@makler.ch }
      responses:
        "201": { description: Angelegt, content: { application/json: { schema: { $ref: "#/components/schemas/Site" } } } }
        "422": { $ref: "#/components/responses/Invalid" }
  /sites/{id}:
    parameters: [{ name: id, in: path, required: true, schema: { type: string, format: uuid } }]
    get:
      tags: [Projekt-Websites]
      summary: Projektseite abrufen (inkl. Inhalt)
      operationId: getSite
      responses:
        "200": { description: Seite, content: { application/json: { schema: { $ref: "#/components/schemas/Site" } } } }
        "404": { $ref: "#/components/responses/NotFound" }
    patch:
      tags: [Projekt-Websites]
      summary: Projektseite ändern oder veröffentlichen
      description: "`content` wird mit dem bestehenden Inhalt zusammengeführt (oberste Ebene). `status: published` stellt die Seite online, `draft` nimmt sie offline."
      operationId: updateSite
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                name: { type: string }
                status: { type: string, enum: [draft, published] }
                content: { $ref: "#/components/schemas/SiteContent" }
      responses:
        "200": { description: Aktualisiert, content: { application/json: { schema: { $ref: "#/components/schemas/Site" } } } }
        "404": { $ref: "#/components/responses/NotFound" }
    delete:
      tags: [Projekt-Websites]
      summary: Projektseite löschen
      operationId: deleteSite
      responses:
        "200": { description: Gelöscht, content: { application/json: { schema: { $ref: "#/components/schemas/Deleted" } } } }

  /videos:
    post:
      tags: [Video-Rundgänge]
      summary: Video-Rundgang bestellen
      operationId: createVideo
      parameters: [{ $ref: "#/components/parameters/TenantRef" }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                reference: { type: string, description: Ihre eigene Referenz (z. B. Inserat-ID) }
                source:
                  type: object
                  properties:
                    listingUrl: { type: string, format: uri }
                    photos: { type: array, items: { type: string, format: uri } }
                template: { type: string, example: classic }
                callbackUrl: { type: string, format: uri }
            example: { reference: INS-4711, source: { photos: ["https://example.ch/1.jpg", "https://example.ch/2.jpg"] }, template: classic }
      responses:
        "202": { description: Angenommen, content: { application/json: { schema: { $ref: "#/components/schemas/VideoJob" } } } }
        "422": { $ref: "#/components/responses/Invalid" }
  /videos/{jobId}:
    get:
      tags: [Video-Rundgänge]
      summary: Status und Ergebnis
      operationId: getVideo
      parameters: [{ name: jobId, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: Status, content: { application/json: { schema: { $ref: "#/components/schemas/VideoJob" } } } }
        "404": { $ref: "#/components/responses/NotFound" }

  /staging:
    post:
      tags: [Virtual Staging]
      summary: Raum einrichten lassen
      description: Liefert ein eingerichtetes Bild und automatisch einen Vorher/Nachher-Vergleich. Ergebnis per Webhook `staging.completed` oder Abfrage.
      operationId: createStaging
      parameters: [{ $ref: "#/components/parameters/TenantRef" }, { $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody:
        required: true
        content:
          application/json:
            schema: { $ref: "#/components/schemas/JobCreate" }
            example: { imageUrl: "https://example.ch/wohnzimmer-leer.jpg", roomType: wohnen, style: skandinavisch, reference: OBJ-12-WZ }
      responses:
        "202": { description: Angenommen, content: { application/json: { schema: { $ref: "#/components/schemas/Job" } } } }
        "422": { $ref: "#/components/responses/Invalid" }
    get:
      tags: [Virtual Staging]
      summary: Letzte Staging-Aufträge
      operationId: listStaging
      parameters: [{ $ref: "#/components/parameters/Limit" }]
      responses:
        "200": { description: Liste, content: { application/json: { schema: { type: object, properties: { object: { const: list }, data: { type: array, items: { $ref: "#/components/schemas/Job" } } } } } } }
  /staging/{id}:
    get:
      tags: [Virtual Staging]
      summary: Status und Ergebnis
      operationId: getStaging
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: Auftrag, content: { application/json: { schema: { $ref: "#/components/schemas/Job" } } } }
        "404": { $ref: "#/components/responses/NotFound" }

  /visualizations:
    post:
      tags: [Visualisierung]
      summary: Visualisierung bestellen
      description: Aus Plan, Ansicht, Skizze oder Foto entsteht ein realistisches Bild. `view` = exterior oder interior.
      operationId: createVisualization
      parameters: [{ $ref: "#/components/parameters/TenantRef" }, { $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - $ref: "#/components/schemas/JobCreate"
                - type: object
                  properties: { view: { type: string, enum: [exterior, interior] } }
            example: { imageUrl: "https://example.ch/ansicht-sued.pdf.png", view: exterior, style: "warmes Abendlicht", reference: HAUS-4 }
      responses:
        "202": { description: Angenommen, content: { application/json: { schema: { $ref: "#/components/schemas/Job" } } } }
    get:
      tags: [Visualisierung]
      summary: Letzte Visualisierungs-Aufträge
      operationId: listVisualizations
      parameters: [{ $ref: "#/components/parameters/Limit" }]
      responses:
        "200": { description: Liste, content: { application/json: { schema: { type: object, properties: { object: { const: list }, data: { type: array, items: { $ref: "#/components/schemas/Job" } } } } } } }
  /visualizations/{id}:
    get:
      tags: [Visualisierung]
      summary: Status und Ergebnis
      operationId: getVisualization
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: Auftrag, content: { application/json: { schema: { $ref: "#/components/schemas/Job" } } } }
        "404": { $ref: "#/components/responses/NotFound" }

  /comparisons:
    post:
      tags: [Vorher/Nachher]
      summary: Vorher/Nachher-Vergleich erstellen
      description: Zwei Bilder (z. B. vor/nach Renovation oder Staging) als Schieberegler zum Einbetten per iframe.
      operationId: createComparison
      parameters: [{ $ref: "#/components/parameters/TenantRef" }, { $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [beforeUrl, afterUrl]
              properties:
                beforeUrl: { type: string, format: uri }
                afterUrl: { type: string, format: uri }
                title: { type: string }
                labels: { type: array, items: { type: string }, minItems: 2, maxItems: 2, example: [Vor der Renovation, Nach der Renovation] }
      responses:
        "201": { description: Erstellt, content: { application/json: { schema: { $ref: "#/components/schemas/Comparison" } } } }
  /comparisons/{id}:
    parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
    get:
      tags: [Vorher/Nachher]
      summary: Vergleich abrufen
      operationId: getComparison
      responses:
        "200": { description: Vergleich, content: { application/json: { schema: { $ref: "#/components/schemas/Comparison" } } } }
    delete:
      tags: [Vorher/Nachher]
      summary: Vergleich löschen
      operationId: deleteComparison
      responses:
        "200": { description: Gelöscht, content: { application/json: { schema: { $ref: "#/components/schemas/Deleted" } } } }

  /valuations:
    post:
      tags: [Bewertung]
      summary: Indikative Bewertung
      operationId: createValuation
      parameters: [{ $ref: "#/components/parameters/TenantRef" }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [property]
              properties:
                reference: { type: string }
                property:
                  type: object
                  required: [type]
                  properties:
                    address: { type: object, properties: { street: { type: string }, zip: { type: string }, city: { type: string }, country: { type: string, example: CH } } }
                    egid: { type: integer }
                    type: { type: string, example: apartment }
                    livingArea: { type: number }
                    landArea: { type: number }
                    rooms: { type: number }
                    buildYear: { type: integer }
                    condition: { type: string }
                options: { type: object, properties: { report: { type: boolean }, valuationType: { type: string, enum: [sale, rental, both] } } }
            example: { reference: BEW-1, property: { address: { zip: "5600", city: Lenzburg }, type: apartment, livingArea: 112, rooms: 4.5, buildYear: 2016 }, options: { report: true } }
      responses:
        "200":
          description: Ergebnis
          content:
            application/json:
              schema:
                type: object
                properties:
                  id: { type: string }
                  status: { const: completed }
                  currency: { const: CHF }
                  marketValue: { type: number }
                  valueRange: { type: object }
                  pricePerSqm: { type: number }
                  confidence: { type: string }
                  rentalValueMonthly: { type: number }
                  reportUrl: { type: [string, "null"] }
                  disclaimer: { type: string }
        "422": { $ref: "#/components/responses/Invalid" }

  /leads:
    get:
      tags: [Leads]
      summary: Anfragen abrufen
      description: Anfragen aus Ihren Projektseiten und Funnels, neueste zuerst. Für Echtzeit zusätzlich Webhook `lead.created`.
      operationId: listLeads
      parameters:
        - { $ref: "#/components/parameters/Limit" }
        - { $ref: "#/components/parameters/Before" }
        - { name: since, in: query, schema: { type: string, format: date-time }, description: Nur neuer als dieses Datum }
        - { name: source, in: query, schema: { type: string, enum: [site, funnel] } }
      responses:
        "200": { description: Liste, content: { application/json: { schema: { type: object, properties: { object: { const: list }, data: { type: array, items: { $ref: "#/components/schemas/Lead" } }, hasMore: { type: boolean } } } } } }
  /leads/{id}:
    get:
      tags: [Leads]
      summary: Eine Anfrage
      operationId: getLead
      parameters: [{ name: id, in: path, required: true, schema: { type: string, format: uuid } }]
      responses:
        "200": { description: Anfrage, content: { application/json: { schema: { $ref: "#/components/schemas/Lead" } } } }
        "404": { $ref: "#/components/responses/NotFound" }

  /marketplace/products:
    get:
      tags: [Marktplatz & 3D]
      summary: Möbel und Materialien
      operationId: listProducts
      parameters:
        - { $ref: "#/components/parameters/Limit" }
        - { $ref: "#/components/parameters/Before" }
        - { name: kind, in: query, schema: { type: string, enum: [furniture, material] } }
        - { name: category, in: query, schema: { type: string }, example: parkett }
        - { name: surface, in: query, schema: { type: string, enum: [boden, wand, kueche_front, arbeitsplatte, bad_boden, bad_wand, kamin, vorhang, treppe, teppich] } }
        - { name: supplier, in: query, schema: { type: string, format: uuid } }
        - { name: q, in: query, schema: { type: string }, description: Suche im Namen }
      responses:
        "200": { description: Katalog, content: { application/json: { schema: { type: object, properties: { object: { const: list }, data: { type: array, items: { $ref: "#/components/schemas/Product" } }, hasMore: { type: boolean }, nextBefore: { type: [string, "null"] } } } } } }
  /marketplace/products/{id}:
    get:
      tags: [Marktplatz & 3D]
      summary: Ein Produkt
      operationId: getProduct
      parameters: [{ name: id, in: path, required: true, schema: { type: string, format: uuid } }]
      responses:
        "200": { description: Produkt, content: { application/json: { schema: { $ref: "#/components/schemas/Product" } } } }
        "404": { $ref: "#/components/responses/NotFound" }
  /marketplace/inquiries:
    post:
      tags: [Marktplatz & 3D]
      summary: Einrichtungs-Anfrage senden
      description: Kunde fragt Produkte an; Immobrille leitet an die Händler weiter.
      operationId: createInquiry
      parameters: [{ $ref: "#/components/parameters/IdempotencyKey" }]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [items, contact, consent]
              properties:
                reference: { type: string }
                items: { type: array, items: { type: object, required: [productId], properties: { productId: { type: string, format: uuid }, variantId: { type: string, format: uuid }, quantity: { type: number } } } }
                contact: { type: object, required: [email], properties: { name: { type: string }, email: { type: string, format: email }, phone: { type: string } } }
                message: { type: string }
                consent: { type: boolean, description: Kunde ist mit Kontaktaufnahme einverstanden }
      responses:
        "201": { description: Erhalten, content: { application/json: { schema: { type: object, properties: { id: { type: string }, object: { const: marketplace_inquiry }, status: { const: received }, items: { type: integer } } } } } }
        "422": { $ref: "#/components/responses/Invalid" }
  /scenes:
    get:
      tags: [Marktplatz & 3D]
      summary: 3D-Rundgänge
      operationId: listScenes
      responses:
        "200": { description: Liste, content: { application/json: { schema: { type: object, properties: { object: { const: list }, data: { type: array, items: { type: object, properties: { slug: { type: string }, name: { type: string }, published: { type: boolean }, embedUrl: { type: string } } } } } } } } }
  /scenes/{slug}:
    get:
      tags: [Marktplatz & 3D]
      summary: Einrichtung eines 3D-Rundgangs + Einbett-Code
      operationId: getScene
      parameters: [{ name: slug, in: path, required: true, schema: { type: string }, example: sonnhalde-haus4 }]
      responses:
        "200": { description: Szene, content: { application/json: { schema: { type: object, properties: { slug: { type: string }, embedUrl: { type: string }, iframe: { type: string }, rooms: { type: array, items: { type: object } }, surfaces: { type: object }, furniture: { type: array, items: { type: object } }, products: { type: object } } } } } }
        "404": { $ref: "#/components/responses/NotFound" }

  /webhooks:
    get:
      tags: [Webhooks]
      summary: Registrierte Endpoints
      operationId: listWebhooks
      responses:
        "200": { description: Liste, content: { application/json: { schema: { type: object, properties: { endpoints: { type: array, items: { $ref: "#/components/schemas/WebhookEndpoint" } } } } } } }
    post:
      tags: [Webhooks]
      summary: Endpoint registrieren
      description: Das `secret` wird nur in dieser Antwort ausgegeben – sicher speichern.
      operationId: createWebhook
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required: [url]
              properties:
                url: { type: string, format: uri }
                events: { type: array, items: { $ref: "#/components/schemas/EventName" } }
      responses:
        "201": { description: Registriert, content: { application/json: { schema: { allOf: [{ $ref: "#/components/schemas/WebhookEndpoint" }, { type: object, properties: { secret: { type: string, example: whsec_… } } }] } } } }
  /webhooks/{id}:
    delete:
      tags: [Webhooks]
      summary: Endpoint entfernen
      operationId: deleteWebhook
      parameters: [{ name: id, in: path, required: true, schema: { type: string } }]
      responses:
        "200": { description: Entfernt }

webhooks:
  event:
    post:
      summary: Ereignis an Ihren Endpoint
      description: |
        Header `X-Immobrille-Signature: t=<unix>,v1=<hex>` – HMAC-SHA256 über `"<t>.<body>"` mit Ihrem `whsec_…`-Secret.
        Bei Fehler wiederholt Immobrille die Zustellung bis zu 6 Mal (5 Minuten bis 6 Stunden Abstand).
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                event: { $ref: "#/components/schemas/EventName" }
                id: { type: string }
                reference: { type: [string, "null"] }
              additionalProperties: true
      responses:
        "200": { description: Mit 2xx bestätigen }

components:
  securitySchemes:
    bearerAuth: { type: http, scheme: bearer, description: "sk_test_… oder sk_live_…" }
  parameters:
    TenantRef: { name: X-Tenant-Ref, in: header, schema: { type: string }, description: Ihre Kunden-Referenz (z. B. Makler-ID). Legt den Mandanten bei Bedarf an. }
    IdempotencyKey: { name: Idempotency-Key, in: header, schema: { type: string }, description: Gleicher Key = gleiche Antwort (24 h), keine Doppelaufträge. }
    Limit: { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 100, default: 25 } }
    Before: { name: before, in: query, schema: { type: string, format: date-time }, description: Blättern – nur Einträge älter als dieses Datum }
  responses:
    Unauthorized: { description: Key fehlt oder ungültig, content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    NotFound: { description: Unbekannt, content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
    Invalid: { description: Eingabe unvollständig, content: { application/json: { schema: { $ref: "#/components/schemas/Error" } } } }
  schemas:
    Error:
      type: object
      properties:
        error: { type: object, properties: { code: { type: string, example: INVALID_INPUT }, message: { type: string }, requestId: { type: string } } }
    Deleted: { type: object, properties: { id: { type: string }, object: { type: string }, deleted: { const: true } } }
    EventName: { type: string, enum: [lead.created, video.completed, video.failed, staging.completed, staging.failed, visualization.completed, visualization.failed, valuation.completed] }
    SiteContent:
      type: object
      description: Inhalt der Projektseite. Alle Felder optional; nicht erkannte Felder werden ignoriert.
      properties:
        layout: { type: string, enum: [classic, modern, villa, stay, rental, atelier, night, block] }
        fonts: { type: string, enum: [classic, editorial, serif, luxe, jakarta, geist, condensed, bricolage] }
        lang: { type: string, enum: [de, en] }
        headline: { type: string }
        eyebrow: { type: string }
        heroImage: { type: string, format: uri }
        theme: { type: object, properties: { primary: { type: string }, secondary: { type: string }, footer: { type: string } } }
        intro: { type: object, properties: { title: { type: string }, text: { type: string }, cta: { type: object, properties: { label: { type: string }, href: { type: string } } } } }
        facts: { type: array, items: { type: object, properties: { value: { type: string }, label: { type: string } } } }
        gallery: { type: array, items: { type: string, format: uri } }
        units: { type: array, items: { type: object, properties: { id: { type: string }, house: { type: string }, floor: { type: string }, rooms: { type: number }, area: { type: number }, price: { type: string }, status: { type: string, enum: [frei, reserviert, verkauft] }, pdf: { type: string } } } }
        rent: { type: object, properties: { net: { type: string }, extra: { type: string }, gross: { type: string }, note: { type: string } } }
        location: { type: object }
        tour: { type: object, properties: { title: { type: string }, text: { type: string }, video: { type: string }, poster: { type: string } } }
        agent: { type: object, properties: { name: { type: string }, company: { type: string }, phone: { type: string }, email: { type: string } } }
        inquiry: { type: object, properties: { title: { type: string }, to: { type: string, format: email, description: Empfänger der Anfragen } } }
        noindex: { type: boolean }
      additionalProperties: true
    SiteCreate:
      type: object
      required: [name]
      properties:
        name: { type: string }
        slug: { type: string, description: "Adresse www.immobrille.ch/website/projekt/{slug}; bei Kollision wird -2 usw. angehängt" }
        publish: { type: boolean, default: false }
        content: { $ref: "#/components/schemas/SiteContent" }
    Site:
      type: object
      properties:
        id: { type: string, format: uuid }
        object: { const: site }
        slug: { type: string }
        name: { type: string }
        status: { type: string, enum: [draft, published] }
        url: { type: string }
        embedUrl: { type: string }
        createdAt: { type: string }
        updatedAt: { type: string }
        publishedAt: { type: [string, "null"] }
        content: { $ref: "#/components/schemas/SiteContent" }
    SiteList: { type: object, properties: { object: { const: list }, data: { type: array, items: { $ref: "#/components/schemas/Site" } }, hasMore: { type: boolean } } }
    VideoJob:
      type: object
      properties:
        id: { type: string, example: vid_… }
        reference: { type: [string, "null"] }
        status: { type: string, enum: [queued, processing, completed, failed] }
        videoUrl: { type: [string, "null"] }
        error: { type: [string, "null"] }
    JobCreate:
      type: object
      required: [imageUrl]
      properties:
        imageUrl: { type: string, format: uri, description: Öffentlich erreichbares Bild (https) }
        roomType: { type: string, example: wohnen }
        style: { type: string, example: skandinavisch }
        prompt: { type: string, description: Zusätzliche Wünsche in Worten }
        reference: { type: string }
        callbackUrl: { type: string, format: uri, description: Wird bei Fertigstellung zusätzlich direkt aufgerufen }
    Job:
      type: object
      properties:
        id: { type: string, example: stg_… }
        object: { type: string, enum: [staging, visualization] }
        reference: { type: [string, "null"] }
        status: { type: string, enum: [queued, processing, completed, failed] }
        input: { type: object }
        imageUrl: { type: [string, "null"], description: Ergebnisbild }
        comparisonId: { type: [string, "null"] }
        comparisonUrl: { type: [string, "null"], description: Einbettbarer Vorher/Nachher-Regler }
        error: { type: [string, "null"] }
        createdAt: { type: string }
        completedAt: { type: [string, "null"] }
        sandbox: { type: boolean }
    Comparison:
      type: object
      properties:
        id: { type: string, example: cmp_… }
        object: { const: comparison }
        title: { type: [string, "null"] }
        beforeUrl: { type: string }
        afterUrl: { type: string }
        labels: { type: array, items: { type: string } }
        embedUrl: { type: string }
        iframe: { type: string }
    Lead:
      type: object
      properties:
        id: { type: string, format: uuid }
        object: { const: lead }
        source: { type: string, enum: [site, funnel] }
        tenantRef: { type: [string, "null"] }
        siteSlug: { type: [string, "null"] }
        name: { type: [string, "null"] }
        email: { type: string }
        phone: { type: [string, "null"] }
        message: { type: [string, "null"] }
        unit: { type: [string, "null"] }
        rooms: { type: array, items: { type: string } }
        tenure: { type: [string, "null"] }
        createdAt: { type: string }
    Product:
      type: object
      properties:
        id: { type: string, format: uuid }
        object: { const: product }
        kind: { type: string, enum: [furniture, material] }
        name: { type: string }
        description: { type: [string, "null"] }
        category: { type: string }
        surfaces: { type: array, items: { type: string } }
        supplier: { type: object, properties: { id: { type: string }, name: { type: string }, website: { type: [string, "null"] } } }
        dimensionsCm: { type: [object, "null"], properties: { width: { type: number }, depth: { type: number }, height: { type: number } } }
        price: { type: object, properties: { amount: { type: [number, "null"] }, currency: { const: CHF }, kind: { type: string, enum: [fix, ab, auf_anfrage] }, unit: { type: string, enum: [stk, m2, lfm, l, set] } } }
        shopUrl: { type: [string, "null"] }
        leadTime: { type: [string, "null"] }
        images: { type: array, items: { type: object, properties: { role: { type: string }, url: { type: string } } } }
        variants: { type: array, items: { type: object, properties: { id: { type: string }, label: { type: string }, colorHex: { type: [string, "null"] }, textureUrl: { type: [string, "null"] }, textureSizeM: { type: number }, price: { type: [number, "null"] } } } }
    WebhookEndpoint:
      type: object
      properties:
        id: { type: string }
        url: { type: string }
        events: { type: array, items: { $ref: "#/components/schemas/EventName" } }
        active: { type: boolean }
        created_at: { type: string }
