{
  "openapi": "3.1.0",
  "info": {
    "title": "Thetawaves AI API",
    "version": "1.0.0",
    "description": "Public REST API for the Thetawaves AI AEO scanner. Create website scans and retrieve AI-readiness reports.",
    "contact": {
      "name": "Thetawaves AI Support",
      "email": "support@thetawaves.ai"
    }
  },
  "servers": [
    {
      "url": "https://thetawaves.ai"
    }
  ],
  "paths": {
    "/api/scans": {
      "post": {
        "operationId": "createScan",
        "summary": "Create a new website scan",
        "description": "Submits a URL for AEO / AI-readiness analysis. Returns the created scan record; results are populated asynchronously (poll GET /api/scans/{id} until status is 'completed').",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "url"
                ],
                "properties": {
                  "url": {
                    "type": "string",
                    "format": "uri",
                    "description": "The website URL to analyze."
                  },
                  "industry": {
                    "type": "string",
                    "description": "Optional industry/category slug for AI visibility analysis."
                  },
                  "recaptchaToken": {
                    "type": "string",
                    "description": "reCAPTCHA token (required unless a valid agency code is supplied)."
                  },
                  "agencyCode": {
                    "type": "string",
                    "description": "Optional agency code to consume a scan credit and bypass reCAPTCHA."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Scan created."
          },
          "400": {
            "description": "Validation error."
          }
        }
      }
    },
    "/api/scans/{id}": {
      "get": {
        "operationId": "getScan",
        "summary": "Retrieve a scan and its analysis",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Numeric scan identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "The scan record with status and analysis."
          },
          "404": {
            "description": "Scan not found."
          }
        }
      }
    },
    "/api/categories": {
      "get": {
        "operationId": "listCategories",
        "summary": "List industry categories for AI visibility analysis",
        "responses": {
          "200": {
            "description": "Array of categories."
          }
        }
      }
    },
    "/api/categories/{id}/prompts": {
      "get": {
        "operationId": "listCategoryPrompts",
        "summary": "List the AI search prompts for a category",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "minimum": 1
            },
            "description": "Numeric category identifier."
          }
        ],
        "responses": {
          "200": {
            "description": "Array of prompts."
          }
        }
      }
    }
  }
}