{
  "openapi": "3.1.0",
  "info": {
    "title": "XK Audit — AI Readiness & GEO Diagnostic API",
    "version": "1.0.0",
    "description": "API contract for submitting AI Readiness & GEO audit requests with Idempotency-Key support and RFC 9457 application/problem+json error responses.",
    "contact": {
      "name": "XK Audit",
      "url": "https://xk.fyi/",
      "email": "eqerimi@gmail.com"
    }
  },
  "servers": [
    {
      "url": "https://xk.fyi",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/v1/audits": {
      "post": {
        "operationId": "createAuditRequest",
        "summary": "Submit a website for an AI Readiness & GEO audit",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "schema": { "type": "string", "format": "uuid" },
            "description": "Unique key preventing duplicate audit submissions on retry."
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditRequestInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Audit request accepted and queued",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/AuditRequestCreated" }
              }
            }
          },
          "422": {
            "description": "Validation error (RFC 9457 Problem Details)",
            "content": {
              "application/problem+json": {
                "schema": { "$ref": "#/components/schemas/ProblemDetails" }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AuditRequestInput": {
        "type": "object",
        "required": ["websiteUrl", "email", "businessType", "primaryGoal"],
        "properties": {
          "websiteUrl": { "type": "string", "format": "uri" },
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "businessType": { "type": "string" },
          "primaryGoal": { "type": "string" },
          "notes": { "type": "string" }
        }
      },
      "AuditRequestCreated": {
        "type": "object",
        "required": ["id", "status", "createdAt"],
        "properties": {
          "id": { "type": "string" },
          "status": { "type": "string", "enum": ["PENDING", "IN_PROGRESS", "COMPLETED"] },
          "createdAt": { "type": "integer" }
        }
      },
      "ProblemDetails": {
        "type": "object",
        "required": ["type", "title", "status"],
        "properties": {
          "type": { "type": "string", "format": "uri" },
          "title": { "type": "string" },
          "status": { "type": "integer" },
          "detail": { "type": "string" },
          "instance": { "type": "string" }
        }
      }
    }
  }
}
