{
  "openapi": "3.0.3",
  "info": {
    "title": "Stradum API",
    "version": "0.1.0",
    "description": "Behavioral biometrics platform for passive identity verification. Analyzes how users type, move, and navigate to verify identity in real time."
  },
  "servers": [
    {
      "url": "https://api.stradum.com/api/v1",
      "description": "Production API"
    }
  ],
  "security": [],
  "tags": [
    { "name": "Auth", "description": "Authentication, registration, and user management" },
    { "name": "Sessions", "description": "Session lifecycle and event ingestion. A session is one meaningful form interaction (page load through submission or abandonment). Only sessions with 100+ behavioral events count toward your org quota." },
    { "name": "Identities", "description": "Identity management and linking" },
    { "name": "Accounts", "description": "Account listing" },
    { "name": "Analysis", "description": "Risk scoring and behavioral analysis" },
    { "name": "Forms", "description": "Form configuration and field mapping" },
    { "name": "Dashboard", "description": "Dashboard and overview endpoints" },
    { "name": "Webhooks", "description": "Webhook configuration" },
    { "name": "Billing", "description": "Subscription and billing management" },
    { "name": "Waitlist", "description": "Early access waitlist signup" }
  ],
  "paths": {
    "/auth/register": {
      "post": {
        "tags": ["Auth"],
        "summary": "Create organization and owner",
        "operationId": "authRegister",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["org_name", "email", "password"],
                "properties": {
                  "org_name": { "type": "string", "minLength": 1, "maxLength": 200 },
                  "email": { "type": "string", "format": "email", "minLength": 3, "maxLength": 255 },
                  "password": { "type": "string", "format": "password", "minLength": 8, "maxLength": 128 }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Organization and owner created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RegisterResponse"
                }
              }
            }
          },
          "422": { "$ref": "#/components/responses/ValidationError" }
        }
      }
    },
    "/auth/login": {
      "post": {
        "tags": ["Auth"],
        "summary": "Login",
        "operationId": "authLogin",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": { "type": "string", "format": "email" },
                  "password": { "type": "string", "format": "password" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Login successful",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/auth/me": {
      "get": {
        "tags": ["Auth"],
        "summary": "Get current user",
        "operationId": "authMe",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "Current user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/auth/keys": {
      "post": {
        "tags": ["Auth"],
        "summary": "Create key pair",
        "operationId": "authCreateKeys",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "label": { "type": "string", "default": "Default" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Key pair created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyCreateResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "get": {
        "tags": ["Auth"],
        "summary": "List keys",
        "operationId": "authListKeys",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "List of keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/ApiKeyResponse"
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/auth/keys/{key_id}": {
      "delete": {
        "tags": ["Auth"],
        "summary": "Revoke key",
        "operationId": "authRevokeKey",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "key_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "Key revoked" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/auth/users": {
      "post": {
        "tags": ["Auth"],
        "summary": "Invite user",
        "operationId": "authInviteUser",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["email", "password"],
                "properties": {
                  "email": { "type": "string", "format": "email", "minLength": 3, "maxLength": 255 },
                  "password": { "type": "string", "format": "password", "minLength": 8, "maxLength": 128 },
                  "role": { "type": "string", "default": "viewer" }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "User invited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "422": { "$ref": "#/components/responses/ValidationError" }
        }
      },
      "get": {
        "tags": ["Auth"],
        "summary": "List users",
        "operationId": "authListUsers",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "List of users",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UserResponse"
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/auth/users/{user_id}": {
      "patch": {
        "tags": ["Auth"],
        "summary": "Update user role",
        "operationId": "authUpdateUser",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["role"],
                "properties": {
                  "role": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "User updated" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "delete": {
        "tags": ["Auth"],
        "summary": "Remove user",
        "operationId": "authRemoveUser",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "user_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "User removed" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/sessions": {
      "post": {
        "tags": ["Sessions"],
        "summary": "Create session",
        "operationId": "sessionsCreate",
        "security": [{ "SdkKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Session created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/ValidationError" }
        }
      },
      "get": {
        "tags": ["Sessions"],
        "summary": "List sessions",
        "operationId": "sessionsList",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          { "name": "identity_id", "in": "query", "schema": { "type": "string" } },
          { "name": "account_id", "in": "query", "schema": { "type": "string" } },
          { "name": "status", "in": "query", "schema": { "type": "string" } },
          { "name": "match_status", "in": "query", "schema": { "$ref": "#/components/schemas/MatchStatus" } },
          { "name": "form_id", "in": "query", "schema": { "type": "string" } },
          { "name": "tag", "in": "query", "schema": { "type": "string" }, "description": "Filter by tag (comma-separated for multiple)" },
          { "name": "metadata_key", "in": "query", "schema": { "type": "string" }, "description": "Filter by metadata key" },
          { "name": "metadata_value", "in": "query", "schema": { "type": "string" }, "description": "Filter by metadata value (use with metadata_key)" },
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } },
          { "name": "page_size", "in": "query", "schema": { "type": "integer", "default": 50, "maximum": 200 } }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of sessions",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/sessions/events": {
      "post": {
        "tags": ["Sessions"],
        "summary": "Ingest events batch",
        "description": "Ingest a batch of behavioral events from the SDK. The session_id is provided in the request body, not the URL path.",
        "operationId": "sessionsIngestEvents",
        "security": [{ "SdkKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EventBatchRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Events accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EventBatchResponse"
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "402": { "$ref": "#/components/responses/PaymentRequired" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/ValidationError" },
          "429": {
            "description": "Session quota exceeded",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/sessions/{session_id}": {
      "get": {
        "tags": ["Sessions"],
        "summary": "Get session",
        "operationId": "sessionsGet",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Session details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "delete": {
        "tags": ["Sessions"],
        "summary": "Delete session",
        "operationId": "sessionsDelete",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "Session deleted" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/sessions/{session_id}/complete": {
      "post": {
        "tags": ["Sessions"],
        "summary": "Complete session",
        "operationId": "sessionsComplete",
        "security": [{ "SdkKey": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionCompleteRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Session completed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/sessions/{session_id}/metadata": {
      "post": {
        "tags": ["Sessions"],
        "summary": "Update session metadata",
        "description": "Merge metadata into an active session. Uses merge semantics — new keys are added, existing keys are overwritten.",
        "operationId": "sessionsUpdateMetadata",
        "security": [{ "SdkKey": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SessionMetadataRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Metadata updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/sessions/{session_id}/tags": {
      "patch": {
        "tags": ["Sessions"],
        "summary": "Update session tags",
        "operationId": "sessionsUpdateTags",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "add": { "type": "array", "items": { "type": "string" } },
                  "remove": { "type": "array", "items": { "type": "string" } }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tags updated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/sessions/{session_id}/timeline": {
      "get": {
        "tags": ["Sessions"],
        "summary": "Get session timeline",
        "operationId": "sessionsGetTimeline",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Session timeline",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TimelineResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/identities": {
      "post": {
        "tags": ["Identities"],
        "summary": "Create identity",
        "operationId": "identitiesCreate",
        "security": [{ "ServerKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IdentityCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Identity created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentityResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "get": {
        "tags": ["Identities"],
        "summary": "List identities",
        "operationId": "identitiesList",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          { "name": "account_id", "in": "query", "schema": { "type": "string" } },
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } },
          { "name": "page_size", "in": "query", "schema": { "type": "integer", "default": 50, "maximum": 200 } }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of identities",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentityListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/identities/link": {
      "post": {
        "tags": ["Identities"],
        "summary": "Link session to identity",
        "operationId": "identitiesLink",
        "security": [{ "ServerKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/IdentityLinkRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Session linked to identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SessionResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/identities/resolve": {
      "post": {
        "tags": ["Identities"],
        "summary": "Resolve identity by external_id",
        "description": "Find or create an identity by external ID. Used when the customer knows their internal user ID and wants to ensure a Stradum identity exists for linking.",
        "operationId": "identitiesResolve",
        "security": [{ "ServerKey": [] }],
        "parameters": [
          {
            "name": "external_id",
            "in": "query",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Resolved identity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentityResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/identities/{identity_id}": {
      "get": {
        "tags": ["Identities"],
        "summary": "Get identity",
        "operationId": "identitiesGet",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "identity_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Identity details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IdentityResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "delete": {
        "tags": ["Identities"],
        "summary": "Delete identity (GDPR/CCPA right-to-erasure)",
        "description": "Delete an identity and all associated behavioral data. Fulfills GDPR/CCPA right-to-erasure and FCRA adverse-action data deletion requests. Cascades to all sessions, behavioral profiles, and analysis results linked to this identity.",
        "operationId": "identitiesDelete",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "identity_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "Identity and all associated data deleted" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/accounts": {
      "get": {
        "tags": ["Accounts"],
        "summary": "List accounts",
        "operationId": "accountsList",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } },
          { "name": "page_size", "in": "query", "schema": { "type": "integer", "default": 50, "maximum": 200 } },
          { "name": "search", "in": "query", "schema": { "type": "string" }, "description": "Search by account name or ID" }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/analysis/trigger": {
      "post": {
        "tags": ["Analysis"],
        "summary": "Trigger analysis",
        "description": "Trigger behavioral analysis for a completed session. The session must be completed and linked to an identity. Returns the public score response.",
        "operationId": "analysisTrigger",
        "security": [{ "ServerKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnalysisTriggerRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Analysis result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScoreResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" },
          "422": { "$ref": "#/components/responses/ValidationError" },
          "500": {
            "description": "Analysis failed",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/analysis/session/{session_id}/score": {
      "get": {
        "tags": ["Analysis"],
        "summary": "Get session score",
        "operationId": "analysisGetScore",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Score result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScoreResponse"
                }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/analysis/session/{session_id}/detail": {
      "get": {
        "tags": ["Analysis"],
        "summary": "Get detailed analysis breakdown",
        "description": "Retrieve detailed analysis with per-category breakdowns. Returns 200 with status='not_run' when analysis has not been run yet.",
        "operationId": "analysisGetDetail",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Detailed analysis breakdown (or status='not_run' if analysis not yet triggered)",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/analysis/identity/{identity_id}/scores": {
      "get": {
        "tags": ["Analysis"],
        "summary": "Get all score results for an identity",
        "operationId": "analysisGetByIdentity",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "identity_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of score responses for the identity",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": { "$ref": "#/components/schemas/ScoreResponse" }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/analysis/{session_id}/resolve": {
      "patch": {
        "tags": ["Analysis"],
        "summary": "Resolve a review session",
        "description": "Resolve a review session as confirmed match or confirmed mismatch. Only sessions with match_status='review' can be resolved.",
        "operationId": "analysisResolve",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "session_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["resolution"],
                "properties": {
                  "resolution": {
                    "type": "string",
                    "enum": ["confirmed_match", "confirmed_mismatch"]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Session resolved",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "session_id": { "type": "string" },
                    "resolution": { "type": "string" },
                    "resolved_by": { "type": "string" },
                    "resolved_at": { "type": "string", "format": "date-time" },
                    "match_status": { "type": "string" },
                    "match_score": { "type": "number" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "409": {
            "description": "Session already resolved",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorResponse" }
              }
            }
          }
        }
      }
    },
    "/forms": {
      "post": {
        "tags": ["Forms"],
        "summary": "Create form",
        "operationId": "formsCreate",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FormCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Form created",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/FormResponse" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "422": { "$ref": "#/components/responses/ValidationError" }
        }
      },
      "get": {
        "tags": ["Forms"],
        "summary": "List forms",
        "operationId": "formsList",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "List of forms",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/FormListResponse" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/forms/{form_id}": {
      "get": {
        "tags": ["Forms"],
        "summary": "Get form",
        "operationId": "formsGet",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "form_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Form details",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/FormResponse" }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "patch": {
        "tags": ["Forms"],
        "summary": "Update form",
        "operationId": "formsUpdate",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "form_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/FormUpdateRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Form updated",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/FormResponse" }
              }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      },
      "delete": {
        "tags": ["Forms"],
        "summary": "Delete form",
        "operationId": "formsDelete",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "parameters": [
          {
            "name": "form_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "Form deleted" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/dashboard/auth-check": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "Check if auth required",
        "operationId": "dashboardAuthCheck",
        "security": [],
        "responses": {
          "200": {
            "description": "Auth check result",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/dashboard/overview": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "Dashboard overview",
        "operationId": "dashboardOverview",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "Dashboard overview data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DashboardOverview"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/dashboard/identity/{identity_id}/profile": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "Identity profile",
        "operationId": "dashboardIdentityProfile",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "identity_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Identity profile with session history",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/dashboard/alerts": {
      "get": {
        "tags": ["Dashboard"],
        "summary": "List alerts",
        "operationId": "dashboardAlerts",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          { "name": "page", "in": "query", "schema": { "type": "integer", "default": 1 } },
          { "name": "page_size", "in": "query", "schema": { "type": "integer", "default": 20 } }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of alerts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AlertListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/webhooks": {
      "post": {
        "tags": ["Webhooks"],
        "summary": "Create webhook",
        "operationId": "webhooksCreate",
        "security": [{ "ServerKey": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      },
      "get": {
        "tags": ["Webhooks"],
        "summary": "List webhooks",
        "operationId": "webhooksList",
        "security": [{ "ServerKey": [] }, { "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "List of webhooks",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookListResponse"
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/webhooks/{webhook_id}": {
      "delete": {
        "tags": ["Webhooks"],
        "summary": "Delete webhook",
        "operationId": "webhooksDelete",
        "security": [{ "BearerAuth": [] }],
        "parameters": [
          {
            "name": "webhook_id",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "204": { "description": "Webhook deleted" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/billing/plan": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get current plan info",
        "operationId": "billingGetPlan",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "Current plan details",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/billing/plan-config": {
      "get": {
        "tags": ["Billing"],
        "summary": "Get plan configuration",
        "operationId": "billingGetPlanConfig",
        "security": [],
        "responses": {
          "200": {
            "description": "Available plans and pricing",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          }
        }
      }
    },
    "/billing/create-checkout-session": {
      "post": {
        "tags": ["Billing"],
        "summary": "Create Stripe checkout session",
        "operationId": "billingCreateCheckout",
        "security": [{ "BearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "type": "object" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session URL",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/billing/create-portal-session": {
      "post": {
        "tags": ["Billing"],
        "summary": "Create Stripe billing portal session",
        "operationId": "billingCreatePortal",
        "security": [{ "BearerAuth": [] }],
        "responses": {
          "200": {
            "description": "Portal session URL",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/billing/webhook": {
      "post": {
        "tags": ["Billing"],
        "summary": "Stripe webhook handler",
        "operationId": "billingWebhook",
        "security": [],
        "description": "Receives Stripe webhook events for subscription management. Not called directly by integrators.",
        "responses": {
          "200": { "description": "Webhook processed" }
        }
      }
    },
    "/waitlist": {
      "post": {
        "tags": ["Waitlist"],
        "summary": "Submit waitlist signup",
        "description": "Submit a waitlist entry for early access. Idempotent on email — duplicate submissions return the same success message.",
        "operationId": "waitlistSubmit",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WaitlistRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Waitlist entry accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WaitlistResponse"
                }
              }
            }
          },
          "422": { "$ref": "#/components/responses/ValidationError" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "SdkKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Stradum-Key",
        "description": "Publishable key for SDK endpoints (pk_live_*)"
      },
      "ServerKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-Stradum-Key",
        "description": "Secret key for server endpoints (sk_live_*)"
      },
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "JWT token for dashboard endpoints"
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Bad request",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key / JWT token",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "PaymentRequired": {
        "description": "Trial limit reached or trial expired",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "Forbidden": {
        "description": "Key lacks permission for this endpoint",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      },
      "ValidationError": {
        "description": "Validation error",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/ErrorResponse" }
          }
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": { "type": "string" },
          "detail": { "type": "string" },
          "code": { "type": "string" }
        }
      },
      "MatchStatus": {
        "type": "string",
        "enum": ["match", "review", "mismatch"]
      },
      "SignalCategory": {
        "type": "string",
        "enum": ["expected", "atypical", "anomalous"]
      },
      "BaselineDepth": {
        "type": "string",
        "enum": ["none", "thin", "moderate", "strong"]
      },
      "RegisterResponse": {
        "type": "object",
        "properties": {
          "org_id": { "type": "string" },
          "user_id": { "type": "string" },
          "email": { "type": "string" },
          "publishable_key": { "type": "string", "description": "Full publishable key (pk_live_*), shown only once" },
          "secret_key": { "type": "string", "description": "Full secret key (sk_live_*), shown only once" }
        }
      },
      "LoginResponse": {
        "type": "object",
        "properties": {
          "token": { "type": "string" },
          "user_id": { "type": "string" },
          "org_id": { "type": "string" },
          "email": { "type": "string" },
          "role": { "type": "string" }
        }
      },
      "UserResponse": {
        "type": "object",
        "properties": {
          "user_id": { "type": "string" },
          "org_id": { "type": "string" },
          "email": { "type": "string" },
          "role": { "type": "string" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      },
      "ApiKeyResponse": {
        "type": "object",
        "properties": {
          "key_id": { "type": "string" },
          "org_id": { "type": "string" },
          "form_id": { "type": "string", "nullable": true },
          "key_type": { "type": "string" },
          "key_prefix": { "type": "string" },
          "key_full": { "type": "string", "nullable": true, "description": "Full key value, populated for publishable keys only" },
          "label": { "type": "string" },
          "active": { "type": "boolean" },
          "created_at": { "type": "string", "format": "date-time" },
          "last_used_at": { "type": "string", "format": "date-time", "nullable": true }
        }
      },
      "ApiKeyCreateResponse": {
        "type": "object",
        "properties": {
          "publishable_key": { "$ref": "#/components/schemas/ApiKeyResponse" },
          "secret_key": { "$ref": "#/components/schemas/ApiKeyResponse" },
          "publishable_key_full": { "type": "string", "description": "Full publishable key, shown only once" },
          "secret_key_full": { "type": "string", "description": "Full secret key, shown only once" }
        }
      },
      "SessionCreateRequest": {
        "type": "object",
        "properties": {
          "session_id": { "type": "string", "nullable": true, "description": "Pre-generated session ID; auto-generated if omitted" },
          "form_id": { "type": "string", "nullable": true, "description": "Form ID; can also be set via X-Stradum-Form-Id header or key binding" },
          "metadata": { "type": "object", "default": {} },
          "device_info": { "type": "object", "default": {} }
        }
      },
      "SessionResponse": {
        "type": "object",
        "properties": {
          "session_id": { "type": "string" },
          "identity_id": { "type": "string", "nullable": true },
          "account_id": { "type": "string", "nullable": true },
          "account_name": { "type": "string", "nullable": true },
          "form_id": { "type": "string", "nullable": true },
          "form_name": { "type": "string", "nullable": true },
          "status": { "type": "string", "enum": ["active", "completed", "expired", "error"] },
          "match_status": { "$ref": "#/components/schemas/MatchStatus" },
          "match_score": { "type": "number", "nullable": true },
          "created_at": { "type": "string", "format": "date-time" },
          "updated_at": { "type": "string", "format": "date-time" },
          "completed_at": { "type": "string", "format": "date-time", "nullable": true },
          "event_count": { "type": "integer" },
          "metadata": { "type": "object" },
          "device_info": { "type": "object" },
          "field_values": { "type": "object", "additionalProperties": { "type": "string" } },
          "tags": { "type": "array", "items": { "type": "string" } }
        }
      },
      "SessionListResponse": {
        "type": "object",
        "properties": {
          "sessions": { "type": "array", "items": { "$ref": "#/components/schemas/SessionResponse" } },
          "total": { "type": "integer" },
          "page": { "type": "integer" },
          "page_size": { "type": "integer" }
        }
      },
      "SessionCompleteRequest": {
        "type": "object",
        "properties": {
          "identity_id": { "type": "string", "nullable": true },
          "form_id": { "type": "string", "nullable": true },
          "field_values": { "type": "object", "additionalProperties": { "type": "string" }, "default": {} },
          "metadata": { "type": "object", "default": {} }
        }
      },
      "SessionMetadataRequest": {
        "type": "object",
        "properties": {
          "form_id": { "type": "string", "nullable": true },
          "metadata": { "type": "object", "default": {} }
        }
      },
      "EventPayload": {
        "type": "object",
        "required": ["event_type", "timestamp"],
        "properties": {
          "event_type": { "type": "string" },
          "timestamp": { "type": "number", "description": "Epoch milliseconds" },
          "field_name": { "type": "string", "nullable": true },
          "field_type": { "type": "string", "nullable": true },
          "data": { "type": "object", "default": {} }
        }
      },
      "EventBatchRequest": {
        "type": "object",
        "required": ["session_id", "events"],
        "properties": {
          "session_id": { "type": "string", "minLength": 1, "maxLength": 128 },
          "events": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/EventPayload" },
            "minItems": 1,
            "maxItems": 5000
          },
          "form_id": { "type": "string", "nullable": true },
          "sdk_version": { "type": "string", "nullable": true },
          "page_url": { "type": "string", "nullable": true }
        }
      },
      "EventBatchResponse": {
        "type": "object",
        "properties": {
          "session_id": { "type": "string" },
          "accepted": { "type": "integer" },
          "rejected": { "type": "integer" },
          "total_event_count": { "type": "integer" }
        }
      },
      "IdentityCreateRequest": {
        "type": "object",
        "properties": {
          "external_id": { "type": "string", "nullable": true },
          "account_id": { "type": "string", "nullable": true },
          "account_name": { "type": "string", "nullable": true },
          "account_uri": { "type": "string", "nullable": true },
          "metadata": { "type": "object", "default": {} }
        }
      },
      "IdentityLinkRequest": {
        "type": "object",
        "required": ["session_id", "identity_id"],
        "properties": {
          "session_id": { "type": "string" },
          "identity_id": { "type": "string" },
          "account_id": { "type": "string", "nullable": true },
          "account_name": { "type": "string", "nullable": true },
          "account_uri": { "type": "string", "nullable": true }
        }
      },
      "IdentityResponse": {
        "type": "object",
        "properties": {
          "identity_id": { "type": "string" },
          "external_id": { "type": "string", "nullable": true },
          "account_ids": { "type": "array", "items": { "type": "string" } },
          "created_at": { "type": "string", "format": "date-time" },
          "session_count": { "type": "integer" },
          "metadata": { "type": "object" }
        }
      },
      "IdentityListResponse": {
        "type": "object",
        "properties": {
          "identities": { "type": "array", "items": { "$ref": "#/components/schemas/IdentityResponse" } },
          "total": { "type": "integer" },
          "page": { "type": "integer" },
          "page_size": { "type": "integer" }
        }
      },
      "AccountResponse": {
        "type": "object",
        "properties": {
          "account_id": { "type": "string" },
          "account_name": { "type": "string" },
          "account_uri": { "type": "string", "nullable": true },
          "created_at": { "type": "string", "format": "date-time" },
          "session_count": { "type": "integer" },
          "identity_count": { "type": "integer" },
          "metadata": { "type": "object" }
        }
      },
      "AccountListResponse": {
        "type": "object",
        "properties": {
          "accounts": { "type": "array", "items": { "$ref": "#/components/schemas/AccountResponse" } },
          "total": { "type": "integer" },
          "page": { "type": "integer" },
          "page_size": { "type": "integer" }
        }
      },
      "AnalysisTriggerRequest": {
        "type": "object",
        "required": ["session_id"],
        "properties": {
          "session_id": { "type": "string" },
          "identity_id": { "type": "string", "nullable": true, "description": "Override the session's linked identity" },
          "external_id": { "type": "string", "nullable": true }
        }
      },
      "ScoreResponse": {
        "type": "object",
        "description": "Public score response returned by /analysis/trigger and /analysis/session/{session_id}/score. Built by the response builder — does not expose internal signal names or z-scores.",
        "properties": {
          "session_id": { "type": "string" },
          "identity_id": { "type": "string" },
          "analyzed_at": { "type": "string", "format": "date-time" },
          "result": {
            "type": "object",
            "properties": {
              "score": { "type": "number", "description": "Similarity score 0-100 (higher = more similar)" },
              "match_status": { "$ref": "#/components/schemas/MatchStatus" },
              "confidence": { "type": "number", "description": "0.0-1.0 reflecting baseline depth" }
            }
          },
          "signals": {
            "type": "object",
            "description": "Per-category signal ratings",
            "properties": {
              "typing_behavior": { "$ref": "#/components/schemas/SignalCategory" },
              "interaction_pattern": { "$ref": "#/components/schemas/SignalCategory" },
              "navigation_behavior": { "$ref": "#/components/schemas/SignalCategory" },
              "data_entry_method": { "$ref": "#/components/schemas/SignalCategory" },
              "behavioral_consistency": { "$ref": "#/components/schemas/SignalCategory" }
            }
          },
          "reasons": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "code": { "type": "string" },
                "category": { "type": "string" },
                "severity": { "type": "string" },
                "description": { "type": "string" }
              }
            }
          },
          "context": {
            "type": "object",
            "properties": {
              "baseline_sessions": { "type": "integer" },
              "baseline_depth": { "$ref": "#/components/schemas/BaselineDepth" },
              "summary": { "type": "string" }
            }
          }
        }
      },
      "DashboardOverview": {
        "type": "object",
        "properties": {
          "total_sessions": { "type": "integer" },
          "total_identities": { "type": "integer" },
          "total_accounts": { "type": "integer" },
          "sessions_today": { "type": "integer" },
          "alerts_today": { "type": "integer" },
          "match_distribution": {
            "type": "object",
            "additionalProperties": { "type": "integer" }
          },
          "recent_sessions": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/SessionResponse" }
          }
        }
      },
      "AlertItem": {
        "type": "object",
        "properties": {
          "analysis_id": { "type": "string" },
          "session_id": { "type": "string" },
          "identity_id": { "type": "string" },
          "account_id": { "type": "string", "nullable": true },
          "account_name": { "type": "string", "nullable": true },
          "form_id": { "type": "string", "nullable": true },
          "analyzed_at": { "type": "string", "format": "date-time" },
          "match_score": { "type": "number" },
          "match_status": { "$ref": "#/components/schemas/MatchStatus" },
          "confidence": { "type": "number" },
          "summary": { "type": "string" },
          "reasons": { "type": "array", "items": { "type": "string" } },
          "signals": { "type": "object", "additionalProperties": { "type": "string" } },
          "session_created_at": { "type": "string", "format": "date-time", "nullable": true },
          "event_count": { "type": "integer" }
        }
      },
      "AlertListResponse": {
        "type": "object",
        "properties": {
          "alerts": { "type": "array", "items": { "$ref": "#/components/schemas/AlertItem" } },
          "total": { "type": "integer" },
          "page": { "type": "integer" },
          "page_size": { "type": "integer" }
        }
      },
      "TimelineEntry": {
        "type": "object",
        "properties": {
          "timestamp": { "type": "string", "format": "date-time" },
          "field_name": { "type": "string", "nullable": true },
          "action": { "type": "string", "enum": ["started_field", "completed_field", "paused", "resumed", "submitted", "switched_away", "returned"] },
          "duration_seconds": { "type": "number", "nullable": true },
          "annotation": { "type": "string", "nullable": true }
        }
      },
      "TimelineResponse": {
        "type": "object",
        "properties": {
          "session_id": { "type": "string" },
          "identity_id": { "type": "string", "nullable": true },
          "started_at": { "type": "string", "format": "date-time", "nullable": true },
          "completed_at": { "type": "string", "format": "date-time", "nullable": true },
          "duration_seconds": { "type": "number", "nullable": true },
          "device_type": { "type": "string", "nullable": true },
          "fields_completed": { "type": "integer", "nullable": true },
          "fields_available": { "type": "integer", "nullable": true },
          "timeline": {
            "type": "array",
            "items": { "$ref": "#/components/schemas/TimelineEntry" }
          },
          "summary": { "type": "string", "nullable": true }
        }
      },
      "FormCreateRequest": {
        "type": "object",
        "required": ["name"],
        "properties": {
          "name": { "type": "string", "minLength": 1, "maxLength": 200 },
          "slug": { "type": "string" },
          "field_mapping": { "type": "object", "additionalProperties": { "type": "string" } },
          "session_group_key": { "type": "string", "nullable": true },
          "metadata": { "type": "object", "default": {} }
        }
      },
      "FormUpdateRequest": {
        "type": "object",
        "properties": {
          "name": { "type": "string", "nullable": true },
          "slug": { "type": "string", "nullable": true },
          "field_mapping": { "type": "object", "additionalProperties": { "type": "string" }, "nullable": true },
          "session_group_key": { "type": "string", "nullable": true },
          "metadata": { "type": "object", "nullable": true }
        }
      },
      "FormResponse": {
        "type": "object",
        "properties": {
          "form_id": { "type": "string" },
          "org_id": { "type": "string" },
          "name": { "type": "string" },
          "slug": { "type": "string" },
          "field_mapping": { "type": "object", "additionalProperties": { "type": "string" } },
          "session_group_key": { "type": "string", "nullable": true },
          "created_at": { "type": "string", "format": "date-time" },
          "updated_at": { "type": "string", "format": "date-time" },
          "metadata": { "type": "object" }
        }
      },
      "FormListResponse": {
        "type": "object",
        "properties": {
          "forms": { "type": "array", "items": { "$ref": "#/components/schemas/FormResponse" } },
          "total": { "type": "integer" }
        }
      },
      "WebhookCreateRequest": {
        "type": "object",
        "required": ["url", "events"],
        "properties": {
          "url": { "type": "string", "format": "uri" },
          "events": { "type": "array", "items": { "type": "string" } },
          "secret": { "type": "string", "nullable": true },
          "form_id": { "type": "string", "nullable": true }
        }
      },
      "WebhookResponse": {
        "type": "object",
        "properties": {
          "webhook_id": { "type": "string" },
          "form_id": { "type": "string", "nullable": true },
          "url": { "type": "string" },
          "events": { "type": "array", "items": { "type": "string" } },
          "active": { "type": "boolean" },
          "created_at": { "type": "string", "format": "date-time" }
        }
      },
      "WebhookListResponse": {
        "type": "object",
        "properties": {
          "webhooks": { "type": "array", "items": { "$ref": "#/components/schemas/WebhookResponse" } }
        }
      },
      "WaitlistRequest": {
        "type": "object",
        "required": ["name", "email"],
        "properties": {
          "name": { "type": "string" },
          "email": { "type": "string", "format": "email" },
          "company": { "type": "string", "nullable": true },
          "use_case": { "type": "string", "nullable": true }
        }
      },
      "WaitlistResponse": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" },
          "message": { "type": "string" }
        }
      }
    }
  }
}
