{
  "openapi": "3.1.0",
  "info": { "title": "GenXForm API", "version": "0.2.0", "description": "Prompt-to-Form, Form Studio, publishing, and responses." },
  "paths": {
    "/health": { "get": { "summary": "Return minimal application liveness and version metadata", "responses": { "200": { "description": "Application is serving requests" } } } },
    "/ready": { "get": { "summary": "Check application and D1 readiness", "responses": { "200": { "description": "Application dependencies are ready" }, "503": { "description": "A required dependency is unavailable" } } } },
    "/api/dashboard": { "get": { "summary": "Get tenant-scoped operational dashboard metrics, funnel, recent forms, and audited activity", "responses": { "200": { "description": "Dashboard snapshot" }, "401": { "description": "Not authorized" }, "403": { "description": "Insufficient workspace access" } } } },
    "/api/audit": { "get": { "summary": "List active-workspace audit events with opaque cursor pagination", "responses": { "200": { "description": "Paginated audit events" }, "400": { "description": "Invalid cursor" }, "403": { "description": "Insufficient workspace access" } } } },
    "/api/workspaces/{id}": { "patch": { "summary": "Update workspace name, URL slug, and description", "responses": { "200": { "description": "Workspace settings persisted" }, "403": { "description": "Insufficient workspace access" }, "409": { "description": "Workspace slug conflict" }, "422": { "description": "Invalid workspace settings" } } } },
    "/api/workspace-members": { "get": { "summary": "List active-workspace members and viewer capabilities", "responses": { "200": { "description": "Workspace members" }, "403": { "description": "Insufficient workspace access" } } }, "post": { "summary": "Create a single-use workspace invitation and return its developer link once", "responses": { "201": { "description": "Invitation created" }, "409": { "description": "Member already exists" }, "422": { "description": "Invalid email or role" } } } },
    "/api/workspace-members/{userId}": { "patch": { "summary": "Change a workspace member role", "responses": { "200": { "description": "Role updated" }, "403": { "description": "Protected member or insufficient access" } } }, "delete": { "summary": "Remove a workspace member", "responses": { "200": { "description": "Member removed" }, "403": { "description": "Protected member or insufficient access" } } } },
    "/api/workspace-invitations": { "get": { "summary": "List pending and expired active-workspace invitations without tokens", "responses": { "200": { "description": "Workspace invitations" } } } },
    "/api/workspace-invitations/{id}": { "delete": { "summary": "Revoke a pending workspace invitation", "responses": { "200": { "description": "Invitation revoked" }, "404": { "description": "Pending invitation not found" } } } },
    "/api/public/invitations/{token}": { "get": { "summary": "Inspect a single-use invitation with masked recipient data", "responses": { "200": { "description": "Invitation summary" }, "404": { "description": "Invalid invitation" } } }, "post": { "summary": "Accept an invitation for the exact authenticated email", "responses": { "200": { "description": "Invitation accepted and workspace activated" }, "403": { "description": "Identity email mismatch" }, "409": { "description": "Invitation already used or revoked" }, "410": { "description": "Invitation expired" } } } },
    "/api/ai/create": { "post": { "summary": "Generate a complete form as structured operations", "responses": { "200": { "description": "Form plan, operations, and validated schema" }, "401": { "description": "Not authorized" }, "422": { "description": "Prompt or generated output rejected" } } } },
    "/api/ai/generate": { "post": { "summary": "Edit the current form through structured operations", "responses": { "200": { "description": "Operation proposal and preview schema" }, "401": { "description": "Not authorized" }, "422": { "description": "Validation failed" } } } },
    "/api/forms": { "get": { "summary": "List workspace forms", "responses": { "200": { "description": "Forms" }, "401": { "description": "Not authorized" } } }, "post": { "summary": "Create a validated form", "responses": { "201": { "description": "Created" }, "422": { "description": "Validation failed" } } } },
    "/api/forms/{id}": { "get": { "summary": "Get a form", "parameters": [{ "name": "id", "in": "path", "required": true, "schema": { "type": "string" } }], "responses": { "200": { "description": "Form" } } }, "patch": { "summary": "Create a new draft version", "responses": { "200": { "description": "Saved" }, "409": { "description": "Version conflict" } } } },
    "/api/forms/{id}/publish": { "post": { "summary": "Publish the current immutable version", "responses": { "200": { "description": "Published" } } } },
    "/api/forms/{id}/export": { "get": { "summary": "Export a form as schema or generated code", "parameters": [{ "name": "format", "in": "query", "schema": { "type": "string", "enum": ["json", "gxform", "yaml", "markdown", "mermaid", "react", "next", "typescript", "zod"] } }], "responses": { "200": { "description": "Downloadable export" }, "400": { "description": "Unsupported format" } } } },
    "/api/submissions/{id}": { "get": { "summary": "Get one historical submission", "responses": { "200": { "description": "Submission and historical schema" } } }, "patch": { "summary": "Advance a submission through its audited lifecycle", "responses": { "200": { "description": "Status updated" }, "409": { "description": "Invalid lifecycle transition" }, "422": { "description": "Invalid status" } } } },
    "/api/public/forms/{slug}/submissions": { "post": { "summary": "Validate and submit a published form", "responses": { "201": { "description": "Submission created" }, "422": { "description": "Validation failed" } } } },
    "/api/interaction-requests": { "post": { "summary": "Request structured human input", "responses": { "201": { "description": "Interaction paused awaiting a human" } } } },
    "/api/interaction-requests/{id}/respond": { "post": { "summary": "Respond with a resume token", "responses": { "200": { "description": "Interaction completed" }, "403": { "description": "Invalid token" } } } }
  }
}
