{
  "openapi": "3.1.0",
  "info": {
    "title": "SayNO Public API",
    "version": "1.0.0",
    "description": "Public REST API for SayNO — the uncompromising commitment system. Currently exposes the waitlist endpoint so agents and developers can programmatically register users for early access.\n\nBase URL: https://saynoapp.imbtm.workers.dev\n\n## Deprecation Policy\n\nAll endpoints are versioned via the URL path (e.g. `/v1/`). If an API version is scheduled for deprecation, we will provide at least 6 months notice via the `Deprecation` and `Sunset` HTTP headers. Agents should monitor these headers and transition to newer versions when prompted.\n\nAll requests and responses use `application/json`. Errors always return a structured JSON body.",
    "contact": {
      "name": "SayNO Support",
      "url": "https://saynoapp.imbtm.workers.dev/contact",
      "email": "hello@saynoapp.imbtm.workers.dev"
    },
    "license": {
      "name": "MIT",
      "url": "https://opensource.org/licenses/MIT"
    }
  },
  "servers": [
    {
      "url": "https://saynoapp.imbtm.workers.dev",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "waitlist",
      "description": "Operations for managing the SayNO early-access waitlist."
    },
    {
      "name": "meta",
      "description": "API metadata and health endpoints."
    }
  ],
  "paths": {
    "/v1/waitlist": {
      "post": {
        "operationId": "joinWaitlist",
        "summary": "Join the SayNO early-access waitlist",
        "description": "Registers a person on the SayNO waitlist. Provide at minimum a `name`. If `email` is supplied the server deduplicates by email so the same address is never stored twice. On success returns the Firestore document ID.",
        "tags": ["waitlist"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WaitlistRequest"
              },
              "examples": {
                "nameOnly": {
                  "summary": "Name-only registration",
                  "value": { "name": "Alex Johnson" }
                },
                "withEmail": {
                  "summary": "Registration with email",
                  "value": { "name": "Alex Johnson", "email": "alex@example.com" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successfully added to (or already on) the waitlist.",
            "headers": {
              "X-Request-Id": {
                "description": "Unique request identifier for tracing.",
                "schema": { "type": "string" }
              }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WaitlistResponse" }
              }
            }
          },
          "400": {
            "description": "Invalid request — `name` is missing or malformed.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "405": {
            "description": "Method not allowed — use POST.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          },
          "500": {
            "description": "Internal server error.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/v1/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "API health check",
        "description": "Returns a 200 OK with the current API version and status. Agents should use this to verify connectivity before calling other endpoints.",
        "tags": ["meta"],
        "responses": {
          "200": {
            "description": "API is healthy.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/HealthResponse" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "WaitlistRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "description": "Full name of the person joining the waitlist.",
            "example": "Alex Johnson"
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 254,
            "description": "Optional email address. Used for deduplication and to notify the user when early access opens.",
            "example": "alex@example.com"
          }
        }
      },
      "WaitlistResponse": {
        "type": "object",
        "required": ["success", "id", "alreadyRegistered"],
        "properties": {
          "success": {
            "type": "boolean",
            "description": "Always `true` on a 200 response.",
            "example": true
          },
          "id": {
            "type": "string",
            "description": "The Firestore document ID for the waitlist record. Useful for idempotency checks.",
            "example": "Xk9mN2pQrLvT8wYz"
          },
          "alreadyRegistered": {
            "type": "boolean",
            "description": "Set to `true` if this email was already on the waitlist. The existing record is returned unchanged.",
            "example": false
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "required": ["status", "version", "timestamp"],
        "properties": {
          "status": {
            "type": "string",
            "enum": ["ok"],
            "example": "ok"
          },
          "version": {
            "type": "string",
            "description": "API version string.",
            "example": "1.0.0"
          },
          "timestamp": {
            "type": "string",
            "format": "date-time",
            "description": "ISO 8601 UTC timestamp of the response.",
            "example": "2026-08-24T00:00:00Z"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["code", "message"],
            "properties": {
              "code": {
                "type": "string",
                "description": "Machine-readable error code.",
                "enum": [
                  "BAD_REQUEST",
                  "METHOD_NOT_ALLOWED",
                  "NOT_FOUND",
                  "CONFLICT",
                  "INTERNAL_ERROR"
                ],
                "example": "BAD_REQUEST"
              },
              "message": {
                "type": "string",
                "description": "Human-readable error description.",
                "example": "The `name` field is required."
              },
              "docs": {
                "type": "string",
                "format": "uri",
                "description": "URL to relevant documentation or the OpenAPI spec.",
                "example": "https://saynoapp.imbtm.workers.dev/openapi.json"
              }
            }
          }
        }
      }
    }
  }
}
