{
  "openapi": "3.1.0",
  "info": {
    "title": "BluePeak Lead API",
    "version": "1.0.0",
    "description": "Public API of BluePeak (bluepeak.pt), a licensed construction and renovation company in Portugal. Submits quote requests (pedidos de orçamento) that reach the BluePeak sales team. Versioning: URL path versioning (current: /api/v1/). Unversioned /api/* paths are stable aliases of v1. Deprecation policy: breaking changes only in a new version path; deprecated versions are announced at least 6 months in advance via a Sunset header on responses and a notice at https://bluepeak.pt/docs/api/. Rate limit: 60 requests/minute per client (RateLimit-* headers on every response; fair use).",
    "contact": {
      "url": "https://bluepeak.pt/contactos/"
    }
  },
  "servers": [
    {
      "url": "https://bluepeak.pt"
    }
  ],
  "paths": {
    "/api/v1/lead": {
      "post": {
        "operationId": "submitQuoteRequest",
        "summary": "Submit a quote request to BluePeak",
        "description": "Sends a construction/renovation quote request to BluePeak's CRM. No authentication required. Only submit on behalf of a real person who has asked to be contacted by BluePeak. Versioned path: /api/v1/lead (the unversioned /api/lead remains a stable alias).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/QuoteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead accepted",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "405": {
            "description": "Method not allowed (POST only)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "502": {
            "description": "Upstream CRM delivery failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1": {
      "get": {
        "operationId": "getApiIndex",
        "summary": "API discovery document",
        "description": "Returns a machine-readable index of the BluePeak API: available endpoints, links to the OpenAPI spec, documentation, agent skills and llms.txt.",
        "responses": {
          "200": {
            "description": "Discovery document",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "API name"
                    },
                    "description": {
                      "type": "string",
                      "description": "What this API is for"
                    },
                    "version": {
                      "type": "string"
                    },
                    "openapi": {
                      "type": "string",
                      "format": "uri",
                      "description": "URL of this OpenAPI spec"
                    },
                    "documentation": {
                      "type": "string",
                      "format": "uri"
                    },
                    "endpoints": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "method": {
                            "type": "string"
                          },
                          "path": {
                            "type": "string"
                          },
                          "operationId": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  },
                  "required": [
                    "name",
                    "description",
                    "version",
                    "endpoints"
                  ],
                  "additionalProperties": true
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "format",
            "in": "query",
            "required": false,
            "description": "Response format. Only 'json' is supported.",
            "schema": {
              "type": "string",
              "enum": [
                "json"
              ],
              "default": "json"
            }
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "QuoteRequest": {
        "type": "object",
        "required": [
          "nome",
          "apelido",
          "telefone",
          "email"
        ],
        "properties": {
          "nome": {
            "type": "string",
            "description": "First name"
          },
          "apelido": {
            "type": "string",
            "description": "Last name"
          },
          "telefone": {
            "type": "string",
            "description": "Phone number, Portuguese format preferred"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "distrito": {
            "type": "string",
            "description": "District in Portugal where the works will take place",
            "enum": [
              "Aveiro",
              "Braga",
              "Coimbra",
              "Évora",
              "Faro",
              "Lisboa",
              "Porto",
              "Santarém",
              "Setúbal",
              "Viana do Castelo"
            ]
          },
          "tipo": {
            "type": "string",
            "description": "Type of service requested",
            "enum": [
              "Construção",
              "Remodelação",
              "Decoração/Mobiliário",
              "Reparação",
              "Arquitetura",
              "Pedido de Emprego",
              "Outros"
            ]
          },
          "mensagem": {
            "type": "string",
            "description": "Free-text description of the project"
          }
        }
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Human-readable error message"
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}