{
  "openapi": "3.1.0",
  "info": {
    "title": "Viky's Cleaning Lead Capture",
    "version": "1.0.0",
    "description": "Public description of the lead capture form used by Viky's Cleaning & Home Solutions. The live form is protected by Cloudflare Turnstile and posts to the configured Apps Script endpoint."
  },
  "servers": [
    {
      "url": "https://script.google.com/macros/s/AKfycbwcVxIQvDu5fdbKAETtcyBcCsETnVvAEEdue1rzv6MYflVsCVGnlJUEb4gX-mhWxdahYQ/exec",
      "description": "Google Apps Script lead intake endpoint"
    }
  ],
  "paths": {
    "/": {
      "post": {
        "operationId": "submitLead",
        "summary": "Submit an estimate or contact lead",
        "description": "Submits a customer lead from the estimate or contact form. The field website is a honeypot and must be left empty by real clients.",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/LeadPayload"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/LeadPayload"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead accepted by Apps Script",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Validation error or missing verification token"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LeadPayload": {
        "type": "object",
        "required": [
          "form_type",
          "name",
          "phone",
          "service",
          "method",
          "clean_type",
          "floor_area",
          "zip_code",
          "lang",
          "cf-turnstile-response"
        ],
        "properties": {
          "form_type": {
            "type": "string",
            "enum": ["estimate", "contact"]
          },
          "name": {
            "type": "string",
            "minLength": 2,
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email",
            "description": "Required when method is email."
          },
          "phone": {
            "type": "string",
            "minLength": 7,
            "maxLength": 40
          },
          "service": {
            "type": "string",
            "enum": [
              "residential-cleaning",
              "commercial-cleaning",
              "professional-organization",
              "carpet-washing",
              "office-corporate-cleaning",
              "move-in-move-out-cleaning",
              "post-construction-cleaning",
              "interior-exterior-painting",
              "other"
            ]
          },
          "method": {
            "type": "string",
            "enum": ["phone", "text", "email"]
          },
          "clean_type": {
            "type": "string",
            "enum": [
              "standard-cleaning",
              "deep-cleaning",
              "move-in-move-out",
              "recurring-service",
              "one-time-project",
              "other"
            ]
          },
          "floor_area": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80,
            "examples": ["1590 sq ft"]
          },
          "zip_code": {
            "type": "string",
            "pattern": "^[0-9]{5}(-[0-9]{4})?$"
          },
          "message": {
            "type": "string",
            "maxLength": 2000
          },
          "lang": {
            "type": "string",
            "enum": ["en", "es"]
          },
          "page_url": {
            "type": "string",
            "format": "uri"
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "user_agent": {
            "type": "string"
          },
          "website": {
            "type": "string",
            "description": "Honeypot field. Leave empty."
          },
          "cf-turnstile-response": {
            "type": "string",
            "description": "Cloudflare Turnstile token generated by the browser form."
          }
        }
      }
    }
  }
}
