{
  "openapi": "3.1.0",
  "info": {
    "title": "Lacsa Laboratorios Public API",
    "version": "1.0.0",
    "summary": "Submit a manufacturing quote request and resolve visitor geo.",
    "description": "The public API for Lacsa Laboratorios, a full-service nutraceutical and dietary-supplement contract manufacturer. Use it to submit a lead/quote request (the primary action a customer or agent takes) and to resolve a visitor's country for language selection. No authentication is required for these public endpoints; do not send secrets. For a human-readable guide see /developers, and for a site guide see /llms.txt.",
    "contact": {
      "name": "Lacsa Laboratorios",
      "email": "contact@lacsalaboratorios.com",
      "url": "https://lacsalaboratorios.com"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://lacsalaboratorios.com/privacy"
    }
  },
  "servers": [
    {
      "url": "https://lacsalaboratorios.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "Developer documentation",
    "url": "https://lacsalaboratorios.com/developers"
  },
  "tags": [
    {
      "name": "Leads",
      "description": "Submit and manage manufacturing quote requests."
    },
    {
      "name": "Geo",
      "description": "Visitor country resolution for language selection."
    }
  ],
  "paths": {
    "/api/leads": {
      "post": {
        "operationId": "submitLead",
        "tags": [
          "Leads"
        ],
        "summary": "Submit a manufacturing quote / contact request",
        "description": "Create a new lead so a Lacsa specialist can respond with a quote. Use this when a user wants to request a quote, start a private-label or white-label project, or contact Lacsa about manufacturing supplements, patches, smart foods, or essential oils. A valid email plus at least a name or a message is required. Returns 200 with { ok: true } on success and a structured JSON error otherwise.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              },
              "examples": {
                "quote": {
                  "summary": "A private-label supplement quote request",
                  "value": {
                    "name": "Jordan Rivera",
                    "company": "Peak Nutrition Co.",
                    "email": "jordan@peaknutrition.example",
                    "phone": "+1 555 010 2000",
                    "interest": "Private-label capsules",
                    "message": "We need 10,000 units of a magnesium glycinate capsule. Timeline and pricing?"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadSuccess"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed (invalid JSON or missing required fields).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "500": {
            "description": "Server error while storing the lead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/api/geo": {
      "get": {
        "operationId": "resolveVisitorGeo",
        "tags": [
          "Geo"
        ],
        "summary": "Resolve the visitor's country",
        "description": "Return the visitor's 2-letter ISO country code, used for first-visit language auto-selection. Resolution order: edge geo header, then GPS coordinates (lat/lng) reverse-geocoded, then IP geolocation. Never throws; an unknown result returns { countryCode: null, source: \"none\" }.",
        "parameters": [
          {
            "name": "lat",
            "in": "query",
            "required": false,
            "description": "Optional visitor latitude for GPS reverse geocoding.",
            "schema": {
              "type": "number",
              "format": "double",
              "minimum": -90,
              "maximum": 90
            }
          },
          {
            "name": "lng",
            "in": "query",
            "required": false,
            "description": "Optional visitor longitude for GPS reverse geocoding.",
            "schema": {
              "type": "number",
              "format": "double",
              "minimum": -180,
              "maximum": 180
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved (or null) country.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GeoResult"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LeadRequest": {
        "type": "object",
        "description": "A manufacturing quote / contact request.",
        "required": [
          "email"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "description": "Full name of the requester.",
            "maxLength": 200
          },
          "company": {
            "type": "string",
            "description": "Company or brand name.",
            "maxLength": 200
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Contact email. Required and validated."
          },
          "phone": {
            "type": "string",
            "description": "Contact phone in international format.",
            "maxLength": 40
          },
          "interest": {
            "type": "string",
            "description": "Product or capability of interest (e.g. 'Private-label capsules').",
            "maxLength": 200
          },
          "message": {
            "type": "string",
            "description": "Project details, volumes, and timeline.",
            "maxLength": 5000
          }
        }
      },
      "LeadSuccess": {
        "type": "object",
        "required": [
          "ok"
        ],
        "additionalProperties": false,
        "properties": {
          "ok": {
            "type": "boolean",
            "const": true
          }
        }
      },
      "GeoResult": {
        "type": "object",
        "required": [
          "countryCode",
          "source"
        ],
        "additionalProperties": false,
        "properties": {
          "countryCode": {
            "type": [
              "string",
              "null"
            ],
            "description": "2-letter ISO-3166 country code (uppercase), or null if unknown.",
            "pattern": "^[A-Z]{2}$"
          },
          "source": {
            "type": "string",
            "description": "How the country was resolved.",
            "enum": [
              "edge",
              "gps",
              "ip",
              "none"
            ]
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Structured error response for LLM function-calling recovery.",
        "required": [
          "ok",
          "error"
        ],
        "additionalProperties": false,
        "properties": {
          "ok": {
            "type": "boolean",
            "const": false
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string",
                "description": "Stable machine-readable error code.",
                "enum": [
                  "invalid_json",
                  "missing_fields",
                  "method_not_allowed",
                  "server_error"
                ]
              },
              "message": {
                "type": "string",
                "description": "Human-readable explanation."
              },
              "hint": {
                "type": "string",
                "description": "How to fix the request."
              }
            }
          }
        }
      }
    }
  }
}