{
  "openapi": "3.0.3",
  "info": {
    "title": "Bringness AI Supplier API",
    "version": "1.0.0",
    "description": "Lieferantengebundene Schnittstelle. Separaten Schlüssel unter Lieferanten-API erstellen und aktivieren. 600 Anfragen je Verbindung pro 15 Minuten. Produktimport bis 100 Produkte und 220000 Zeichen je Anfrage. Jede neue Änderung braucht eine neue requestId; Netzfehler mit gleicher ID und gleichen Daten wiederholen. API-Schlüssel und Login-Token sind getrennt. Keine Wareneingangsbestätigung, keine Änderung von Provisionen. Verfügbarkeit ist eine Lieferbar-Kennzeichnung, keine Reservierung physischer Bestände. Erweiterte Lieferantenrückmeldungen: bestätigte Liefertermine, Nichtlieferbarkeit und Ersatzvorschläge mit dauerhaft wiederholbaren requestId-Kennungen. Herstelleradapter und Webhooks sind nicht enthalten."
  },
  "servers": [
    {
      "url": "https://bringness-ai.com"
    }
  ],
  "security": [
    {
      "SupplierKey": []
    }
  ],
  "paths": {
    "/api/ai/v1/supplier/status": {
      "get": {
        "operationId": "supplierStatus",
        "summary": "Verbindung prüfen",
        "responses": {
          "200": {
            "description": "Aktive Verbindung und fest vereinbarte 2%-Provision.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "version": {
                      "type": "string"
                    },
                    "connectorId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "lastSync": {
                      "type": "string",
                      "format": "date-time",
                      "nullable": true
                    },
                    "commissionBps": {
                      "type": "integer",
                      "enum": [
                        200
                      ]
                    },
                    "permissions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/supplier/products": {
      "get": {
        "operationId": "supplierProducts",
        "summary": "Eigene Produkte exportieren",
        "parameters": [
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Bis 100 Produkte. Mit nextAfter fortsetzen; für einen neuen vollständigen Export ohne after starten.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "products": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Product"
                      }
                    },
                    "nextAfter": {
                      "type": "string",
                      "format": "uuid",
                      "nullable": true
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "operationId": "importSupplierProducts",
        "summary": "Bis 100 Produkte atomar anlegen oder aktualisieren",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "requestId",
                  "products"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "products": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 100,
                    "items": {
                      "$ref": "#/components/schemas/ProductInput"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Wiederholung derselben ID mit identischen Daten übernimmt keine Änderung erneut.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "imported": {
                      "type": "integer"
                    },
                    "duplicate": {
                      "type": "boolean"
                    },
                    "products": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {
                            "type": "string",
                            "format": "uuid"
                          },
                          "external_code": {
                            "type": "string",
                            "minLength": 1,
                            "maxLength": 150
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/supplier/orders": {
      "get": {
        "operationId": "supplierOrders",
        "summary": "Eigene Bestellungen und Statusänderungen abrufen",
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Cursor unverändert speichern und weitergeben. Bis 100 aktuelle Bestellstände; hasMore bedeutet sofort weiterlesen, sonst beim nächsten Abruf fortsetzen. Keine Ereignishistorie.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "orders": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      }
                    },
                    "nextCursor": {
                      "type": "string",
                      "nullable": true
                    },
                    "hasMore": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/supplier/orders/{orderId}/accept": {
      "post": {
        "operationId": "supplieraccept",
        "summary": "Bestellung annehmen",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Identische Wiederholung ohne zweite Statusbuchung.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "duplicate": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/supplier/orders/{orderId}/cancel": {
      "post": {
        "operationId": "suppliercancel",
        "summary": "Offene Bestellung stornieren",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Identische Wiederholung ohne zweite Statusbuchung.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "duplicate": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "500": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "503": {
            "description": "Keine Teilbuchung; bei 429/500/503 später mit derselben Import-ID wiederholen.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "error"
                  ],
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/ai/v1/supplier/order-groups/{groupId}/accept": {
      "post": {
        "operationId": "supplierFeedbackAccept",
        "summary": "Gesamten Lieferauftrag mit Liefertermin bestätigen",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "requestId",
                  "confirmed",
                  "deliveryDate"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirmed": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "deliveryDate": {
                    "type": "string",
                    "format": "date",
                    "description": "Bestätigter Berliner Kalendertag, heute oder später."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/SupplierFeedbackSuccess"
          },
          "400": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "401": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "403": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "404": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "405": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "409": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "429": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "500": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "503": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          }
        }
      }
    },
    "/api/ai/v1/supplier/order-groups/{groupId}/cancel": {
      "post": {
        "operationId": "supplierFeedbackCancel",
        "summary": "Offenen Lieferauftrag mit Begründung stornieren",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "requestId",
                  "confirmed",
                  "reason"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirmed": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/SupplierFeedbackSuccess"
          },
          "400": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "401": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "403": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "404": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "405": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "409": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "429": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "500": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "503": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          }
        }
      }
    },
    "/api/ai/v1/supplier/orders/{orderId}/unavailable": {
      "post": {
        "operationId": "supplierFeedbackUnavailable",
        "summary": "Nichtlieferbarkeit einer eigenen Position melden",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "requestId",
                  "confirmed",
                  "reason"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirmed": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "pauseProduct": {
                    "type": "boolean",
                    "default": false
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/SupplierFeedbackSuccess"
          },
          "400": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "401": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "403": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "404": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "405": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "409": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "429": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "500": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "503": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          }
        }
      }
    },
    "/api/ai/v1/supplier/orders/{orderId}/replacement": {
      "post": {
        "operationId": "supplierFeedbackReplacement",
        "summary": "Eigenen lieferbaren Ersatz vorschlagen; Restaurant entscheidet",
        "parameters": [
          {
            "name": "orderId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "requestId",
                  "confirmed",
                  "reason",
                  "productId",
                  "packs"
                ],
                "properties": {
                  "requestId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "confirmed": {
                    "type": "boolean",
                    "enum": [
                      true
                    ]
                  },
                  "reason": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 1000
                  },
                  "productId": {
                    "type": "string",
                    "format": "uuid"
                  },
                  "packs": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "$ref": "#/components/responses/SupplierFeedbackSuccess"
          },
          "400": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "401": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "403": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "404": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "405": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "409": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "429": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "500": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          },
          "503": {
            "$ref": "#/components/responses/SupplierFeedbackError"
          }
        }
      }
    },
    "/api/ai/v1/supplier/order-groups/{groupId}": {
      "get": {
        "operationId": "supplierGroupDetail",
        "summary": "Alle eigenen Positionen eines Auftrags lesen (höchstens 500, sonst 409)",
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Vollständiger eigener Lieferauftrag; ohne supplier_order_id wird die einzelne Bestell-ID verwendet.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "groupId": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "orders": {
                      "type": "array",
                      "maxItems": 500,
                      "items": {
                        "$ref": "#/components/schemas/Order"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Kein eigener Auftrag"
          },
          "409": {
            "description": "Mehr als 500 Positionen; keine abgeschnittene Antwort"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SupplierKey": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "ProductInput": {
        "type": "object",
        "required": [
          "externalCode",
          "name",
          "unit",
          "packQuantity",
          "priceCents"
        ],
        "properties": {
          "externalCode": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 150
          },
          "unit": {
            "type": "string",
            "enum": [
              "kg",
              "l",
              "piece"
            ]
          },
          "packQuantity": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "maximum": 1000000,
            "multipleOf": 0.001,
            "description": "Bei piece eine ganze Zahl."
          },
          "priceCents": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100000000,
            "description": "Nettopreis je Packung in Cent."
          },
          "minimumPacks": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10000,
            "default": 1
          },
          "active": {
            "type": "boolean",
            "default": true
          },
          "available": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "Product": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "external_code": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "pack_quantity": {
            "type": "string",
            "description": "Dezimalmenge als PostgreSQL-Zeichenfolge."
          },
          "price_cents": {
            "type": "string",
            "description": "Netto-Cent als PostgreSQL-bigint-Zeichenfolge."
          },
          "minimum_packs": {
            "type": "integer"
          },
          "active": {
            "type": "boolean"
          },
          "available": {
            "type": "boolean"
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid"
          },
          "product_id": {
            "type": "string",
            "format": "uuid"
          },
          "external_code": {
            "type": "string",
            "nullable": true
          },
          "product_name": {
            "type": "string"
          },
          "unit": {
            "type": "string"
          },
          "pack_quantity": {
            "type": "string"
          },
          "packs": {
            "type": "integer"
          },
          "net_cents": {
            "type": "string"
          },
          "commission_bps": {
            "type": "integer"
          },
          "commission_cents": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "sent",
              "accepted",
              "received",
              "cancelled"
            ]
          },
          "delivery_date": {
            "type": "string",
            "format": "date"
          },
          "delivery_address": {
            "type": "string"
          },
          "buyer_email": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "supplier_order_id": {
            "type": "string",
            "format": "uuid",
            "nullable": true
          },
          "confirmed_delivery_date": {
            "type": "string",
            "format": "date",
            "nullable": true
          },
          "unavailable": {
            "type": "boolean"
          },
          "unavailable_reason": {
            "type": "string"
          },
          "ordered_packs": {
            "type": "integer",
            "nullable": true
          },
          "original_net_cents": {
            "type": "string",
            "nullable": true
          },
          "delivered_packs": {
            "type": "string",
            "nullable": true
          },
          "received_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "replacement": {
            "type": "object",
            "nullable": true,
            "description": "Neuester Ersatzvorschlag einschließlich gespeichertem Produkt-/Preissnapshot; Zustimmung ausschließlich durch Restaurant.",
            "properties": {
              "id": {
                "type": "string",
                "format": "uuid"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending",
                  "approved",
                  "rejected",
                  "cancelled"
                ]
              },
              "snapshot": {
                "type": "object"
              },
              "reason": {
                "type": "string"
              },
              "createdAt": {
                "type": "string",
                "format": "date-time"
              },
              "decidedAt": {
                "type": "string",
                "format": "date-time",
                "nullable": true
              }
            }
          }
        }
      }
    },
    "responses": {
      "SupplierFeedbackSuccess": {
        "description": "Dauerhaft gespeicherte Rückmeldung. Identische requestId und Nutzdaten geben ursprüngliche Bestätigung mit replayed:true zurück, ohne spätere Zustände zurückzusetzen.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "ok": {
                  "type": "boolean"
                },
                "replayed": {
                  "type": "boolean"
                },
                "groupId": {
                  "type": "string",
                  "format": "uuid"
                },
                "positions": {
                  "type": "integer"
                },
                "id": {
                  "type": "string",
                  "format": "uuid"
                },
                "adminNotified": {
                  "type": "boolean"
                }
              }
            }
          }
        }
      },
      "SupplierFeedbackError": {
        "description": "Keine Teiländerung. 400 Eingabe/Zustimmung prüfen; 401/403 aktuelle Freigabe prüfen; 404 kein eigener Auftrag; 409 widersprüchliche Kennung oder gesperrter Bestellzustand; 429/500/503 denselben gespeicherten Vorgang später wiederholen.",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "error"
              ],
              "properties": {
                "error": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    }
  }
}
