{
  "openapi": "3.1.0",
  "info": {
    "title": "Julieta Pizarro — Contact API",
    "version": "1.0.0",
    "description": "Public API for julietapizarro.com. Currently exposes a single endpoint that lets visitors (or agents acting on their behalf) send a contact inquiry to Julieta Pizarro, singing teacher and vocal pedagogue.",
    "contact": {
      "name": "Julieta Pizarro",
      "url": "https://julietapizarro.com",
      "email": "info@julietapizarro.com"
    }
  },
  "servers": [
    {
      "url": "https://julietapizarro.com",
      "description": "Production (Cloudflare Pages)"
    }
  ],
  "paths": {
    "/api/contact": {
      "post": {
        "operationId": "submitContactForm",
        "summary": "Send a contact inquiry",
        "description": "Sends a contact message to Julieta Pizarro via email. Use this when a user wants to book a trial singing lesson, ask about availability, pricing, or the Functional Voice Method. The message is delivered to info@julietapizarro.com with the sender's email as reply-to.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["name", "email", "message"],
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 200,
                    "description": "Full name of the person sending the inquiry."
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 200,
                    "description": "Email address for the reply. Must match the pattern .+@.+\\..+"
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 5000,
                    "description": "The inquiry text. Mention goals, experience level, preferred language (Spanish/English), and whether the student wants online or in-person lessons."
                  },
                  "cf-turnstile-response": {
                    "type": "string",
                    "description": "Cloudflare Turnstile CAPTCHA token. Optional when calling from a server-side agent; required when submitting from the browser form."
                  }
                },
                "additionalProperties": false
              },
              "example": {
                "name": "María García",
                "email": "maria@example.com",
                "message": "Hola Julieta, me gustaría probar una clase de canto online. Soy principiante y me interesa el método funcional."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Message sent successfully.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "ok": { "type": "boolean", "const": true }
                  },
                  "required": ["ok"]
                }
              }
            }
          },
          "400": {
            "description": "Validation failed — missing or invalid name, email, or message.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "examples": {
                  "invalid": {
                    "value": { "ok": false, "error": "invalid" }
                  },
                  "bad_request": {
                    "value": { "ok": false, "error": "bad_request" }
                  }
                }
              }
            }
          },
          "403": {
            "description": "Cloudflare Turnstile CAPTCHA verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": { "ok": false, "error": "captcha_failed" }
              }
            }
          },
          "502": {
            "description": "Upstream email delivery failed (Resend API error).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": { "ok": false, "error": "send_failed" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean", "const": false },
          "error": {
            "type": "string",
            "enum": ["bad_request", "invalid", "captcha_failed", "send_failed"],
            "description": "Machine-readable error code."
          }
        },
        "required": ["ok", "error"]
      }
    }
  }
}
