{
  "openapi": "3.0.3",
  "info": {
    "title": "Kvaliteetaken preliminary quote API (windows, doors and glass units)",
    "version": "1.0.0",
    "description": "Guest sale quotes for windows/doors and insulating glass units (EUR, no sign-in, no personal data), plus a trial agent order interface that saves offers in a customer's account with their personal key. Rates and performance may be unverified; delivery/local compliance require review. Quote lookups: 30/min and 300/hour per address (429 + Retry-After)."
  },
  "servers": [
    {
      "url": "https://kvaliteetaken-studio.lovable.app"
    }
  ],
  "paths": {
    "/api/public/quote": {
      "get": {
        "operationId": "listQuoteOptions",
        "summary": "List options, or quote one position by link (?type=W2&w=1500&h=1250)",
        "responses": {
          "200": {
            "description": "Available quote options"
          },
          "429": {
            "description": "Too many lookups from this address (Retry-After)"
          }
        },
        "description": "Without parameters: lists products, colours and glass option ids. With type, w and h: returns a preliminary quote for one position (same response as POST). Works for link-only AI browsers.",
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Product id, e.g. W1, W2, BD",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "w",
            "in": "query",
            "required": false,
            "description": "Window width mm (overall frame)",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "h",
            "in": "query",
            "required": false,
            "description": "Window height mm, excluding 30 mm sill profile",
            "schema": {
              "type": "integer"
            }
          },
          {
            "name": "qty",
            "in": "query",
            "required": false,
            "description": "Quantity, max 5",
            "schema": {
              "type": "integer",
              "default": 1
            }
          },
          {
            "name": "openings",
            "in": "query",
            "required": false,
            "description": "Comma list per section: F, D-L, D-R, K, DK-L, DK-R",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "panes",
            "in": "query",
            "required": false,
            "description": "2 or 3",
            "schema": {
              "type": "integer",
              "default": 3
            }
          },
          {
            "name": "room",
            "in": "query",
            "required": false,
            "description": "general|bathroom|bedroom|kitchen",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "colour",
            "in": "query",
            "required": false,
            "description": "Colour name from the options list",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "glassOptions",
            "in": "query",
            "required": false,
            "description": "Comma list of glass option ids",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "post": {
        "operationId": "calculatePreliminaryQuote",
        "summary": "Calculate a preliminary quote and configuration-only draft link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "positions"
                ],
                "properties": {
                  "room": {
                    "type": "string",
                    "enum": [
                      "general",
                      "bathroom",
                      "bedroom",
                      "kitchen"
                    ],
                    "default": "general"
                  },
                  "panes": {
                    "type": "integer",
                    "enum": [
                      2,
                      3
                    ],
                    "default": 3
                  },
                  "glassOptions": {
                    "type": "array",
                    "maxItems": 12,
                    "items": {
                      "type": "string",
                      "pattern": "^[a-z0-9_]{1,40}$"
                    },
                    "default": []
                  },
                  "colour": {
                    "type": "string",
                    "maxLength": 80,
                    "default": "White"
                  },
                  "middleGasket": {
                    "type": "boolean",
                    "default": false
                  },
                  "positions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 5,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "widthMm",
                        "heightMm"
                      ],
                      "properties": {
                        "productType": {
                          "type": "string",
                          "default": "W1"
                        },
                        "widthMm": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 6000
                        },
                        "heightMm": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 3500
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 5,
                          "default": 1
                        },
                        "openings": {
                          "type": "array",
                          "minItems": 1,
                          "maxItems": 5,
                          "items": {
                            "type": "string",
                            "enum": [
                              "F",
                              "D-L",
                              "D-R",
                              "K",
                              "DK-L",
                              "DK-R"
                            ]
                          }
                        },
                        "outward": {
                          "type": "boolean",
                          "default": false
                        },
                        "stulp": {
                          "type": "boolean",
                          "default": false
                        },
                        "watersill": {
                          "type": "boolean",
                          "default": false
                        },
                        "windowbank": {
                          "type": "boolean",
                          "default": false
                        }
                      }
                    },
                    "description": "Sum of quantities must not exceed five physical units. Openings must match product section count."
                  }
                }
              },
              "example": {
                "room": "bathroom",
                "panes": 3,
                "positions": [
                  {
                    "productType": "W1",
                    "widthMm": 400,
                    "heightMm": 1500,
                    "qty": 1
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Preliminary or needs_review result; incomplete totals are partial subtotals",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "seller",
                    "totals",
                    "draftUrl"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "enum": [
                        "preliminary",
                        "needs_review"
                      ]
                    },
                    "seller": {
                      "type": "object"
                    },
                    "currency": {
                      "type": "string",
                      "enum": [
                        "EUR"
                      ]
                    },
                    "positions": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    },
                    "recommendations": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "totals": {
                      "type": "object",
                      "properties": {
                        "net": {
                          "type": "number"
                        },
                        "gross": {
                          "type": "number"
                        },
                        "vat": {
                          "type": "number"
                        },
                        "vatPercent": {
                          "type": "number"
                        },
                        "incomplete": {
                          "type": "boolean"
                        }
                      }
                    },
                    "draftUrl": {
                      "type": "string",
                      "format": "uri"
                    },
                    "disclaimer": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid configuration or quote unavailable"
          },
          "413": {
            "description": "Body exceeds 16384 bytes"
          },
          "415": {
            "description": "Requires application/json"
          },
          "429": {
            "description": "Too many lookups from this address (Retry-After)"
          }
        }
      }
    },
    "/api/public/glass": {
      "get": {
        "operationId": "glassPriceList",
        "summary": "Glass unit price list (sale price per m² incl./excl. VAT, estimated properties), materials and pricing rules; or quote one unit with ?preset=&widthMm=&heightMm=&qty=",
        "parameters": [
          {
            "name": "preset",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "widthMm",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 100,
              "maximum": 6000
            }
          },
          {
            "name": "heightMm",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 100,
              "maximum": 6000
            }
          },
          {
            "name": "qty",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 999
            }
          },
          {
            "name": "shaped",
            "in": "query",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Price list, or a quote when preset is given"
          }
        }
      },
      "post": {
        "operationId": "quoteGlassUnits",
        "summary": "Sale quote for insulating glass units (glass only, no window) with an order link",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "lines"
                ],
                "properties": {
                  "lines": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "additionalProperties": false,
                      "required": [
                        "widthMm",
                        "heightMm"
                      ],
                      "properties": {
                        "preset": {
                          "type": "string",
                          "description": "Ready glass unit id from GET /api/public/glass (give preset or buildUp)"
                        },
                        "buildUp": {
                          "type": "object",
                          "description": "Panes outside → inside and gaps between them; material ids from GET",
                          "properties": {
                            "panes": {
                              "type": "array",
                              "minItems": 1,
                              "maxItems": 3,
                              "items": {
                                "type": "object",
                                "required": [
                                  "materialId"
                                ],
                                "properties": {
                                  "materialId": {
                                    "type": "string"
                                  },
                                  "tempered": {
                                    "type": "boolean"
                                  }
                                }
                              }
                            },
                            "gaps": {
                              "type": "array",
                              "maxItems": 2,
                              "items": {
                                "type": "object",
                                "required": [
                                  "widthMm",
                                  "gas",
                                  "spacer"
                                ],
                                "properties": {
                                  "widthMm": {
                                    "type": "integer"
                                  },
                                  "gas": {
                                    "type": "string",
                                    "enum": [
                                      "air",
                                      "argon",
                                      "krypton"
                                    ]
                                  },
                                  "spacer": {
                                    "type": "string",
                                    "enum": [
                                      "alu",
                                      "warm"
                                    ]
                                  }
                                }
                              }
                            }
                          }
                        },
                        "widthMm": {
                          "type": "integer",
                          "minimum": 100,
                          "maximum": 6000
                        },
                        "heightMm": {
                          "type": "integer",
                          "minimum": 100,
                          "maximum": 6000
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 999,
                          "default": 1
                        },
                        "shaped": {
                          "type": "boolean",
                          "default": false
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Unit and total sale prices excl./incl. VAT, estimated properties and orderUrl"
          },
          "400": {
            "description": "Invalid configuration"
          }
        }
      }
    },
    "/api/public/agent/order": {
      "post": {
        "operationId": "createAgentOrder",
        "summary": "Save a priced offer or send an order request in the key owner's account (trial)",
        "security": [
          {
            "agentKey": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "positions"
                ],
                "additionalProperties": false,
                "properties": {
                  "reference": {
                    "type": "string",
                    "maxLength": 160,
                    "description": "Project or site name"
                  },
                  "projectRules": {
                    "type": "string",
                    "maxLength": 2000,
                    "description": "Customer's construction project rules, stored on the offer for our team"
                  },
                  "contact": {
                    "type": "object",
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "company": {
                        "type": "string"
                      },
                      "email": {
                        "type": "string",
                        "format": "email"
                      },
                      "phone": {
                        "type": "string"
                      }
                    }
                  },
                  "deliveryAddress": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "panes": {
                    "type": "integer",
                    "enum": [
                      2,
                      3
                    ],
                    "default": 3
                  },
                  "glassOptions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "colour": {
                    "type": "string",
                    "default": "White"
                  },
                  "middleGasket": {
                    "type": "boolean",
                    "default": false
                  },
                  "transport": {
                    "type": "boolean",
                    "default": false
                  },
                  "installation": {
                    "type": "boolean",
                    "default": false
                  },
                  "submit": {
                    "type": "boolean",
                    "default": false,
                    "description": "false = draft for the customer to review; true = order request to our team"
                  },
                  "positions": {
                    "type": "array",
                    "minItems": 1,
                    "maxItems": 50,
                    "items": {
                      "type": "object",
                      "required": [
                        "widthMm",
                        "heightMm"
                      ],
                      "additionalProperties": false,
                      "properties": {
                        "productType": {
                          "type": "string",
                          "default": "W1",
                          "description": "Product id from GET /api/public/quote"
                        },
                        "widthMm": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 6000
                        },
                        "heightMm": {
                          "type": "integer",
                          "minimum": 300,
                          "maximum": 3500
                        },
                        "qty": {
                          "type": "integer",
                          "minimum": 1,
                          "maximum": 99,
                          "default": 1
                        },
                        "openings": {
                          "type": "array",
                          "items": {
                            "type": "string",
                            "enum": [
                              "F",
                              "D-L",
                              "D-R",
                              "K",
                              "DK-L",
                              "DK-R"
                            ]
                          },
                          "description": "One per section, left to right"
                        },
                        "outward": {
                          "type": "boolean"
                        },
                        "stulp": {
                          "type": "boolean"
                        },
                        "watersill": {
                          "type": "boolean"
                        },
                        "windowbank": {
                          "type": "boolean"
                        },
                        "notes": {
                          "type": "string",
                          "maxLength": 500
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "reference": "Pärnu mnt 10 renovation",
                "panes": 3,
                "submit": false,
                "positions": [
                  {
                    "productType": "W2",
                    "widthMm": 1500,
                    "heightMm": 1250,
                    "qty": 3,
                    "openings": [
                      "DK-L",
                      "F"
                    ]
                  },
                  {
                    "productType": "BD",
                    "widthMm": 900,
                    "heightMm": 2100,
                    "qty": 2
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Offer created: offerId, offerNo, status (draft|order_requested|support_requested), positions, totals, offerUrl, statusUrl, payment"
          },
          "400": {
            "description": "Invalid order (issues + example)"
          },
          "401": {
            "description": "Missing or revoked agent key"
          },
          "429": {
            "description": "Rate limited (Retry-After)"
          }
        }
      },
      "get": {
        "operationId": "getAgentOrderStatus",
        "summary": "Status of an order created with this key",
        "security": [
          {
            "agentKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "offerId, offerNo, orderNumber, status, stage, totals, updatedAt, offerUrl"
          },
          "401": {
            "description": "Missing or revoked agent key"
          },
          "404": {
            "description": "Not found for this account"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "agentKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "Customer's personal agent key (kvk_…) from My offers → AI agent access. X-Api-Key header also accepted."
      }
    }
  }
}