{
  "info": {
    "description": "Read the catalog and request a fixed-price quote. Prices are computed server side from the catalog. Everything in writing. No calls. Files belong to the client; the client hosts the result.",
    "title": "Pieza quote API",
    "version": "1.0.0"
  },
  "openapi": "3.1.0",
  "paths": {
    "/api/quote": {
      "post": {
        "operationId": "requestQuote",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "additionalProperties": false,
                    "properties": {
                      "contact": {
                        "additionalProperties": false,
                        "description": "Only with the client's consent. Creates a lead and returns ref.",
                        "properties": {
                          "email": {
                            "format": "email",
                            "type": "string"
                          },
                          "name": {
                            "maxLength": 100,
                            "type": "string"
                          }
                        },
                        "required": [
                          "email"
                        ],
                        "type": "object"
                      },
                      "extras": {
                        "description": "Optional extras. Additional products or rooms are computed from quantity; if listed here they are ignored.",
                        "items": {
                          "enum": [
                            "extra-product",
                            "extra-option-group",
                            "extra-room"
                          ],
                          "type": "string"
                        },
                        "maxItems": 20,
                        "type": "array"
                      },
                      "mode": {
                        "const": "structured"
                      },
                      "notes": {
                        "maxLength": 1000,
                        "type": "string"
                      },
                      "piece": {
                        "enum": [
                          "PZ-01",
                          "PZ-02",
                          "PZ-03",
                          "PZ-04",
                          "PZ-00"
                        ],
                        "type": "string"
                      },
                      "quantity": {
                        "description": "Products, rooms or bugs.",
                        "maximum": 20,
                        "minimum": 1,
                        "type": "integer"
                      },
                      "tier": {
                        "description": "Omit to get the smallest tier that covers quantity.",
                        "enum": [
                          "starter",
                          "standard",
                          "advanced"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "mode",
                      "piece"
                    ],
                    "title": "Structured",
                    "type": "object"
                  },
                  {
                    "additionalProperties": false,
                    "properties": {
                      "message": {
                        "maxLength": 600,
                        "type": "string"
                      },
                      "mode": {
                        "const": "chat"
                      },
                      "session": {
                        "pattern": "^[A-Za-z0-9_-]{8,64}$",
                        "type": "string"
                      },
                      "turnstile": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "mode",
                      "session",
                      "message"
                    ],
                    "title": "Chat",
                    "type": "object"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "alternatives": {
                      "description": "When quantity exceeds a tier, a cheaper option: the lowest tier plus additional-unit extras (fewer inclusions per product). Empty otherwise.",
                      "items": {
                        "properties": {
                          "days": {
                            "description": "Delivery time in days.",
                            "type": "integer"
                          },
                          "extras": {
                            "items": {
                              "properties": {
                                "days": {
                                  "type": "integer"
                                },
                                "id": {
                                  "type": "string"
                                },
                                "name": {
                                  "type": "string"
                                },
                                "price_usd": {
                                  "type": "integer"
                                },
                                "qty": {
                                  "type": "integer"
                                }
                              },
                              "type": "object"
                            },
                            "type": "array"
                          },
                          "includes": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "label": {
                            "description": "Short label, present only when alternatives is not empty.",
                            "type": "string"
                          },
                          "piece": {
                            "enum": [
                              "PZ-01",
                              "PZ-02",
                              "PZ-03",
                              "PZ-04"
                            ],
                            "type": "string"
                          },
                          "piece_name": {
                            "type": "string"
                          },
                          "price_usd": {
                            "description": "Total in USD, computed from the catalog.",
                            "type": "integer"
                          },
                          "quantity": {
                            "type": "integer"
                          },
                          "revisions": {
                            "type": "integer"
                          },
                          "tier": {
                            "enum": [
                              "starter",
                              "standard",
                              "advanced"
                            ],
                            "type": "string"
                          }
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "done": {
                      "type": "boolean"
                    },
                    "needs": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "quote": {
                      "oneOf": [
                        {
                          "properties": {
                            "days": {
                              "description": "Delivery time in days.",
                              "type": "integer"
                            },
                            "extras": {
                              "items": {
                                "properties": {
                                  "days": {
                                    "type": "integer"
                                  },
                                  "id": {
                                    "type": "string"
                                  },
                                  "name": {
                                    "type": "string"
                                  },
                                  "price_usd": {
                                    "type": "integer"
                                  },
                                  "qty": {
                                    "type": "integer"
                                  }
                                },
                                "type": "object"
                              },
                              "type": "array"
                            },
                            "includes": {
                              "items": {
                                "type": "string"
                              },
                              "type": "array"
                            },
                            "label": {
                              "description": "Short label, present only when alternatives is not empty.",
                              "type": "string"
                            },
                            "piece": {
                              "enum": [
                                "PZ-01",
                                "PZ-02",
                                "PZ-03",
                                "PZ-04"
                              ],
                              "type": "string"
                            },
                            "piece_name": {
                              "type": "string"
                            },
                            "price_usd": {
                              "description": "Total in USD, computed from the catalog.",
                              "type": "integer"
                            },
                            "quantity": {
                              "type": "integer"
                            },
                            "revisions": {
                              "type": "integer"
                            },
                            "tier": {
                              "enum": [
                                "starter",
                                "standard",
                                "advanced"
                              ],
                              "type": "string"
                            }
                          },
                          "type": "object"
                        },
                        {
                          "type": "null"
                        }
                      ]
                    },
                    "ref": {
                      "description": "Lead reference, only when contact was sent.",
                      "type": "string"
                    },
                    "reply": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "reply",
                    "quote",
                    "alternatives",
                    "needs",
                    "done"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Quote or follow-up question"
          },
          "400": {
            "description": "Invalid request"
          },
          "429": {
            "description": "Rate limited"
          }
        },
        "summary": "Price a catalog piece (structured mode, for agents) or talk to the quoter (chat mode, for humans on the site)."
      }
    },
    "/catalog.json": {
      "get": {
        "operationId": "getCatalog",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Catalog"
          }
        },
        "summary": "The full catalog: pieces, tiers, prices, days, extras."
      }
    }
  },
  "servers": [
    {
      "url": "https://pieza.studio"
    }
  ]
}