{
  "openapi": "3.1.0",
  "info": {
    "title": "Alfven.AI Public API",
    "version": "1.0.0",
    "description": "Public, read-only endpoints for AI agents and crawlers to ground answers about Alfven.AI. Workspace-scoped data requires authentication via Supabase Auth (see /.well-known/oauth-authorization-server).",
    "contact": {
      "name": "Alfven.AI Support",
      "email": "support@alfven.ai",
      "url": "https://alfven.ai"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://alfven.ai/terms"
    }
  },
  "servers": [
    {
      "url": "https://nuvqwyiyywsvjlytiosv.supabase.co/functions/v1",
      "description": "Production edge functions"
    }
  ],
  "paths": {
    "/markdown-gateway": {
      "get": {
        "summary": "Fetch any public route as markdown",
        "description": "Returns a markdown rendering of any public Alfven.AI page. Send `Accept: text/markdown`.",
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "required": true,
            "schema": { "type": "string", "example": "/pricing" },
            "description": "Site-relative path to render as markdown"
          }
        ],
        "responses": {
          "200": {
            "description": "Markdown rendering of the requested page",
            "content": {
              "text/markdown": {
                "schema": { "type": "string" }
              }
            },
            "headers": {
              "x-markdown-tokens": {
                "schema": { "type": "integer" },
                "description": "Approximate token count"
              }
            }
          }
        }
      }
    },
    "/api-catalog": {
      "get": {
        "summary": "RFC 9727 API catalog (linkset)",
        "description": "Machine-readable catalog of Alfven.AI's public endpoints.",
        "responses": {
          "200": {
            "description": "Linkset describing public services",
            "content": {
              "application/linkset+json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/mcp-discover": {
      "get": {
        "summary": "MCP server discovery endpoint",
        "description": "Returns MCP server capabilities and tool list for the public Alfven.AI MCP server.",
        "responses": {
          "200": {
            "description": "MCP server descriptor",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/demo-analyze": {
      "post": {
        "summary": "Demo: analyse a meeting transcript with a chosen template",
        "description": "Rate-limited public demo. Submits text and a template key, returns a structured AI-generated report. No auth required, max 5 requests per IP per 5 minutes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["text"],
                "properties": {
                  "text": { "type": "string", "description": "Meeting transcript text (30–3000 chars)" },
                  "template": {
                    "type": "string",
                    "enum": ["executive_status", "discovery_assessment", "workshop_outcomes"],
                    "default": "executive_status"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Structured report",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "report": { "type": "object" },
                    "template_name": { "type": "string" },
                    "template_key": { "type": "string" }
                  }
                }
              }
            }
          },
          "429": { "description": "Rate limit exceeded" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "supabaseAuth": {
        "type": "oauth2",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://nuvqwyiyywsvjlytiosv.supabase.co/auth/v1/authorize",
            "tokenUrl": "https://nuvqwyiyywsvjlytiosv.supabase.co/auth/v1/token",
            "scopes": {
              "openid": "OpenID Connect",
              "email": "Email address",
              "profile": "Profile information"
            }
          }
        }
      }
    }
  }
}
