{
  "openapi": "3.1.0",
  "info": {
    "title": "Stahl & Söhne API",
    "summary": "Agent-first API for moving workflows",
    "description": "Machine-readable API contract for moving service discovery and actions. Agent endpoints require scoped bearer tokens.",
    "version": "1.1.0",
    "contact": {
      "name": "Stahl & Söhne KG",
      "email": "office@stahlundsoehne.at",
      "url": "https://www.stahlundsoehne.at"
    }
  },
  "servers": [
    {
      "url": "https://www.stahlundsoehne.at",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Public Requests",
      "description": "Public website request endpoints"
    },
    {
      "name": "Agent Actions",
      "description": "Scoped action endpoints for AI agents"
    }
  ],
  "paths": {
    "/api/send-removal-request": {
      "post": {
        "tags": [
          "Public Requests"
        ],
        "operationId": "createRemovalRequest",
        "summary": "Create relocation request",
        "description": "Creates a relocation cost estimate request and delivers it to the internal inbox.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RemovalRequestInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request accepted successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuccessResponse"
                }
              }
            }
          },
          "400": {
            "description": "Missing required fields",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "500": {
            "description": "Server-side processing error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/check-service-area": {
      "post": {
        "tags": [
          "Agent Actions"
        ],
        "operationId": "checkServiceArea",
        "summary": "Check service area eligibility",
        "description": "Determines whether a region or postal code is currently in the primary service area.",
        "security": [
          {
            "AgentBearerAuth": []
          }
        ],
        "x-required-scope": "service:read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ServiceAreaRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Service area result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ServiceAreaResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithTrackingResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScopeErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/estimate-price": {
      "post": {
        "tags": [
          "Agent Actions"
        ],
        "operationId": "estimatePrice",
        "summary": "Estimate moving price range",
        "description": "Returns an indicative price range based on move profile assumptions.",
        "security": [
          {
            "AgentBearerAuth": []
          }
        ],
        "x-required-scope": "quote:read",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EstimatePriceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Price estimate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EstimatePriceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithTrackingResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScopeErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/agent/request-callback": {
      "post": {
        "tags": [
          "Agent Actions"
        ],
        "operationId": "requestCallback",
        "summary": "Create callback lead",
        "description": "Creates a callback lead object for follow-up by the operations team.",
        "security": [
          {
            "AgentBearerAuth": []
          }
        ],
        "x-required-scope": "lead:create",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CallbackRequestInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Callback request accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CallbackResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithTrackingResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Insufficient scope",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScopeErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AgentBearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Scoped agent token. Configure `AGENT_API_TOKENS_JSON` on the server."
      }
    },
    "schemas": {
      "RemovalRequestInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "postalCode",
          "category",
          "fromAddress",
          "toAddress"
        ],
        "properties": {
          "postalCode": {
            "type": "string",
            "minLength": 2
          },
          "category": {
            "type": "string"
          },
          "fromAddress": {
            "type": "string",
            "minLength": 5
          },
          "toAddress": {
            "type": "string",
            "minLength": 5
          }
        }
      },
      "ServiceAreaRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "postalCode": {
            "type": "string"
          },
          "region": {
            "type": "string"
          }
        }
      },
      "ServiceAreaResponse": {
        "type": "object",
        "required": [
          "trackingId",
          "serviceable",
          "regionHint",
          "message"
        ],
        "properties": {
          "trackingId": {
            "type": "string"
          },
          "serviceable": {
            "type": "boolean"
          },
          "regionHint": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "EstimatePriceRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "rooms"
        ],
        "properties": {
          "rooms": {
            "type": "integer",
            "minimum": 1
          },
          "moveType": {
            "type": "string",
            "enum": [
              "privatumzug",
              "firmenumzug"
            ]
          },
          "distanceKm": {
            "type": "number",
            "minimum": 0
          },
          "hasAssembly": {
            "type": "boolean"
          }
        }
      },
      "EstimatePriceResponse": {
        "type": "object",
        "required": [
          "trackingId",
          "currency",
          "estimatedMinPrice",
          "estimatedMaxPrice",
          "assumptions",
          "message"
        ],
        "properties": {
          "trackingId": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "estimatedMinPrice": {
            "type": "number"
          },
          "estimatedMaxPrice": {
            "type": "number"
          },
          "assumptions": {
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "CallbackRequestInput": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "phone"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "phone": {
            "type": "string"
          },
          "preferredTime": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      },
      "CallbackResponse": {
        "type": "object",
        "required": [
          "trackingId",
          "status",
          "callbackRequest",
          "message"
        ],
        "properties": {
          "trackingId": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "callbackRequest": {
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "SuccessResponse": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "message"
        ],
        "properties": {
          "message": {
            "type": "string"
          },
          "error": {
            "type": "string"
          }
        }
      },
      "ErrorWithTrackingResponse": {
        "type": "object",
        "required": [
          "message",
          "trackingId"
        ],
        "properties": {
          "message": {
            "type": "string"
          },
          "trackingId": {
            "type": "string"
          }
        }
      },
      "ScopeErrorResponse": {
        "type": "object",
        "required": [
          "message",
          "requiredScope"
        ],
        "properties": {
          "message": {
            "type": "string"
          },
          "requiredScope": {
            "type": "string"
          }
        }
      }
    }
  }
}
