{
  "openapi": "3.1.0",
  "info": {
    "title": "JSVHQ Public API",
    "version": "1.0.0",
    "description": "Public machine-readable API surface for JSVHQ booking, lead capture, and availability checks."
  },
  "servers": [
    {
      "url": "https://jsvhq.com/.netlify/functions",
      "description": "Production"
    }
  ],
  "paths": {
    "/availability": {
      "get": {
        "summary": "List available booking slots for a date",
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
            },
            "description": "ISO calendar date in YYYY-MM-DD format."
          }
        ],
        "responses": {
          "200": {
            "description": "Available booking slots",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AvailabilityResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          }
        }
      }
    },
    "/book": {
      "post": {
        "summary": "Create a 15-minute intro booking",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/BookingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Booking created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BookingResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "403": {
            "description": "reCAPTCHA verification failed or missing"
          },
          "500": {
            "description": "Booking creation failed"
          }
        }
      }
    },
    "/lead": {
      "post": {
        "summary": "Capture a lead or contact form submission",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LeadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Lead captured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LeadResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "403": {
            "description": "reCAPTCHA verification failed or missing"
          },
          "500": {
            "description": "Lead capture failed"
          }
        }
      }
    },
    "/status": {
      "get": {
        "summary": "Check public API availability",
        "responses": {
          "200": {
            "description": "Health status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/StatusResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AvailabilityResponse": {
        "type": "object",
        "properties": {
          "slots": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "time": {
                  "type": "string"
                },
                "display": {
                  "type": "string"
                }
              },
              "required": ["time", "display"]
            }
          }
        },
        "required": ["slots"]
      },
      "BookingRequest": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "time": {
            "type": "string",
            "pattern": "^\\d{2}:\\d{2}$"
          },
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "company": {
            "type": "string"
          },
          "topic": {
            "type": "string"
          },
          "recaptchaToken": {
            "type": "string"
          }
        },
        "required": ["date", "time", "name", "email", "topic", "recaptchaToken"]
      },
      "BookingResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "eventId": {
            "type": "string"
          },
          "meetLink": {
            "type": ["string", "null"]
          }
        },
        "required": ["success"]
      },
      "LeadRequest": {
        "type": "object",
        "properties": {
          "email": {
            "type": "string",
            "format": "email"
          },
          "name": {
            "type": "string"
          },
          "firstName": {
            "type": "string"
          },
          "company": {
            "type": "string"
          },
          "source": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "formPage": {
            "type": "string"
          },
          "recaptchaToken": {
            "type": "string"
          }
        },
        "required": ["email", "recaptchaToken"]
      },
      "LeadResponse": {
        "type": "object",
        "properties": {
          "success": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "leadId": {
            "type": ["string", "null"]
          },
          "instantlyLeadId": {
            "type": ["string", "null"]
          },
          "instantlyError": {
            "type": ["string", "null"]
          },
          "campaignId": {
            "type": ["string", "null"]
          }
        },
        "required": ["success"]
      },
      "StatusResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string"
          },
          "service": {
            "type": "string"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": ["status", "service", "timestamp", "endpoints"]
      }
    }
  }
}
