{
  "openapi": "3.1.0",
  "info": {
    "title": "ulex API",
    "version": "2025.9.1",
    "summary": "Agent-native identity control-plane simulator: OIDC/OAuth 2.1, SAML 2.0, SCIM 2.0, cross-app SSO, directory sync, MFA and passkeys, JWT sessions, webhooks, an immutable audit log, and deployment simulation.",
    "description": "ulex lets an AI agent stand up a complete, realistic identity backend for the app it is building — without a real IdP, a real customer directory, or a browser.\n\n## Ten things to know before your first call\n\n1. **Tenant context comes from the credential.** It is never a parameter. An API key talks to your tenant on `https://ulexid.com` (or your local in-memory server on `http://127.0.0.1:3001`).\n2. **Read `error.retryable`, not the status code.** It is the only backoff signal. `false` means the request is wrong; retrying cannot help.\n3. **Every error is the same envelope** — `{ error: { type, code, message, param?, request_id, retryable, docs_url?, hint?, details? } }` — on REST, MCP, and the CLI alike.\n4. **Send `Idempotency-Key` on every create.** Replays return the original response; a different body with the same key is 409.\n5. **A new connection is `draft`.** Every login on a draft connection is refused with `connection_not_active` until you activate it.\n6. **Refresh tokens rotate on every use.** Replaying a spent one revokes the whole family. On a network timeout, introspect — do not retry.\n7. **Users are tenant-global.** One human is one `usr_…`; customers are `organization_membership` records.\n8. **Secrets are returned once.** API keys, client secrets, SCIM tokens, webhook secrets, and MFA secrets are never retrievable again.\n9. **Secrets accept `env:VAR_NAME`.** ulex reads them from its own environment and never persists the literal.\n10. **Every operation names the MCP tool that wraps it** in `x-ulex-mcp-tool`. Prefer the tool: it infers the tenant context and returns the same object.\n\n## Authentication\n\n`Authorization: Bearer ulex_sk_live_…` for the control plane, or a user access token for the OIDC surface. `X-Ulex-Request-Id` and `X-Ulex-Correlation-Id` are accepted and echoed; the first is stored on every audit event the call touches.\n\n## Resources\n\nEvery object is `{ id, object, ...fields }`. Ids are prefixed, ULID-suffixed, and sort by creation time: `ten_` `app_` `org_` `usr_` `con_` `dom_` `mem_` `grp_` `dir_` `ses_` `grt_` `tok_` `key_` `whk_` `dlv_` `aud_` `dep_` `job_` `psk_` `mfa_`.\n\n## What ulex is not\n\nIt is a simulator. It does not authenticate real humans, deliver email, sign with a CA-issued certificate, or run your application's code during a deployment. It is a faithful model of an identity backend, plus the controls that let you build and test against the real one. See `https://docs.ulexid.com/agents/agent-manual#what-ulex-is-not`.",
    "contact": {
      "name": "ulex support",
      "url": "https://docs.ulexid.com/resources/support"
    },
    "license": {
      "name": "Commercial",
      "url": "https://docs.ulexid.com/resources/support#licensing"
    }
  },
  "servers": [
    {
      "url": "https://ulexid.com/api/v1",
      "description": "Ulexid REST API"
    }
  ],
  "tags": [
    {
      "name": "Platform",
      "description": "Health, status, the current credential, and the tenant."
    },
    {
      "name": "API keys",
      "description": "Control-plane credentials, signing keys, and rotation."
    },
    {
      "name": "Applications",
      "description": "OAuth 2.1 / OIDC clients, credentials, and SAML SP metadata."
    },
    {
      "name": "Organizations",
      "description": "Customers, verified domains, memberships, and groups."
    },
    {
      "name": "Users",
      "description": "Tenant-global users, status, suspend, passkeys, and MFA factors."
    },
    {
      "name": "Groups",
      "description": "Organization-scoped groups and their membership."
    },
    {
      "name": "Connections",
      "description": "Identity sources: mock, password, OIDC, SAML, SCIM, JWT."
    },
    {
      "name": "Directories",
      "description": "Upstream directories, outbound polling, and SCIM configuration."
    },
    {
      "name": "SCIM",
      "description": "Inbound SCIM 2.0 for Okta, Entra ID, and Google Workspace."
    },
    {
      "name": "OAuth",
      "description": "Authorization code with PKCE, refresh, introspection, revocation, JWKS, token exchange, device flow."
    },
    {
      "name": "Auth",
      "description": "Hosted sign-in UI. For humans, not agents."
    },
    {
      "name": "Webhooks",
      "description": "Signed change notifications, 34 events, retries, and delivery inspection."
    },
    {
      "name": "Audit",
      "description": "The immutable, hash-chained audit log and its export."
    },
    {
      "name": "Deployments",
      "description": "The modelled deployment lifecycle, logs, and rollback."
    },
    {
      "name": "Environments",
      "description": "Active control-plane environment metadata and health."
    },
    {
      "name": "Simulator",
      "description": "Headless authentication, token minting, and reset. Requires allow_mocks: true on non-HIPAA tenants (enabled by default in local in-memory mode)."
    },
    {
      "name": "MCP",
      "description": "Streamable HTTP MCP endpoint: 86 tools, OAuth 2.1 protected resource."
    },
    {
      "name": "Portal",
      "description": "Public signup, browser sessions, and own-organization management. For the human-facing portal SPA, not agents."
    },
    {
      "name": "Feedback",
      "description": "Agent-submitted reports about the platform itself."
    }
  ],
  "security": [
    {
      "bearerApiKey": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "summary": "Liveness",
        "description": "Cheap, unauthenticated liveness probe with per-dependency latency. Not rate limited.\n\n**MCP tool:** `ulex_health_check`",
        "operationId": "getHealth",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_health_check",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/health"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                },
                "examples": {
                  "unavailable": {
                    "$ref": "#/components/examples/healthUnavailable"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/status": {
      "get": {
        "summary": "Service status",
        "description": "Aggregate status for the credential's environment, plus any active degradations. Unauthenticated.\n\n**MCP tool:** `ulex_get_status`",
        "operationId": "getStatus",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_get_status",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Status"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/status"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/usage": {
      "get": {
        "summary": "Get tenant usage, storage, and estimated usage-based bill",
        "description": "Returns live resource counts, current-period request counters, storage estimation, and usage-based billing calculation with zero plan limits.",
        "operationId": "getUsage",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_get_usage",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "usage": { "type": "object" },
                    "requests": { "type": "object" },
                    "billing": { "type": "object" },
                    "plan_limits_enforced": { "type": "boolean" }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/me": {
      "get": {
        "summary": "Identify the caller",
        "description": "Return the authenticated caller, tenant id, request id, and environment.",
        "operationId": "getMe",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_get_usage",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Me"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/me"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/tenants/current": {
      "get": {
        "summary": "Read the current tenant",
        "description": "The tenant that owns the credential. `id` is used as the default scope for every other call.\n\n**MCP tool:** `ulex_get_tenant`\n\n**Scopes:** `ulex:admin`",
        "operationId": "getCurrentTenant",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_get_tenant",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tenant"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/tenant"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update the current tenant",
        "description": "Mutable: `name`, `allow_mocks`, `hipaa_enabled`, and the retention windows. `plan`, `slug`, `region` and `kms_key_alias` are not writable through the API.\n\n**MCP tool:** `ulex_update_tenant`\n\n**Scopes:** `ulex:admin`",
        "operationId": "updateCurrentTenant",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_update_tenant",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TenantUpdate"
              },
              "examples": {
                "allowMocks": {
                  "$ref": "#/components/examples/tenantUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Tenant"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/tenant"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/tenants/current/retention/sweep": {
      "post": {
        "summary": "Enforce configured tenant retention windows",
        "description": "Purges expired sessions, old webhook deliveries, soft-deletes inactive applications, and removes audit log entries strictly older than `retention.audit_log_days` (minimum 2555 days when `hipaa_enabled` is true) while preserving audit hash chain integrity.\n\n**MCP tool:** `ulex_run_retention_sweep`\n\n**Scopes:** `ulex:admin`",
        "operationId": "sweepTenantRetention",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_run_retention_sweep",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "dry_run": {
                    "type": "boolean",
                    "default": false
                  },
                  "limit": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 2000,
                    "default": 500
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Retention sweep summary",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "tenant_id": { "type": "string" },
                    "dry_run": { "type": "boolean" },
                    "swept_at": { "type": "string", "format": "date-time" },
                    "policy": { "type": "object" },
                    "cutoffs": { "type": "object" },
                    "purged": {
                      "type": "object",
                      "properties": {
                        "sessions": { "type": "integer" },
                        "webhook_deliveries": { "type": "integer" },
                        "inactive_applications": { "type": "integer" },
                        "audit_events": { "type": "integer" }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/tenants/current/api-keys": {
      "get": {
        "summary": "List API keys",
        "description": "Prefixes only. The full key is never returned, by any endpoint, ever.\n\n**MCP tool:** `ulex_list_api_keys`\n\n**Scopes:** `ulex:admin`",
        "operationId": "listApiKeys",
        "tags": [
          "API keys"
        ],
        "x-ulex-mcp-tool": "ulex_list_api_keys",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/apiKeyList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create an API key",
        "description": "The plaintext key is returned in `key` exactly once. Store it in the same call. Admin-only scopes (`ulex:admin`, `mcp:admin`, `sso:impersonate`) are rejected at mint time for non-admin keys.\n\n**MCP tool:** `ulex_create_api_key`\n\n**Scopes:** `ulex:admin`",
        "operationId": "createApiKey",
        "tags": [
          "API keys"
        ],
        "x-ulex-mcp-tool": "ulex_create_api_key",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiKeyCreate"
              },
              "examples": {
                "agentBootstrap": {
                  "$ref": "#/components/examples/apiKeyCreate"
                },
                "leastPrivilege": {
                  "$ref": "#/components/examples/apiKeyCreateNarrow"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyWithSecret"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/apiKeyWithSecret"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKeyWithSecret"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/apiKeyWithSecret"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/tenants/current/api-keys/{keyId}": {
      "delete": {
        "summary": "Revoke an API key",
        "description": "Immediate and total. The next call with this key returns 401 `api_key_revoked`. There is no grace period, because a leaked key must be dead on the next request.\n\n**MCP tool:** `ulex_revoke_api_key`\n\n**Scopes:** `ulex:admin`",
        "operationId": "revokeApiKey",
        "tags": [
          "API keys"
        ],
        "x-ulex-mcp-tool": "ulex_revoke_api_key",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/keyId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiKey"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/apiKeyRevoked"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/tenants/current/rotate-signing-keys": {
      "post": {
        "summary": "Rotate tenant signing keys",
        "description": "Generates a new active key per purpose and puts the previous one in `retiring` for the grace window. During the window the JWKS contains both. Wait at least two full JWKS cache TTLs after rotation before assuming the old `kid` is gone from consumers. Not idempotent: every call mints a new key.\n\n**MCP tool:** `ulex_rotate_signing_keys`\n\n**Scopes:** `ulex:admin`",
        "operationId": "rotateSigningKeys",
        "tags": [
          "API keys"
        ],
        "x-ulex-mcp-tool": "ulex_rotate_signing_keys",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SigningKeyRotateRequest"
              },
              "examples": {
                "accessToken": {
                  "$ref": "#/components/examples/signingKeyRotation"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyRotationResult"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/keyRotationResult"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/applications": {
      "get": {
        "summary": "List applications",
        "description": "Every OIDC/SAML client registered in the tenant, newest last by default.\n\n**MCP tool:** `ulex_list_applications`\n\n**Scopes:** `read:applications`",
        "operationId": "listApplications",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_list_applications",
        "x-ulex-scopes": [
          "read:applications"
        ],
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "description": "Filter by client type.",
            "schema": {
              "type": "string",
              "enum": [
                "first_party",
                "third_party"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Prefix match on name or slug.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/applicationList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create an application",
        "description": "Registers an OAuth 2.1 / OIDC client. PKCE is required by default and `S256` only. `redirect_uris` accepts `http://` solely for `localhost`, `127.0.0.1` and `::1`. Natural idempotency key: `slug`.\n\n**MCP tool:** `ulex_create_application`\n\n**Scopes:** `write:applications`",
        "operationId": "createApplication",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_create_application",
        "x-ulex-scopes": [
          "write:applications"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationCreate"
              },
              "examples": {
                "firstParty": {
                  "$ref": "#/components/examples/applicationCreate"
                },
                "multiRedirect": {
                  "$ref": "#/components/examples/applicationCreateLocalhost"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/application"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/application"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/applications/{id}": {
      "get": {
        "summary": "Read an application",
        "description": "Read-only projection. The client secret is never included; use the `/secret` sub-resource.\n\n**MCP tool:** `ulex_get_application`\n\n**Scopes:** `read:applications`",
        "operationId": "getApplication",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_get_application",
        "x-ulex-scopes": [
          "read:applications"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/applicationId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/application"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update an application",
        "description": "`id`, `tenant_id`, `object`, `created_at`, `created_by` and `slug` are immutable; sending one is 409 `immutable_field`. An empty body is 400.\n\n**MCP tool:** `ulex_update_application`\n\n**Scopes:** `write:applications`",
        "operationId": "updateApplication",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_update_application",
        "x-ulex-scopes": [
          "write:applications"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/applicationId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationUpdate"
              },
              "examples": {
                "patchRedirectUris": {
                  "$ref": "#/components/examples/applicationUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Application"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/application"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete an application",
        "description": "Soft delete, reversible for 30 days. Sessions and grants issued to the application are **not** terminated; revoke them explicitly if you need them dead now.\n\n**MCP tool:** `ulex_delete_application`\n\n**Scopes:** `write:applications`",
        "operationId": "deleteApplication",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_delete_application",
        "x-ulex-scopes": [
          "write:applications"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/applicationId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedApplication"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/applications/{id}/secret": {
      "get": {
        "summary": "Read client credentials",
        "description": "Decrypts and returns the client secret. Requires `ulex:admin`; a scoped key gets 403 `insufficient_scope`. Also returns the SAML IdP signing certificate and every endpoint URL for this application.\n\n**MCP tool:** `ulex_get_application_credentials`\n\n**Scopes:** `ulex:admin` `read:applications`",
        "operationId": "getApplicationSecret",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_get_application_credentials",
        "x-ulex-scopes": [
          "ulex:admin",
          "read:applications"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/applicationId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApplicationCredentials"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/applicationCredentials"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/applications/{id}/rotate-secret": {
      "post": {
        "summary": "Rotate the client secret",
        "description": "Mints a new secret and keeps the previous one valid for the grace window. This is the whole zero-downtime mechanism: deploy the new secret, smoke-test one token call, and let the old one expire. Not idempotent.\n\n**MCP tool:** `ulex_rotate_application_secret`\n\n**Scopes:** `ulex:admin`",
        "operationId": "rotateApplicationSecret",
        "tags": [
          "Applications"
        ],
        "x-ulex-mcp-tool": "ulex_rotate_application_secret",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/applicationId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApplicationUpdate"
              },
              "examples": {
                "withGrace": {
                  "$ref": "#/components/examples/rotateSecret"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SecretRotation"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/secretRotation"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/organizations": {
      "get": {
        "summary": "List organizations",
        "description": "Customer organizations in the tenant. Hard-capped at 10,000 rows.\n\n**MCP tool:** `ulex_list_organizations`\n\n**Scopes:** `read:organizations`",
        "operationId": "listOrganizations",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_list_organizations",
        "x-ulex-scopes": [
          "read:organizations"
        ],
        "parameters": [
          {
            "name": "connection_id",
            "in": "query",
            "description": "Organizations bound to this connection.",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "domain",
            "in": "query",
            "description": "Organizations with this verified domain.",
            "schema": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Prefix match on name or slug.",
            "schema": {
              "type": "string",
              "maxLength": 120
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrganizationList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/organizationList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create an organization",
        "description": "A customer of your app. Natural idempotency key: `slug`.\n\n**MCP tool:** `ulex_create_organization`\n\n**Scopes:** `write:organizations`",
        "operationId": "createOrganization",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_create_organization",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationCreate"
              },
              "examples": {
                "ssoOnly": {
                  "$ref": "#/components/examples/organizationCreate"
                },
                "withMetadata": {
                  "$ref": "#/components/examples/organizationCreateWithMetadata"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/organization"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/organization"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/organizations/{id}": {
      "get": {
        "summary": "Read an organization",
        "description": "One customer organization.\n\n**MCP tool:** `ulex_get_organization`\n\n**Scopes:** `read:organizations`",
        "operationId": "getOrganization",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_get_organization",
        "x-ulex-scopes": [
          "read:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/organization"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update an organization",
        "description": "Mutable: `name`, `logo_url`, `sso_only`, `allow_profiles_outside_organization`, `connection_id`, `directory_id`, `metadata`. `slug` and `id` are immutable.\n\n**MCP tool:** `ulex_update_organization`\n\n**Scopes:** `write:organizations`",
        "operationId": "updateOrganization",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_update_organization",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrganizationUpdate"
              },
              "examples": {
                "bindConnection": {
                  "$ref": "#/components/examples/organizationUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Organization"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/organization"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete an organization",
        "description": "Soft delete, reversible for 30 days. Memberships are revoked and active sessions terminated. Emits `organization.deleted`.\n\n**MCP tool:** `ulex_delete_organization`\n\n**Scopes:** `write:organizations`",
        "operationId": "deleteOrganization",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_delete_organization",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedOrganization"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/organizations/{id}/members": {
      "get": {
        "summary": "List organization members",
        "description": "Memberships in one organization, with the organization summary inlined.\n\n**MCP tool:** `ulex_list_organization_members`\n\n**Scopes:** `read:organizations`",
        "operationId": "listOrganizationMembers",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_list_organization_members",
        "x-ulex-scopes": [
          "read:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "role",
            "in": "query",
            "description": "Filter by role.",
            "schema": {
              "type": "string",
              "enum": [
                "owner",
                "admin",
                "member",
                "guest"
              ]
            }
          },
          {
            "name": "group_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Prefix match on email.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MembershipList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/membershipList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/organizations/{id}/members/{userId}": {
      "put": {
        "summary": "Replace a membership",
        "description": "Upsert addressed by user id. `group_ids` is replaced wholesale, so omit a group to remove it.\n\n**MCP tool:** `ulex_add_organization_member`\n\n**Scopes:** `write:organizations`",
        "operationId": "replaceOrganizationMember",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_add_organization_member",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MembershipCreate"
              },
              "examples": {
                "admin": {
                  "$ref": "#/components/examples/membershipUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Membership"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/membership"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Remove a member",
        "description": "Revokes that user's sessions **in this organization only**; their tokens in other organizations stay valid. Removing the last `owner` is 409 `invalid_state_transition`.\n\n**MCP tool:** `ulex_remove_organization_member`\n\n**Scopes:** `write:organizations`",
        "operationId": "removeOrganizationMember",
        "tags": [
          "Organizations"
        ],
        "x-ulex-mcp-tool": "ulex_remove_organization_member",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedMembership"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/organizations/{id}/groups": {
      "get": {
        "summary": "List an organization's groups",
        "description": "Groups always belong to exactly one organization.\n\n**MCP tool:** `ulex_list_groups`\n\n**Scopes:** `read:groups`",
        "operationId": "listOrganizationGroups",
        "tags": [
          "Groups"
        ],
        "x-ulex-mcp-tool": "ulex_list_groups",
        "x-ulex-scopes": [
          "read:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "source",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "manual",
                "scim",
                "saml",
                "rule"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GroupList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/groupList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a group",
        "description": "Natural idempotency key: `(organization_id, slug)`.\n\n**MCP tool:** `ulex_create_group`\n\n**Scopes:** `write:groups`",
        "operationId": "createOrganizationGroup",
        "tags": [
          "Groups"
        ],
        "x-ulex-mcp-tool": "ulex_create_group",
        "x-ulex-scopes": [
          "write:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GroupCreate"
              },
              "examples": {
                "rule": {
                  "$ref": "#/components/examples/groupCreate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/group"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/group"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/groups/{id}": {
      "patch": {
        "summary": "Update a group",
        "description": "`slug` and `organization_id` are immutable. An empty body is 400.\n\n**MCP tool:** `ulex_update_group`\n\n**Scopes:** `write:groups`",
        "operationId": "updateGroup",
        "tags": [
          "Groups"
        ],
        "x-ulex-mcp-tool": "ulex_update_group",
        "x-ulex-scopes": [
          "write:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GroupUpdate"
              },
              "examples": {
                "rename": {
                  "$ref": "#/components/examples/groupUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/group"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete a group",
        "description": "Removes the group from every membership's `group_ids`. Users are not deleted.\n\n**MCP tool:** `ulex_delete_group`\n\n**Scopes:** `write:groups`",
        "operationId": "deleteGroup",
        "tags": [
          "Groups"
        ],
        "x-ulex-mcp-tool": "ulex_delete_group",
        "x-ulex-scopes": [
          "write:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/groups/{id}/members": {
      "put": {
        "summary": "Replace group membership",
        "description": "A **full replace**, not an append. This is the correct semantic for directory sync; if you want to append, read the current members and write the union. Idempotent: applying the same set twice is the same state.\n\n**MCP tool:** `ulex_set_group_members`\n\n**Scopes:** `write:groups`",
        "operationId": "replaceGroupMembers",
        "tags": [
          "Groups"
        ],
        "x-ulex-mcp-tool": "ulex_set_group_members",
        "x-ulex-scopes": [
          "write:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GroupMembersReplace"
              },
              "examples": {
                "replace": {
                  "$ref": "#/components/examples/groupMembersReplace"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Group"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/groupWithMembers"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users": {
      "get": {
        "summary": "List users",
        "description": "Users are tenant-global. Use `organization_id` to narrow to one customer's members. Prefer `email=` for a single lookup; listing and scanning is wasteful.\n\n**MCP tool:** `ulex_list_users`\n\n**Scopes:** `read:users`",
        "operationId": "listUsers",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_list_users",
        "x-ulex-scopes": [
          "read:users"
        ],
        "parameters": [
          {
            "name": "email",
            "in": "query",
            "description": "Exact email match.",
            "schema": {
              "type": "string",
              "format": "email",
              "maxLength": 320
            }
          },
          {
            "name": "external_id",
            "in": "query",
            "description": "The id in the upstream IdP. The JIT join key.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "organization_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "group_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "directory_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive",
                "suspended",
                "pending"
              ]
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Prefix match on email or name.",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/userList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a user",
        "description": "A user is tenant-global and `email` is unique per tenant, not per organization. Creating a user does not create a membership; follow with `POST /organizations/{id}/members`. The same human in three customers is one user and three memberships.\n\n**MCP tool:** `ulex_create_user`\n\n**Scopes:** `write:users`",
        "operationId": "createUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_create_user",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserCreate"
              },
              "examples": {
                "basic": {
                  "$ref": "#/components/examples/userCreate"
                },
                "withScim": {
                  "$ref": "#/components/examples/userCreateWithScim"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/user"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/user"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}": {
      "get": {
        "summary": "Read a user",
        "description": "One tenant-global user.\n\n**MCP tool:** `ulex_get_user`\n\n**Scopes:** `read:users`",
        "operationId": "getUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_get_user",
        "x-ulex-scopes": [
          "read:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/user"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update a user",
        "description": "Mutable profile, `status`, `scim` sub-attributes and `metadata`. Changing `email` does not re-verify; set `email_verified` explicitly. An empty body is 400.\n\n**MCP tool:** `ulex_update_user`\n\n**Scopes:** `write:users`",
        "operationId": "updateUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_update_user",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserUpdate"
              },
              "examples": {
                "promote": {
                  "$ref": "#/components/examples/userUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/user"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete a user",
        "description": "Removes the user from every organization, revokes every session, soft-deletes. Prefer `POST /users/{id}/suspend` for reversible offboarding.\n\n**MCP tool:** `ulex_delete_user`\n\n**Scopes:** `write:users`",
        "operationId": "deleteUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_delete_user",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedUser"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}/suspend": {
      "post": {
        "summary": "Suspend a user",
        "description": "Atomic and idempotent: sets `status: suspended`, revokes every session in every organization, revokes every refresh-token family, emits `user.suspended` plus one `session.revoked` per session, and writes `user.suspended` to the audit log. Existing access tokens stay cryptographically valid until `exp`; introspection returns `active: false` immediately. Revoke per token if you need immediate expiry.\n\n**MCP tool:** `ulex_suspend_user`\n\n**Scopes:** `write:users`",
        "operationId": "suspendUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_suspend_user",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/UserUpdate"
              },
              "examples": {
                "withReason": {
                  "$ref": "#/components/examples/suspendUser"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SuspendResult"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/suspendResult"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}/unsuspend": {
      "post": {
        "summary": "Unsuspend a user",
        "description": "Restores `status: active` and emits `user.unsuspended`. Sessions are not resurrected; the user logs in again. Idempotent.\n\n**MCP tool:** `ulex_unsuspend_user`\n\n**Scopes:** `write:users`",
        "operationId": "unsuspendUser",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_unsuspend_user",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/User"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/user"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}/confirm-signup": {
      "post": {
        "summary": "Confirm a user signup without a code",
        "description": "The operator equivalent of Cognito's `AdminConfirmSignUp`: marks the email verified and the account `active`, clears any outstanding verification code. Idempotent.\n\n**MCP tool:** `ulex_confirm_sign_up`\n\n**Scopes:** `write:users`",
        "operationId": "confirmUserSignup",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_confirm_sign_up",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}/identities": {
      "get": {
        "summary": "List external identities linked to a user",
        "description": "Returns the upstream OIDC/SAML identities linked to the user plus password and verified passkey counts.\n\n**MCP tool:** `ulex_list_user_identities`\n\n**Scopes:** `read:users`",
        "operationId": "listUserIdentities",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_list_user_identities",
        "x-ulex-scopes": [
          "read:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "Linked external identities",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "404": {
            "description": "User not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      },
      "post": {
        "summary": "Link an external provider identity to a user",
        "description": "Binds an upstream `(connection_id, subject)` pair to the user. Refuses with `409 identity_already_linked` if already linked to another user.\n\n**MCP tool:** `ulex_link_user_identity`\n\n**Scopes:** `write:users`",
        "operationId": "linkUserIdentity",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_link_user_identity",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["connection_id", "subject"],
                "properties": {
                  "connection_id": { "type": "string" },
                  "subject": { "type": "string" },
                  "email": { "type": "string", "nullable": true },
                  "issuer": { "type": "string", "nullable": true }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Identity linked",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "409": {
            "description": "Identity already linked to another account",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/users/{id}/identities/{connectionId}": {
      "delete": {
        "summary": "Unlink an external identity from a user",
        "description": "Removes an upstream `(connection_id, subject)` link. Refuses `400 last_auth_method` unless `force=true` or another sign-in factor exists.\n\n**MCP tool:** `ulex_unlink_user_identity`\n\n**Scopes:** `write:users`",
        "operationId": "unlinkUserIdentity",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_unlink_user_identity",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": {
            "description": "Identity unlinked",
            "content": {
              "application/json": {
                "schema": { "type": "object" }
              }
            }
          },
          "400": {
            "description": "Last remaining authentication method",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/users/{id}/memberships": {
      "get": {
        "summary": "List a user's memberships",
        "description": "The canonical answer to \"which customers is this person in\". The organization summary is inlined on each row.\n\n**MCP tool:** `ulex_list_organization_members`\n\n**Scopes:** `read:organizations` `read:users`",
        "operationId": "listUserMemberships",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_list_organization_members",
        "x-ulex-scopes": [
          "read:organizations",
          "read:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MembershipList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/membershipList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/connections": {
      "get": {
        "summary": "List connections",
        "description": "One connection is one identity source for one organization.\n\n**MCP tool:** `ulex_list_connections`\n\n**Scopes:** `read:connections`",
        "operationId": "listConnections",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_list_connections",
        "x-ulex-scopes": [
          "read:connections"
        ],
        "parameters": [
          {
            "name": "organization_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "strategy",
            "in": "query",
            "description": "Filter on config.strategy.",
            "schema": {
              "$ref": "#/components/schemas/ConnectionStrategy"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "active",
                "inactive",
                "expired",
                "error"
              ]
            }
          },
          {
            "name": "domain",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            }
          },
          {
            "name": "search",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connectionList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a connection",
        "description": "`config` is a discriminated union on `strategy`: only that strategy's namespace is valid, and sending any other is 400 `unknown_parameter`. New connections are created in `state: draft`; **every login on a draft connection fails with 403 `connection_not_active`** until you activate it. Secret-shaped fields accept `\"env:VAR_NAME\"`, which ulex reads from its own environment and never persists in cleartext.\n\n**MCP tool:** `ulex_create_connection`\n\n**Scopes:** `write:connections`",
        "operationId": "createConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_create_connection",
        "x-ulex-scopes": [
          "write:connections"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionCreate"
              },
              "examples": {
                "mockSso": {
                  "$ref": "#/components/examples/connectionCreateMockSso"
                },
                "oktaOidc": {
                  "$ref": "#/components/examples/connectionCreateOktaOidc"
                },
                "saml": {
                  "$ref": "#/components/examples/connectionCreateSaml"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connection"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connection"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connection"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connection"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/connections/{id}": {
      "get": {
        "summary": "Read a connection",
        "description": "Secrets are redacted: `*_encrypted` fields are replaced by `has_*` booleans or `null`. Nothing encrypted is ever transmitted.\n\n**MCP tool:** `ulex_get_connection`\n\n**Scopes:** `read:connections`",
        "operationId": "getConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_get_connection",
        "x-ulex-scopes": [
          "read:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connection"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connection"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "patch": {
        "summary": "Update a connection",
        "description": "Replaces the whole `config` object; it does not deep-merge. Read the current config, modify it, send it back. Changing `strategy`, or a SAML certificate, drops the connection back to `draft` and requires re-verification and re-activation.\n\n**MCP tool:** `ulex_create_connection`\n\n**Scopes:** `write:connections`",
        "operationId": "updateConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_create_connection",
        "x-ulex-scopes": [
          "write:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ConnectionUpdate"
              },
              "examples": {
                "forceFailure": {
                  "$ref": "#/components/examples/connectionUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connection"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connection"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete a connection",
        "description": "Soft delete. **Sessions and grants it produced are not terminated** — they live until their own `expires_at`. Revoke them explicitly, or call the simulator reset, if you need them dead now.\n\n**MCP tool:** `ulex_delete_connection`\n\n**Scopes:** `write:connections`",
        "operationId": "deleteConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_delete_connection",
        "x-ulex-scopes": [
          "write:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedConnection"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/connections/{id}/activate": {
      "post": {
        "summary": "Activate a connection",
        "description": "`draft`/`inactive` → `active`. Rejected with 409 `invalid_state_transition` when any domain is unverified, when a SAML certificate has expired, or when required config is missing. Idempotent: activating an active connection returns the same object and is safe to call repeatedly.\n\n**MCP tool:** `ulex_activate_connection`\n\n**Scopes:** `write:connections`",
        "operationId": "activateConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_activate_connection",
        "x-ulex-scopes": [
          "write:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Connection"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/connectionActive"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/connections/{id}/verify": {
      "post": {
        "summary": "Verify a connection",
        "description": "**Reaches the upstream.** For OIDC it fetches and validates the discovery document and, on success, caches the endpoints on `connection.discovery`. For SAML it checks that the pinned certificate yields a usable public key, reports the signature algorithm and the clock-skew budget, and probes `sso_url`. Every check it cannot run is reported as `skipped`, not `passed`.\n\n**Always returns 200.** An unreachable or misconfigured IdP is an *answer*, not an exception: read `valid` and `checks[]`. A caller scripting this must be able to distinguish \"the IdP is misconfigured\" from \"the check itself broke\", and a failure status is the only way to.\n\n**It is the documented gate on going live** — `POST /connections/{id}/activate` refuses an unverified connection. This call used to be a pure config inspection (\"is `issuer` non-empty\") while advertising that it fetched and validated discovery, so \"verified\" and \"the IdP answers\" were the same claim and only the first was true.\n\n**MCP tool:** `ulex_verify_connection`\n\n**Scopes:** `write:connections`",
        "operationId": "verifyConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_verify_connection",
        "x-ulex-scopes": [
          "read:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConnectionVerificationResult"
                },
                "examples": {
                  "allPassed": {
                    "$ref": "#/components/examples/connectionVerification"
                  },
                  "failed": {
                    "$ref": "#/components/examples/connectionVerificationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/connections/{id}/sync": {
      "post": {
        "summary": "Synchronize a SCIM or directory_sync connection",
        "description": "Runs an outbound SCIM 2.0 pull or push synchronization using the connection's `config.scim` settings (`base_url`, filters, `attribute_mapping`, and `deprovision_upstream_removals`).\n\n**Scopes:** `write:connections`",
        "operationId": "syncConnection",
        "tags": [
          "Connections"
        ],
        "x-ulex-scopes": [
          "write:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "direction": { "type": "string", "enum": ["pull", "push"], "default": "pull" },
                  "dry_run": { "type": "boolean", "default": false },
                  "deprovision_upstream_removals": { "type": "boolean" }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Synchronization result",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "dry_run": { "type": "boolean" },
                    "direction": { "type": "string", "enum": ["pull", "push"] },
                    "users_created": { "type": "integer" },
                    "users_updated": { "type": "integer" },
                    "users_deleted": { "type": "integer" },
                    "groups_synced": { "type": "integer" },
                    "errors": { "type": "array", "items": { "type": "string" } }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or SSRF target refused",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/connections/{id}/test-mapping": {
      "post": {
        "summary": "Dry-run attribute mapping rules against a sample upstream payload",
        "description": "Evaluates a connection's `attribute_mapping_rules` and legacy `attribute_mapping` against a caller-supplied sample OIDC claims object, SAML attributes map, or SCIM resource.\n\n**MCP tool:** `ulex_test_connection_mapping`\n\n**Scopes:** `read:connections`",
        "operationId": "testConnectionMapping",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_test_connection_mapping",
        "x-ulex-scopes": [
          "read:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "sample_payload"
                ],
                "properties": {
                  "sample_payload": {
                    "type": "object",
                    "additionalProperties": true
                  },
                  "name_id": {
                    "type": "string",
                    "maxLength": 512
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Mapped attributes and per-rule resolution trace",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Validation failed",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "404": {
            "description": "Connection not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/connections/{id}/x509/authenticate": {
      "post": {
        "summary": "Authenticate using an X.509 client certificate connection",
        "description": "Validates the peer mTLS X.509 client certificate against an active `x509_client_cert` connection's pinned CA certificates, checks clientAuth EKU and domain allowlists, JIT-provisions or resolves the user, creates an `amr: [\"hwk\"]` session, and sets the `ulex_session` cookie.",
        "operationId": "authenticateX509Connection",
        "tags": [
          "Connections"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Client certificate authenticated and session issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object"
                    },
                    "session": {
                      "type": "object"
                    },
                    "certificate": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid connection strategy or certificate format",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Missing or untrusted client certificate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Disallowed email domain or JIT creation disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Connection not found or inactive",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/connections/{id}/saml/metadata": {
      "get": {
        "summary": "Upstream IdP metadata",
        "description": "The customer's SAML `EntityDescriptor` as ulex reads it. Unauthenticated, because it is a public document.\n\n**MCP tool:** `ulex_get_saml_idp_metadata`",
        "operationId": "getConnectionIdpMetadata",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_get_saml_idp_metadata",
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          }
        ],
        "responses": {
          "200": {
            "description": "SAML metadata XML",
            "content": {
              "application/samlmetadata+xml": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "idpMetadata": {
                    "$ref": "#/components/examples/idpMetadata"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/directories": {
      "get": {
        "summary": "List directories",
        "description": "Upstream directories ulex polls, and inbound SCIM endpoints ulex exposes.\n\n**MCP tool:** `ulex_list_directories`\n\n**Scopes:** `read:directories`",
        "operationId": "listDirectories",
        "tags": [
          "Directories"
        ],
        "x-ulex-mcp-tool": "ulex_list_directories",
        "x-ulex-scopes": [
          "read:directories"
        ],
        "parameters": [
          {
            "name": "organization_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "provider",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/DirectoryProvider"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "active",
                "inactive",
                "deleting",
                "failed"
              ]
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DirectoryList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/directoryList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a directory",
        "description": "Creates both halves of the SCIM relationship: an inbound endpoint for the customer's IdP to push into, and an outbound poll target when `scim_base_url` is supplied. Tokens are never returned here; use `GET /directories/{id}/scim`.\n\n**MCP tool:** `ulex_create_directory`\n\n**Scopes:** `write:directories`",
        "operationId": "createDirectory",
        "tags": [
          "Directories"
        ],
        "x-ulex-mcp-tool": "ulex_create_directory",
        "x-ulex-scopes": [
          "write:directories"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/DirectoryCreate"
              },
              "examples": {
                "mockInbound": {
                  "$ref": "#/components/examples/directoryCreateInbound"
                },
                "oktaOutbound": {
                  "$ref": "#/components/examples/directoryCreateOutbound"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Directory"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/directory"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Directory"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/directory"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/directories/{id}": {
      "get": {
        "summary": "Get a directory",
        "description": "Returns the redacted directory configuration (encrypted tokens are omitted).\n\n**Scopes:** `read:directories`",
        "operationId": "getDirectory",
        "tags": [
          "Directories"
        ],
        "x-ulex-scopes": [
          "read:directories"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/directoryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "directory": { "$ref": "#/components/schemas/Directory" }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      },
      "patch": {
        "summary": "Update a directory",
        "description": "Updates directory settings including outbound `scim_base_url` (SSRF-checked), encrypted `scim_token`, polling interval, and poll cap.\n\n**Scopes:** `write:directories`",
        "operationId": "updateDirectory",
        "tags": [
          "Directories"
        ],
        "x-ulex-scopes": [
          "write:directories"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/directoryId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": false,
                "properties": {
                  "name": { "type": "string", "minLength": 1, "maxLength": 120 },
                  "state": { "type": "string", "enum": ["pending", "active", "inactive", "deleting", "failed"] },
                  "scim_base_url": { "type": "string", "format": "uri", "nullable": true },
                  "scim_token": { "type": "string", "nullable": true },
                  "scim_poll_interval_seconds": { "type": "integer", "minimum": 60, "maximum": 86400 },
                  "scim_max_users_per_poll": { "type": "integer", "minimum": 1, "maximum": 10000 }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated directory",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "directory": { "$ref": "#/components/schemas/Directory" }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or SSRF target refused",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ErrorEnvelope" }
              }
            }
          }
        },
        "security": [
          { "bearerApiKey": [] }
        ]
      }
    },
    "/directories/{id}/sync": {
      "post": {
        "summary": "Trigger a directory sync",
        "description": "**Fire and forget.** Returns immediately with `state: pending|running`. Poll `GET /directories/{id}/syncs` (or the MCP `ulex_get_sync_status`) until the state is terminal. A 200 here does not mean the sync worked. Not idempotent: every call starts a new run.\n\n**MCP tool:** `ulex_sync_directory`\n\n**Scopes:** `write:directories`",
        "operationId": "syncDirectory",
        "tags": [
          "Directories"
        ],
        "x-ulex-mcp-tool": "ulex_sync_directory",
        "x-ulex-scopes": [
          "write:directories"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/directoryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DirectorySync"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/directorySync"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/directories/{id}/syncs": {
      "get": {
        "summary": "List directory sync runs",
        "description": "Every run, newest last. `stats` breaks the run down by created/updated/deactivated/failed users and synced groups.\n\n**MCP tool:** `ulex_get_sync_status`\n\n**Scopes:** `read:directories`",
        "operationId": "listDirectorySyncs",
        "tags": [
          "Directories"
        ],
        "x-ulex-mcp-tool": "ulex_get_sync_status",
        "x-ulex-scopes": [
          "read:directories"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/directoryId"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "running",
                "succeeded",
                "partial",
                "failed",
                "cancelled"
              ]
            }
          },
          {
            "name": "trigger",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "scheduled",
                "manual",
                "webhook",
                "scim_push"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DirectorySyncList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/directorySyncList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/scim/v2/ServiceProviderConfig": {
      "get": {
        "summary": "ServiceProviderConfig",
        "description": "What this SCIM server supports: patch, bulk, filter grammar, sort, etag, and the single supported authentication scheme.\n\n**MCP tool:** `ulex_get_scim_configuration`\n\n**Scopes:** `read:users` `read:groups` `scim:provision`",
        "operationId": "getScimServiceProviderConfig",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_get_scim_configuration",
        "x-ulex-scopes": [
          "read:users",
          "read:groups",
          "scim:provision"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimServiceProviderConfig"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimServiceProviderConfig"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Schemas": {
      "get": {
        "summary": "Schemas",
        "description": "Core User, core Group, PatchOp, BulkRequest, BulkResponse, ListResponse and Error. Full definitions in the SCIM schema reference.\n\n**MCP tool:** `ulex_get_scim_configuration`",
        "operationId": "getScimSchemas",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_get_scim_configuration",
        "responses": {
          "200": {
            "description": "Schema list",
            "content": {
              "application/scim+json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "examples": {
                  "schemas": {
                    "$ref": "#/components/examples/scimSchemas"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/ResourceTypes": {
      "get": {
        "summary": "ResourceTypes",
        "description": "`User` at `/Users` and `Group` at `/Groups`. Nothing else is provisioned.\n\n**MCP tool:** `ulex_get_scim_configuration`",
        "operationId": "getScimResourceTypes",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_get_scim_configuration",
        "responses": {
          "200": {
            "description": "Resource types",
            "content": {
              "application/scim+json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                },
                "examples": {
                  "resourceTypes": {
                    "$ref": "#/components/examples/scimResourceTypes"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Users": {
      "get": {
        "summary": "List SCIM users",
        "description": "RFC 7644 offset paging: `startIndex` is 1-based and `count` is 1–200. An empty `Resources` array means you have reached the end. `filter` supports `eq ne co sw ew gt lt ge le pr`, `and or not`, parentheses, and attribute paths such as `emails[type eq \"work\"].value`. A non-unique `eq` match is 400 `tooMany`.\n\n**MCP tool:** `ulex_list_users`\n\n**Scopes:** `read:users`",
        "operationId": "scimListUsers",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_list_users",
        "x-ulex-scopes": [
          "read:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "filter",
            "in": "query",
            "description": "SCIM filter, e.g. userName eq \"pat@acme.example\".",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "description": "1-based offset.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "default": 1
            }
          },
          {
            "name": "count",
            "in": "query",
            "description": "Page size.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ascending",
                "descending"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimListUsers"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "post": {
        "summary": "Create a SCIM user",
        "description": "What Okta and Entra POST. Creates the tenant-global user **and** an `organization_membership` with `role: member` in the directory's organization, plus a `user_directory_id` link. Emits `dsync.user.created` and `user.created`. A duplicate `userName` or `externalId` is 409 with `scimType: uniqueness`, not a silent second user.\n\n**MCP tool:** `ulex_provision_scim_user`\n\n**Scopes:** `write:users` `scim:provision`",
        "operationId": "scimCreateUser",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_provision_scim_user",
        "x-ulex-scopes": [
          "write:users",
          "scim:provision"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimUser"
              },
              "examples": {
                "request": "scimUserCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimUser"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                },
                "examples": {
                  "created": {
                    "$ref": "#/components/examples/scimUser"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "uniqueness": "scimErrorUniqueness"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Users/{id}": {
      "get": {
        "summary": "Read a SCIM user",
        "description": "One user, SCIM-projected.\n\n**MCP tool:** `ulex_list_users`\n\n**Scopes:** `read:users`",
        "operationId": "scimGetUser",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_list_users",
        "x-ulex-scopes": [
          "read:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimUser"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "notFound": "scimErrorNotFound"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "put": {
        "summary": "Replace a SCIM user",
        "description": "A **full replace**. Omit `active` and the user becomes inactive. `id` and `schemas` are immutable. Prefer `PATCH`.\n\n**MCP tool:** `ulex_provision_scim_user`\n\n**Scopes:** `write:users` `scim:provision`",
        "operationId": "scimReplaceUser",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_provision_scim_user",
        "x-ulex-scopes": [
          "write:users",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "description": "Optimistic lock, e.g. W/\"v1.0\". A stale version is 412.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimUser"
              },
              "examples": {
                "request": "scimUserReplace"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimUser"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "mutability": "scimErrorMutability"
                }
              }
            }
          },
          "412": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "staleEtag": "scimErrorStaleEtag"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "patch": {
        "summary": "Patch a SCIM user",
        "description": "`PatchOp` with `add`, `replace` and `remove`. `If-Match` with a stale `meta.version` is 412 `mutability`, which is the intended optimistic-lock behaviour: re-read and re-apply. `remove` with a `value` removes that array element; without one it clears the attribute.\n\n**MCP tool:** `ulex_provision_scim_user`\n\n**Scopes:** `write:users` `scim:provision`",
        "operationId": "scimPatchUser",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_provision_scim_user",
        "x-ulex-scopes": [
          "write:users",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "If-Match",
            "in": "header",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimPatchOp"
              },
              "examples": {
                "request": "scimUserPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUser"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimUserPatched"
                  }
                }
              }
            }
          },
          "400": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "invalidPath": "scimErrorInvalidPath"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "412": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "staleEtag": "scimErrorStaleEtag"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "delete": {
        "summary": "Deprovision a SCIM user",
        "description": "Sets `status: suspended` and `scim.active: false`, revokes every session and refresh-token family, emits `dsync.user.deleted`, `user.deleted` and `user.suspended`, and writes `user.suspended` to the audit log. **Tenant-wide**: if the person also belongs to another customer, they are suspended everywhere. To remove only one membership, call `DELETE /organizations/{id}/members/{userId}` instead.\n\n**MCP tool:** `ulex_deprovision_scim_user`\n\n**Scopes:** `write:users` `scim:provision`",
        "operationId": "scimDeleteUser",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_deprovision_scim_user",
        "x-ulex-scopes": [
          "write:users",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "notFound": "scimErrorNotFound"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Groups": {
      "get": {
        "summary": "List SCIM groups",
        "description": "Offset-paged like `/scim/v2/Users`.\n\n**MCP tool:** `ulex_list_groups`\n\n**Scopes:** `read:groups`",
        "operationId": "scimListGroups",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_list_groups",
        "x-ulex-scopes": [
          "read:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "filter",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "startIndex",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "count",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200
            }
          },
          {
            "name": "sortBy",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "sortOrder",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ascending",
                "descending"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimListResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimListGroups"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "post": {
        "summary": "Create a SCIM group",
        "description": "A ulex group scoped to the directory's organization with `source: scim` and `scim_id` set to `externalId`. `members[].value` may be an existing user id or a `bulkId` from the same Bulk request.\n\n**MCP tool:** `ulex_create_group`\n\n**Scopes:** `write:groups` `scim:provision`",
        "operationId": "scimCreateGroup",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_create_group",
        "x-ulex-scopes": [
          "write:groups",
          "scim:provision"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimGroup"
              },
              "examples": {
                "request": "scimGroupCreate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimGroup"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Created",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                },
                "examples": {
                  "created": {
                    "$ref": "#/components/examples/scimGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "uniqueness": "scimErrorUniqueness"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Groups/{id}": {
      "get": {
        "summary": "Read a SCIM group",
        "description": "One group with its resolved members.\n\n**MCP tool:** `ulex_list_groups`\n\n**Scopes:** `read:groups`",
        "operationId": "scimGetGroup",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_list_groups",
        "x-ulex-scopes": [
          "read:groups"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "notFound": "scimErrorNotFound"
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "put": {
        "summary": "Replace a SCIM group",
        "description": "Full replace of the group and its member list.\n\n**MCP tool:** `ulex_set_group_members`\n\n**Scopes:** `write:groups` `scim:provision`",
        "operationId": "scimReplaceGroup",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_set_group_members",
        "x-ulex-scopes": [
          "write:groups",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimGroup"
              },
              "examples": {
                "request": "scimGroupReplace"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "mutability": "scimErrorMutability"
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "patch": {
        "summary": "Patch a SCIM group",
        "description": "`PatchOp`, including `add` and `remove` against `members`.\n\n**MCP tool:** `ulex_set_group_members`\n\n**Scopes:** `write:groups` `scim:provision`",
        "operationId": "scimPatchGroup",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_set_group_members",
        "x-ulex-scopes": [
          "write:groups",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimPatchOp"
              },
              "examples": {
                "request": "scimGroupPatch"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroup"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimGroup"
                  }
                }
              }
            }
          },
          "400": {
            "description": "SCIM error (RFC 7644 §3.12)",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "invalidPath": "scimErrorInvalidPath"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      },
      "delete": {
        "summary": "Delete a SCIM group",
        "description": "Removes the group from every membership's `group_ids`. Users are not deleted.\n\n**MCP tool:** `ulex_delete_group`\n\n**Scopes:** `write:groups` `scim:provision`",
        "operationId": "scimDeleteGroup",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_delete_group",
        "x-ulex-scopes": [
          "write:groups",
          "scim:provision"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/groupId"
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/scim/v2/Bulk": {
      "post": {
        "summary": "Bulk operations",
        "description": "Up to 100 operations and 10 MiB per request. `failOnErrors: 0` runs everything and reports per-operation; `>= 1` aborts after the Nth failure. `bulkId` must be unique within the request and is how a group operation references users created earlier in the same request. Exceeding 100 is 413 `scim_bulk_exceeded`. A per-operation failure appears in `Operations[].response` while the HTTP status of the call itself is still 200.\n\n**MCP tool:** `ulex_sync_directory`\n\n**Scopes:** `write:users` `write:groups` `scim:provision`",
        "operationId": "scimBulk",
        "tags": [
          "SCIM"
        ],
        "x-ulex-mcp-tool": "ulex_sync_directory",
        "x-ulex-scopes": [
          "write:users",
          "write:groups",
          "scim:provision"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/scim+json": {
              "schema": {
                "$ref": "#/components/schemas/ScimBulkRequest"
              },
              "examples": {
                "request": "scimBulk"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimBulkResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/scimBulkResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "413": {
            "description": "More than 100 operations",
            "content": {
              "application/scim+json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimError"
                },
                "examples": {
                  "tooLarge": {
                    "$ref": "#/components/examples/scimErrorBulkExceeded"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "scimBearerToken": []
          }
        ]
      }
    },
    "/.well-known/openid-configuration": {
      "get": {
        "summary": "OpenID Connect discovery",
        "description": "Issuer `https://{env}.ulexid.com`. Unauthenticated and not rate limited, because every OIDC library fetches it at startup.\n\n**MCP tool:** `ulex_get_oidc_discovery`",
        "operationId": "getOpenIdConfiguration",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_get_oidc_discovery",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OidcDiscovery"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/openidConfiguration"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "summary": "RFC 8414 authorization server metadata",
        "description": "The same document as the OIDC discovery endpoint. Compatibility alias for clients that do not speak OIDC discovery.\n\n**MCP tool:** `ulex_get_oidc_discovery`",
        "operationId": "getAuthorizationServerMetadata",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_get_oidc_discovery",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OidcDiscovery"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/openidConfiguration"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/.well-known/oauth-protected-resource": {
      "get": {
        "summary": "RFC 9728 protected resource metadata",
        "description": "Advertises the MCP endpoint as an OAuth 2.1 protected resource. An unauthenticated `POST /mcp` returns 401 with a `WWW-Authenticate` header pointing here, so a client can discover the authorization server and run authorization-code-with-PKCE with `resource=https://{env}.ulexid.com/api/v1` (RFC 8707).\n\n**MCP tool:** `ulex_get_status`",
        "operationId": "getProtectedResourceMetadata",
        "tags": [
          "MCP"
        ],
        "x-ulex-mcp-tool": "ulex_get_status",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthProtectedResource"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/oauthProtectedResource"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/oauth2/authorize": {
      "get": {
        "summary": "Authorization endpoint",
        "description": "The interactive half of the flow, for humans. With `response_mode: form_post` the success case is a 303 to a self-posting form containing `code`, `state` and `iss`. Errors redirect **only** when `redirect_uri` and `state` both validate; otherwise a rendered error page is returned, because redirecting an unvalidated URI is how open redirects happen. Agents should not drive this endpoint — use `ulex_simulate_login`, which runs the identical transaction and returns JSON.\n\n**MCP tool:** `ulex_get_authorization_url`",
        "operationId": "authorize",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_get_authorization_url",
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "description": "`code` only, in prod.",
            "schema": {
              "type": "string",
              "enum": [
                "code",
                "id_token",
                "code id_token"
              ]
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "description": "Must be an exact member of the application's `redirect_uris`.",
            "schema": {
              "$ref": "#/components/schemas/HttpsUrl"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": true,
            "description": "Space separated. Must include `openid` for an OIDC request.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "Opaque, echoed, your CSRF defence.",
            "schema": {
              "type": "string",
              "maxLength": 2048
            }
          },
          {
            "name": "nonce",
            "in": "query",
            "description": "Required whenever an `id_token` is returned.",
            "schema": {
              "type": "string",
              "maxLength": 512
            }
          },
          {
            "name": "code_challenge",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 128
            }
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "S256",
                "plain"
              ]
            }
          },
          {
            "name": "organization",
            "in": "query",
            "description": "Organization id or slug; resolves the connection.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "prompt",
            "in": "query",
            "description": "Space separated.",
            "schema": {
              "type": "string",
              "enum": [
                "none",
                "login",
                "consent",
                "select_account",
                "create",
                "mfa",
                "step_up"
              ]
            }
          },
          {
            "name": "max_age",
            "in": "query",
            "description": "Re-authenticate if the session is older, in seconds.",
            "schema": {
              "type": "integer",
              "minimum": 0,
              "maximum": 31536000
            }
          },
          {
            "name": "acr_values",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "ui_locales",
            "in": "query",
            "description": "BCP-47, space separated.",
            "schema": {
              "type": "string",
              "maxLength": 256
            }
          },
          {
            "name": "login_hint",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Email"
            }
          },
          {
            "name": "claims",
            "in": "query",
            "description": "JSON object of requested claims.",
            "schema": {
              "type": "string",
              "maxLength": 2048
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hosted sign-in UI, HTML",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "signIn": {
                    "$ref": "#/components/examples/hostedSignInHtml"
                  }
                }
              }
            }
          },
          "302": {
            "description": "Error redirect. `error`, `error_description`, `state` and `iss` are query parameters.",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "303": {
            "description": "Success redirect (form_post)",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                },
                "description": "The application's redirect_uri."
              }
            }
          },
          "400": {
            "description": "Unvalidated redirect_uri; rendered error page",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/hostedSignInErrorHtml"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/oauth2/consent": {
      "get": {
        "summary": "Consent screen",
        "description": "The approval screen for a `third_party` application. Reached by redirect from `/oauth2/authorize` or the hosted login, carrying an opaque `request` token that names one pending authorization. The token is signed and bound to the session that started it, so the screen will not render for a different browser.\n\n**This is a browser endpoint.** It renders HTML and takes no API key; an agent should read the grant list rather than drive the screen.",
        "operationId": "consent",
        "tags": [
          "OAuth"
        ],
        "parameters": [
          {
            "name": "request",
            "in": "query",
            "required": true,
            "description": "The pending approval token. Single-use, and valid for ten minutes.",
            "schema": {
              "type": "string",
              "maxLength": 4096
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The approval screen, HTML",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "302": {
            "description": "Consent is no longer needed (a grant appeared in another tab); the authorization completes",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The token is malformed, expired, or not valid here",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "No session, or the session the request was bound to has ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "The application named by the token does not exist in this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Record a consent decision",
        "description": "Approve or refuse the pending request. The decision is bound to the token: the same token cannot be decided twice, and it cannot be decided by a browser holding a different session.\n\nOn approval the grant is recorded (widening any existing one), `consent.granted` is written to the audit log, and the response is the authorization response the client asked for: a 302 to its `redirect_uri` carrying the code, or a `form_post` page. On refusal nothing is granted, `consent.denied` is written, and the client receives `error=access_denied` at its `redirect_uri` with its own `state`.",
        "operationId": "decideConsent",
        "tags": [
          "OAuth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "consent_request",
                  "decision"
                ],
                "properties": {
                  "consent_request": {
                    "type": "string",
                    "maxLength": 4096,
                    "description": "The token the screen was rendered with."
                  },
                  "decision": {
                    "type": "string",
                    "enum": [
                      "approve",
                      "deny"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "302": {
            "description": "Approved: the client's redirect_uri with a code. Refused: the same address with `error=access_denied`",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "The token was already used, the decision was neither approve nor deny, or the request came from another origin",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "No session, or the session the request was bound to has ended",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "The application named by the token does not exist in this tenant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/oauth2/token": {
      "post": {
        "summary": "Token endpoint",
        "description": "Supports `authorization_code`, `refresh_token`, `client_credentials`, `device_code` and RFC 8693 `token-exchange`. The implicit grant and the password grant are **not implemented**; OAuth 2.1 removes both. **Refresh tokens rotate on every use**: persist the new one atomically with the new access token. Replaying a spent refresh token revokes the whole `family_id` and returns `invalid_grant` with `retryable: false` — start a new login rather than retrying. Rate limit: 30 requests per minute per client.\n\n**MCP tool:** `ulex_exchange_code_for_tokens`\n\n**Scopes:** `openid` `profile` `email` `offline_access`",
        "operationId": "token",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_exchange_code_for_tokens",
        "x-ulex-scopes": [
          "openid",
          "profile",
          "email",
          "offline_access"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/tokenResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "OAuth error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "examples": {
                  "invalidGrant": {
                    "$ref": "#/components/examples/oauthErrorInvalidGrant"
                  },
                  "invalidClient": {
                    "$ref": "#/components/examples/oauthErrorInvalidClient"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Client authentication failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "examples": {
                  "invalidClient": {
                    "$ref": "#/components/examples/oauthErrorInvalidClient"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Token endpoint rate limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/oauthErrorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                },
                "description": "Seconds to wait."
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/oauth2/userinfo": {
      "get": {
        "summary": "Userinfo",
        "description": "OIDC standard claims plus ulex claims (`org_id`, `org_slug`, `connection_id`, `sid`, `amr`, `acr`). Requires the matching `profile`/`email` scopes. **A refresh token here is 401 `invalid_token`** — introspection is the only place a refresh token is accepted.\n\n**MCP tool:** `ulex_get_userinfo`\n\n**Scopes:** `openid` `profile` `email`",
        "operationId": "getUserinfo",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_get_userinfo",
        "x-ulex-scopes": [
          "openid",
          "profile",
          "email"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Userinfo"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/userinfo"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/oauth2/introspect": {
      "post": {
        "summary": "Introspect a token (RFC 7662)",
        "description": "Requires OAuth **client** authentication (HTTP Basic, as at the token endpoint). RFC 7662 §2.1 requires authorization on this endpoint, and without it the endpoint is a token-validity oracle over the whole environment: signing keys are resolved from the token's own `iss`, so an anonymous caller learns whether any token is live, which client holds it, and which user it names.\n\nAn unknown, expired, or revoked token returns **200 with `active: false`**, never 401: an authenticated caller must not be able to turn introspection into an oracle for token validity. An unauthenticated call, a wrong secret, or an unknown client is **401 `invalid_client`** with nothing about the token in the body.\n\nA client authenticated under a tenant prefix may only introspect that tenant's tokens; a token from another tenant returns `active: false` rather than an error.\n\n**MCP tool:** `ulex_introspect_token`",
        "operationId": "introspectToken",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_introspect_token",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "token_type_hint": {
                    "type": "string",
                    "enum": [
                      "access_token",
                      "refresh_token"
                    ]
                  }
                }
              },
              "examples": {
                "request": "introspectToken"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntrospectionResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/introspectionResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/oauth2/revoke": {
      "post": {
        "summary": "Revoke a token (RFC 7009)",
        "description": "Revoking a **refresh token** revokes the whole `family_id` and returns `family_revoked: true`. Revoking an **access token** revokes only that token. Add `revoke_session: true` to revoke everything issued in the same session. An already-revoked or unknown token returns `200 {\"revoked\": true}` — never 400.\n\n**MCP tool:** `ulex_revoke_tokens`",
        "operationId": "revokeToken",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_revoke_tokens",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "token_type_hint": {
                    "type": "string",
                    "enum": [
                      "access_token",
                      "refresh_token",
                      "id_token"
                    ]
                  },
                  "revoke_session": {
                    "type": "boolean"
                  }
                }
              },
              "examples": {
                "request": "revokeToken"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/revokeResponse"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/oauth2/keys": {
      "get": {
        "summary": "JSON Web Key Set",
        "description": "Public and unrate-limited. **Cache it**: during a key rotation the JWKS contains two keys, the new `active` one and the retiring one. A consumer that pins a single `kid` breaks on rotation; a `kid`-keyed map with a 15-minute TTL does not.\n\n**MCP tool:** `ulex_get_oidc_discovery`",
        "operationId": "getJwks",
        "tags": [
          "OAuth"
        ],
        "x-ulex-mcp-tool": "ulex_get_oidc_discovery",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Jwks"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/jwks"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": []
      }
    },
    "/webhooks": {
      "get": {
        "summary": "List webhook endpoints",
        "description": "Secrets are never included; only `secret_prefix`.\n\n**MCP tool:** `ulex_list_webhooks`\n\n**Scopes:** `read:webhooks`",
        "operationId": "listWebhooks",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_list_webhooks",
        "x-ulex-scopes": [
          "read:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "enabled",
                "disabled"
              ]
            }
          },
          {
            "name": "event",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhookList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "post": {
        "summary": "Create a webhook endpoint",
        "description": "Returns the HMAC-SHA256 `secret` in `secret` **exactly once**; it is stored encrypted and is not retrievable again. Unknown event names are rejected at create time, not silently ignored. `http://` is accepted only for loopback; loopback, link-local, RFC 1918 and cloud-metadata hosts are blocked at create time and again at every delivery.\n\n**MCP tool:** `ulex_create_webhook`\n\n**Scopes:** `write:webhooks`",
        "operationId": "createWebhook",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_create_webhook",
        "x-ulex-scopes": [
          "write:webhooks"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              },
              "examples": {
                "identityEvents": {
                  "$ref": "#/components/examples/webhookCreate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookWithSecret"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhookWithSecret"
                  }
                }
              }
            }
          },
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookWithSecret"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhookWithSecret"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/webhooks/{id}": {
      "patch": {
        "summary": "Update a webhook endpoint",
        "description": "Change the URL, the event set, the description, or the API version.\n\n**MCP tool:** `ulex_list_webhooks`\n\n**Scopes:** `write:webhooks`",
        "operationId": "updateWebhook",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_update_webhook",
        "x-ulex-scopes": [
          "write:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/webhookId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookCreate"
              },
              "examples": {
                "trimEvents": {
                  "$ref": "#/components/examples/webhookUpdate"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhook"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Delete a webhook endpoint",
        "description": "Removes the endpoint. Its delivery records are retained for the retention window.\n\n**MCP tool:** `ulex_list_webhooks`\n\n**Scopes:** `write:webhooks`",
        "operationId": "deleteWebhook",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_delete_webhook",
        "x-ulex-scopes": [
          "write:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/webhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deleted"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deletedWebhook"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/webhooks/{id}/deliveries": {
      "get": {
        "summary": "List deliveries for an endpoint",
        "description": "Every attempt, including the ones that failed and the ones that are queued for retry. This is how you diagnose a broken receiver.\n\n**MCP tool:** `ulex_list_webhook_deliveries`\n\n**Scopes:** `read:webhooks`",
        "operationId": "listWebhookDeliveries",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_list_webhook_deliveries",
        "x-ulex-scopes": [
          "read:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "$ref": "#/components/parameters/webhookId"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "pending",
                "in_flight",
                "delivered",
                "failed",
                "dead_lettered"
              ]
            }
          },
          {
            "name": "event",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhookDeliveryList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/webhook-deliveries/{id}": {
      "get": {
        "summary": "Read one delivery",
        "description": "Includes `response_status` and up to 2,000 characters of `response_body`.\n\n**MCP tool:** `ulex_get_webhook_delivery`\n\n**Scopes:** `read:webhooks`",
        "operationId": "getWebhookDelivery",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_get_webhook_delivery",
        "x-ulex-scopes": [
          "read:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/deliveryId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDelivery"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/webhookDelivery"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/audit-events": {
      "get": {
        "summary": "Query the audit log",
        "description": "Append-only and hash-chained; entries can never be updated or deleted through any API, by any scope, including `ulex:admin`. All filters are AND-combined; there is no free-text search and no OR. Use `action_prefix` (`authentication.`) to get a whole family in one call. `actor_type=agent` isolates what MCP clients did. `request_id` and `correlation_id` are the values you sent as `X-Ulex-Request-Id` and `X-Ulex-Correlation-Id`.\n\n**MCP tool:** `ulex_search_audit_logs`\n\n**Scopes:** `read:audit_logs`",
        "operationId": "listAuditEvents",
        "tags": [
          "Audit"
        ],
        "x-ulex-mcp-tool": "ulex_search_audit_logs",
        "x-ulex-scopes": [
          "read:audit_logs"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "action",
            "in": "query",
            "description": "Exact action.",
            "schema": {
              "$ref": "#/components/schemas/AuditAction"
            }
          },
          {
            "name": "action_prefix",
            "in": "query",
            "description": "e.g. `authentication.`",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "category",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "authentication",
                "authorization",
                "configuration",
                "data_access",
                "data_modification",
                "provisioning",
                "security",
                "system"
              ]
            }
          },
          {
            "name": "actor_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "actor_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "user",
                "api_key",
                "system",
                "service",
                "agent"
              ]
            }
          },
          {
            "name": "target_id",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "organization_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "connection_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "session_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "request_id",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "correlation_id",
            "in": "query",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          },
          {
            "name": "outcome",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "success",
                "failure",
                "denied"
              ]
            }
          },
          {
            "name": "error_code",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/ErrorCode"
            }
          },
          {
            "name": "since",
            "in": "query",
            "description": "Inclusive ISO-8601 instant.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "until",
            "in": "query",
            "description": "Exclusive ISO-8601 instant.",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditEventList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/auditEventList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/audit-events/{id}": {
      "get": {
        "summary": "Read one audit event",
        "description": "Returns the event plus its chain link so you can verify the hash chain locally. `entry_hash = sha256(previous_hash || canonical_json(event_without_chain))`.\n\n**MCP tool:** `ulex_get_audit_event`\n\n**Scopes:** `read:audit_logs`",
        "operationId": "getAuditEvent",
        "tags": [
          "Audit"
        ],
        "x-ulex-mcp-tool": "ulex_get_audit_event",
        "x-ulex-scopes": [
          "read:audit_logs"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/auditEventId"
          }
        ],
        "responses": {
          "200": {
            "description": "Audit event and its chain link",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "audit_event": {
                      "$ref": "#/components/schemas/AuditEvent"
                    },
                    "chain": {
                      "$ref": "#/components/schemas/AuditChain"
                    }
                  }
                },
                "examples": {
                  "event": {
                    "$ref": "#/components/examples/auditEvent"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/audit-events/verify_chain": {
      "post": {
        "summary": "Verify the audit hash chain",
        "description": "Recomputes every `entry_hash` over a window and checks the chain's links and order, naming which kind of failure occurred rather than collapsing to a boolean.\n\n**The order comes from the entries' own `previous_hash` links, not from the order the store returned them in.** The storage sort key is the timestamp with the event id as a tiebreaker, and that id suffix is random, so two entries in the same second — which is what concurrency produces, routinely — sort in an order unrelated to the one they were committed in. An earlier implementation trusted the sort order and reported intact chains as `missing_predecessor` under concurrent writes, with the previous entry's `expected_previous` sitting in the very next row of results.\n\nThe order being derived from the links makes \"does this entry link to the previous one\" true by construction, so the check that carries information is **monotonicity**: the chain's own order must agree with the clock. That, plus reachability (every entry supplied is on some branch) and content (each entry hashes to its recorded value), is what is verified.\n\n**`failure.kind` is `hash_mismatch`, `missing_predecessor`, `broken_link`, or `unverifiable`, and only `hash_mismatch` is evidence the log was altered.** The other three are ulex-side — a lost write, two appenders racing for the same predecessor, a clock behind, or a hash written by a formula that cannot be recomputed from storage. `guidance.severity` is returned so a caller never has to decide that by itself, and answering `409` rather than `200` on failure keeps a failed integrity check from being mistaken for a successful request.\n\nThe body is strict: `from` and `to` only, both optional, defaulting to the last 24 hours. An unknown key is a `400` rather than a silently narrower window.\n\nReturns `valid: true` over an untouched log, always. **MCP tool:** `ulex_verify_audit_chain`  ·  **Scopes:** `read:audit_logs`",
        "operationId": "verifyAuditChain",
        "tags": [
          "Audit"
        ],
        "x-ulex-mcp-tool": "ulex_verify_audit_chain",
        "x-ulex-scopes": [
          "read:audit_logs"
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuditChainVerify"
              },
              "examples": {
                "window": {
                  "$ref": "#/components/examples/verifyChain"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditChainVerifyResult"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/verifyChainResult"
                  },
                  "midChainWindow": {
                    "$ref": "#/components/examples/verifyChainTruncated"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "The chain failed inside the window. The body is the same shape as a success, with `valid: false`, a `failure`, and the `guidance` that says what it is worth — `severity: security` only for `hash_mismatch`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuditChainVerifyResult"
                },
                "examples": {
                  "broken": {
                    "$ref": "#/components/examples/verifyChainBroken"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/deployments": {
      "get": {
        "summary": "List deployments",
        "description": "List responses omit `steps` and `issued` for bandwidth. Read the individual deployment for those.\n\n**MCP tool:** `ulex_list_deployments`\n\n**Scopes:** `read:deployments`",
        "operationId": "listDeployments",
        "tags": [
          "Deployments"
        ],
        "x-ulex-mcp-tool": "ulex_list_deployments",
        "x-ulex-scopes": [
          "read:deployments"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "application_id",
            "in": "query",
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          },
          {
            "name": "environment",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "dev",
                "stage",
                "prod"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "queued",
                "provisioning",
                "configuring",
                "building",
                "deploying",
                "verifying",
                "succeeded",
                "failed",
                "cancelled",
                "rolled_back"
              ]
            }
          },
          {
            "name": "branch",
            "in": "query",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "commit_sha",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deploymentList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/deployments/{id}": {
      "get": {
        "summary": "Read a deployment",
        "description": "Includes `steps`, `resources` and `issued`. **Poll on `state`, not on `progress_percent`** — two steps can share a percentage. Terminal states are `succeeded`, `failed`, `cancelled` and `rolled_back`.\n\n**MCP tool:** `ulex_get_deployment`\n\n**Scopes:** `read:deployments`",
        "operationId": "getDeployment",
        "tags": [
          "Deployments"
        ],
        "x-ulex-mcp-tool": "ulex_get_deployment",
        "x-ulex-scopes": [
          "read:deployments"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/deploymentId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deployment"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deploymentSucceeded"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/deployments/{id}/cancel": {
      "post": {
        "summary": "Cancel a deployment",
        "description": "Terminal. Cancelling a `succeeded`, `cancelled` or `rolled_back` deployment is 409 `invalid_state_transition`.\n\n**MCP tool:** `ulex_cancel_deployment`\n\n**Scopes:** `write:deployments`",
        "operationId": "cancelDeployment",
        "tags": [
          "Deployments"
        ],
        "x-ulex-mcp-tool": "ulex_cancel_deployment",
        "x-ulex-scopes": [
          "write:deployments"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/deploymentId"
          },
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Deployment"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deploymentCancelled"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/deployments/{id}/logs": {
      "get": {
        "summary": "Read deployment logs",
        "description": "Structured, already redacted: no client secrets, no tokens, no raw environment values. Omit `step` for all steps. `tail` defaults to 200, max 2,000.\n\n**MCP tool:** `ulex_get_deployment_logs`\n\n**Scopes:** `read:deployments`",
        "operationId": "getDeploymentLogs",
        "tags": [
          "Deployments"
        ],
        "x-ulex-mcp-tool": "ulex_get_deployment_logs",
        "x-ulex-scopes": [
          "read:deployments"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/deploymentId"
          },
          {
            "name": "step",
            "in": "query",
            "description": "Step name, e.g. `verify`.",
            "schema": {
              "type": "string",
              "maxLength": 80
            }
          },
          {
            "name": "tail",
            "in": "query",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 2000,
              "default": 200
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DeploymentLogs"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/deploymentLogs"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/environments": {
      "get": {
        "summary": "List environments",
        "description": "Returns the active control-plane environment entry (`https://ulexid.com`). `slug` is the deployment target identifier (`production`, mapping to `prod`).\n\n**MCP tool:** `ulex_list_environments`",
        "operationId": "listEnvironments",
        "tags": [
          "Environments"
        ],
        "x-ulex-mcp-tool": "ulex_list_environments",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EnvironmentList"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/environmentList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/mcp": {
      "post": {
        "summary": "MCP Streamable HTTP",
        "description": "JSON-RPC 2.0 over Streamable HTTP, protocol `2025-06-18`. Send `Accept: application/json, text/event-stream`. `initialize` returns an `Mcp-Session-Id` header; carry it on every subsequent call and send `DELETE /mcp` to terminate. Every ulex tool returns the resource in both `content[0].text` (JSON string) and `structuredContent` (typed object) — read `structuredContent`. A tool failure is a **successful** JSON-RPC response with `result.isError: true` and the ulex error envelope inside `content[0].text`; a protocol failure uses the standard JSON-RPC `error` object with codes -32700/-32600/-32601/-32602/-32603. The environment comes from the credential and is never a tool argument.\n\n**MCP tool:** `ulex_list_tools`\n\n**Scopes:** `mcp:tools`",
        "operationId": "mcpPost",
        "tags": [
          "MCP"
        ],
        "x-ulex-mcp-tool": "ulex_list_tools",
        "x-ulex-scopes": [
          "mcp:tools"
        ],
        "parameters": [
          {
            "name": "MCP-Protocol-Version",
            "in": "header",
            "required": false,
            "description": "`2025-06-18`.",
            "schema": {
              "type": "string",
              "enum": [
                "2025-03-26",
                "2025-06-18"
              ]
            }
          },
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": false,
            "description": "From the `initialize` response.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/McpResult"
                  },
                  {
                    "$ref": "#/components/schemas/McpError"
                  },
                  {
                    "type": "object",
                    "additionalProperties": true
                  }
                ]
              },
              "examples": {
                "initialize": {
                  "$ref": "#/components/examples/mcpInitialize"
                },
                "toolsCall": {
                  "$ref": "#/components/examples/mcpToolsCall"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SSE-framed JSON-RPC response",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "initialize": {
                    "$ref": "#/components/examples/mcpInitializeResponse"
                  },
                  "toolCall": {
                    "$ref": "#/components/examples/mcpToolsCallResponse"
                  },
                  "toolError": {
                    "$ref": "#/components/examples/mcpToolErrorResponse"
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted; no body. Returned for notifications such as `notifications/initialized`.",
            "headers": {
              "Mcp-Session-Id": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            },
            "headers": {
              "WWW-Authenticate": {
                "schema": {
                  "type": "string"
                },
                "description": "Bearer realm=\"ulex\", resource_metadata=\"https://{env}.ulexid.com/api/v1/.well-known/oauth-protected-resource\""
              }
            }
          },
          "403": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "mcp:tools"
            ]
          }
        ]
      },
      "get": {
        "summary": "MCP server-sent events stream",
        "description": "Opens the SSE channel for server-initiated messages on an established session. Also used for the stdio-adjacent `notifications/tools/list_changed` flow.\n\n**MCP tool:** `ulex_list_tools`\n\n**Scopes:** `mcp:tools`",
        "operationId": "mcpGet",
        "tags": [
          "MCP"
        ],
        "x-ulex-mcp-tool": "ulex_list_tools",
        "x-ulex-scopes": [
          "mcp:tools"
        ],
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "Last-Event-ID",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SSE stream",
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "examples": {
                  "frame": {
                    "$ref": "#/components/examples/mcpSseStream"
                  }
                }
              }
            }
          },
          "400": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "mcp:tools"
            ]
          }
        ]
      },
      "delete": {
        "summary": "Terminate an MCP session",
        "description": "Ends the session and releases the handle. Subsequent calls with that `Mcp-Session-Id` are 404. Idempotent.\n\n**MCP tool:** `ulex_list_tools`\n\n**Scopes:** `mcp:tools`",
        "operationId": "mcpDelete",
        "tags": [
          "MCP"
        ],
        "x-ulex-mcp-tool": "ulex_list_tools",
        "x-ulex-scopes": [
          "mcp:tools"
        ],
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success"
          },
          "204": {
            "description": "Session terminated"
          },
          "400": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "404": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "A JSON-RPC 2.0 error. The MCP transport answers protocol-level failures in the JSON-RPC envelope rather than as a REST error body, so `error.data` carries the same fields a REST error would (`code`, `message`, `request_id`, `docs_url`, `retryable`) and `error.code` is the JSON-RPC numeric code.\n\n`oneOf` with ErrorEnvelope because the shield runs before the MCP handler: a refused Host, a rate limit, an oversized body or a wrong method is answered as a plain HTTP error with no JSON-RPC envelope at all.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/McpError"
                    },
                    {
                      "$ref": "#/components/schemas/ErrorEnvelope"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "mcp:tools"
            ]
          }
        ]
      }
    },
    "/webhooks/{id}/rotate-secret": {
      "post": {
        "summary": "Rotate a webhook signing secret",
        "description": "Mints a new HMAC signing secret, returned once. The old secret stops working immediately — update the receiver during a quiet window.\n\n**MCP tool:** `ulex_rotate_webhook_secret`\n\n**Scopes:** `write:webhooks`",
        "operationId": "rotateWebhookSecret",
        "tags": [
          "Webhooks"
        ],
        "x-ulex-mcp-tool": "ulex_rotate_webhook_secret",
        "x-ulex-scopes": [
          "write:webhooks"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/webhookId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Webhook"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/directories/{id}/rotate_scim_token": {
      "post": {
        "tags": [
          "directories"
        ],
        "summary": "Rotate an inbound SCIM bearer token",
        "description": "Issues a new inbound SCIM bearer token and disables the previous one immediately. The plaintext is returned once and never stored: ulex keeps only a blind index of it, which is what the pre-authentication lookup matches.\n\nThis exists because the plaintext is unrecoverable by design, so without it a lost token could only be replaced by deleting the directory and rebuilding its sync configuration.",
        "operationId": "rotateDirectoryScimToken",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "A new token. The previous one no longer authenticates.",
            "headers": {
              "x-ulex-warning": {
                "description": "Present on every success; the token is shown once.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "directory_id",
                    "inbound"
                  ],
                  "properties": {
                    "directory_id": {
                      "type": "string"
                    },
                    "inbound": {
                      "type": "object",
                      "properties": {
                        "base_url": {
                          "type": "string"
                        },
                        "bearer_token": {
                          "type": "string",
                          "description": "Shown once. Not retrievable again."
                        },
                        "users_endpoint": {
                          "type": "string"
                        },
                        "groups_endpoint": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "warning": {
                    "type": "string"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      }
    },
    "/connections/auth_attempts": {
      "get": {
        "summary": "List auth attempts on a connection",
        "description": "One `auth_attempt` per login attempt, with `stage`, `outcome`, `duration_ms` and `error_code`. `ip_hash` is a salted SHA-256, never the raw address.\n\n**MCP tool:** `ulex_get_status`\n\n**Scopes:** `read:connections`",
        "operationId": "listConnectionAuthAttempts",
        "tags": [
          "Connections"
        ],
        "x-ulex-mcp-tool": "ulex_get_status",
        "x-ulex-scopes": [
          "read:connections"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/connectionId"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/order"
          },
          {
            "name": "outcome",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "success",
                "failure",
                "challenge",
                "error",
                "cancelled"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEnvelope"
                },
                "examples": {
                  "result": {
                    "$ref": "#/components/examples/authAttemptList"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "validationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "unauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  },
                  "invalidApiKey": {
                    "$ref": "#/components/examples/errorInvalidApiKey"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "insufficientScope": {
                    "$ref": "#/components/examples/errorInsufficientScope"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "notFound": {
                    "$ref": "#/components/examples/errorNotFound"
                  }
                }
              }
            }
          },
          "409": {
            "description": "Conflict",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "resourceExists": {
                    "$ref": "#/components/examples/errorResourceExists"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-IP rate limit exceeded; honor Retry-After",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "rateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "internalError": {
                    "$ref": "#/components/examples/errorInternalError"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ]
      }
    },
    "/users/{id}/password": {
      "post": {
        "summary": "Set a user password",
        "description": "Set (or replace) the password the user signs in with at the hosted login. Only the scrypt digest is stored. Existing sessions are revoked, so the change takes effect immediately.\n\n**MCP tool:** `ulex_set_user_password`\n\n**Scopes:** `write:users`",
        "operationId": "setUserPassword",
        "tags": [
          "Users"
        ],
        "x-ulex-mcp-tool": "ulex_set_user_password",
        "x-ulex-scopes": [
          "write:users"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/userId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "password"
                ],
                "properties": {
                  "password": {
                    "type": "string",
                    "minLength": 8,
                    "maxLength": 256,
                    "description": "Stored as a scrypt digest only; never persisted or returned."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Password set; sessions revoked.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "user_id",
                    "password_set"
                  ],
                  "properties": {
                    "user_id": {
                      "type": "string"
                    },
                    "password_set": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        }
      }
    },
    "/portal/signup": {
      "post": {
        "summary": "Sign up",
        "description": "Create an account and an organization. Open only where the tenant allows signup. Sets the ulex_session cookie.",
        "operationId": "portalSignup",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string",
                    "minLength": 8
                  },
                  "first_name": {
                    "type": "string"
                  },
                  "last_name": {
                    "type": "string"
                  },
                  "organization_name": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/session": {
      "post": {
        "summary": "Sign in",
        "description": "Email and password sign-in. Sets the ulex_session cookie. Wrong password and unknown user are indistinguishable.",
        "operationId": "portalCreateSession",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Sign out",
        "description": "Revokes the session and clears the cookie. Idempotent.",
        "operationId": "portalDeleteSession",
        "tags": [
          "Portal"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me": {
      "get": {
        "summary": "Current user",
        "description": "The signed-in user and their organizations with roles. Cookie session.",
        "operationId": "portalMe",
        "tags": [
          "Portal"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/members": {
      "get": {
        "summary": "List my organization members",
        "description": "Members of an organization I belong to. Non-members get 404.",
        "operationId": "portalListMembers",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "search",
            "in": "query",
            "description": "Substring match on member email or display name (bounded to 200 rows).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Add a member",
        "description": "Add an existing user by email or user id. Owner/admin only.",
        "operationId": "portalAddMember",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "user_id": {
                    "type": "string"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "admin",
                      "member",
                      "guest"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/members/{userId}": {
      "delete": {
        "summary": "Remove a member",
        "description": "Owner/admin only.",
        "operationId": "portalRemoveMember",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Signed out."
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/groups": {
      "get": {
        "summary": "List my organization groups",
        "description": "Groups in an organization I belong to.",
        "operationId": "portalListGroups",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a group",
        "description": "Owner/admin only.",
        "operationId": "portalCreateGroup",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "slug": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/groups/{groupId}/members": {
      "get": {
        "summary": "List group members",
        "description": "Members must belong to the group organization.",
        "operationId": "portalListGroupMembers",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Replace group members",
        "description": "Owner/admin only.",
        "operationId": "portalSetGroupMembers",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "user_ids"
                ],
                "properties": {
                  "user_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/groups/{groupId}": {
      "delete": {
        "summary": "Delete a group",
        "description": "Owner/admin only.",
        "operationId": "portalDeleteGroup",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "groupId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Signed out."
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/password": {
      "post": {
        "summary": "Change my password",
        "description": "Verifies the current password, sets the new one, and revokes every other session. Cookie session.",
        "operationId": "portalChangePassword",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "current_password",
                  "new_password"
                ],
                "properties": {
                  "current_password": {
                    "type": "string"
                  },
                  "new_password": {
                    "type": "string",
                    "minLength": 8
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/email-change/request": {
      "post": {
        "summary": "Request a 6-digit code to change my email address",
        "description": "Requires recent authentication or `current_password`, checks uniqueness, and sends a 6-digit verification code bound to `new_email`.",
        "operationId": "portalRequestEmailChange",
        "tags": ["Portal"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["new_email"],
                "properties": {
                  "new_email": { "type": "string", "format": "email" },
                  "current_password": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } },
          "400": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "401": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "429": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/portal/me/email-change/confirm": {
      "post": {
        "summary": "Confirm a pending email address change with its 6-digit code",
        "description": "Verifies the 6-digit email-change code, updates the user's email and `email_verified: true`, and clears pending code state.",
        "operationId": "portalConfirmEmailChange",
        "tags": ["Portal"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["code"],
                "properties": { "code": { "type": "string" } }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } },
          "400": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "409": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/portal/me/email-change/cancel": {
      "post": {
        "summary": "Cancel my pending email change request",
        "description": "Clears any pending email change address and outstanding verification code.",
        "operationId": "portalCancelEmailChange",
        "tags": ["Portal"],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } }
        }
      }
    },
    "/portal/me/identities": {
      "get": {
        "summary": "List external identity providers linked to my account",
        "description": "Returns linked external identities plus `has_password`, `passkey_count`, and `can_unlink`.",
        "operationId": "portalListMyIdentities",
        "tags": ["Portal"],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } },
          "401": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/portal/me/identities/link/start": {
      "post": {
        "summary": "Start an interactive OIDC or SAML flow to link another provider to my account",
        "description": "Creates a single-use account-linking federation transaction for the signed-in portal user and returns the upstream authorization URL or SAML POST form.",
        "operationId": "portalStartLinkIdentity",
        "tags": ["Portal"],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["connection_id"],
                "properties": {
                  "connection_id": { "type": "string" },
                  "return_to": { "type": "string" }
                }
              }
            }
          }
        },
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } },
          "400": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/portal/me/identities/{connectionId}": {
      "delete": {
        "summary": "Unlink an external identity provider from my account",
        "description": "Removes an external identity link unless doing so would remove the user's last remaining authentication method (`400 last_auth_method`).",
        "operationId": "portalUnlinkMyIdentity",
        "tags": ["Portal"],
        "parameters": [
          {
            "name": "connectionId",
            "in": "path",
            "required": true,
            "schema": { "type": "string" }
          }
        ],
        "responses": {
          "200": { "description": "OK", "content": { "application/json": { "schema": { "type": "object" } } } },
          "400": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } },
          "404": { "description": "Error", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/portal/verify-email/request": {
      "post": {
        "summary": "Send a 6-digit email verification code",
        "description": "Issues a code for an unverified address. Unknown and already-verified addresses answer identically. Non-HIPAA tenants with `allow_mocks: true` (or the local in-memory server) return the code at issuance; default hosted tenants never do.",
        "operationId": "portalRequestVerificationCode",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/verify-email/confirm": {
      "post": {
        "summary": "Confirm an email address with its verification code",
        "description": "Single-use 6-digit code, 24h TTL, five wrong guesses spend it. Unknown addresses answer as a wrong code.",
        "operationId": "portalConfirmVerificationCode",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "code"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/verify-email/resend": {
      "post": {
        "summary": "Resend the email verification code",
        "description": "Issues a fresh code, spending the previous one. Refused inside the 60s cooldown with a 429.",
        "operationId": "portalResendVerificationCode",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/password-reset/request": {
      "post": {
        "summary": "Send a 6-digit password-reset code",
        "description": "Issues a code with a 1h TTL. Unknown addresses answer identically. Non-HIPAA tenants with `allow_mocks: true` (or the local in-memory server) return the code at issuance; default hosted tenants never do.",
        "operationId": "portalRequestPasswordReset",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/password-reset/confirm": {
      "post": {
        "summary": "Set a new password with a reset code",
        "description": "Single-use 6-digit code. The new password must meet the tenant policy; every session is revoked on success.",
        "operationId": "portalConfirmPasswordReset",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "code",
                  "new_password"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "code": {
                    "type": "string",
                    "pattern": "^\\d{6}$"
                  },
                  "new_password": {
                    "type": "string",
                    "minLength": 8
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/sessions": {
      "get": {
        "summary": "List my sessions",
        "description": "Sessions with the current one marked. No authenticating material is returned.",
        "operationId": "portalListSessions",
        "tags": [
          "Portal"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/sessions/{sessionId}": {
      "delete": {
        "summary": "Revoke a session",
        "description": "Revoking the current session signs the browser out.",
        "operationId": "portalRevokeSession",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "sessionId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/factors": {
      "get": {
        "summary": "List my second factors",
        "description": "Never returns secrets.",
        "operationId": "portalListMfaFactors",
        "tags": [
          "Portal"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/totp": {
      "post": {
        "summary": "Begin TOTP enrollment",
        "description": "Requires the current password. Returns the otpauth URI exactly once.",
        "operationId": "portalBeginTotpEnrollment",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "current_password"
                ],
                "properties": {
                  "account_name": {
                    "type": "string"
                  },
                  "current_password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/totp/confirm": {
      "post": {
        "summary": "Confirm TOTP enrollment",
        "description": "Promotes the factor to verified with a current code.",
        "operationId": "portalConfirmTotpEnrollment",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "factor_id",
                  "code"
                ],
                "properties": {
                  "factor_id": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/verify": {
      "post": {
        "summary": "Test a second factor",
        "description": "Returns verified true/false; never an error for a wrong code.",
        "operationId": "portalVerifyMfa",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/recovery-codes": {
      "post": {
        "summary": "Replace recovery codes",
        "description": "Shown exactly once; replaces all previous codes.",
        "operationId": "portalReplaceRecoveryCodes",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "count": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 20
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/mfa/factors/{factorId}": {
      "delete": {
        "summary": "Revoke a second factor",
        "description": "Immediate.",
        "operationId": "portalRevokeMfaFactor",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "factorId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/audit": {
      "get": {
        "summary": "Read organization audit",
        "description": "Owner/admin only. Entries are pseudonymised at write time.",
        "operationId": "portalReadAudit",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}": {
      "patch": {
        "summary": "Rename my organization",
        "description": "Owner/admin only. The slug never changes.",
        "operationId": "portalRenameOrganization",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "minLength": 1,
                    "maxLength": 120
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/invites": {
      "get": {
        "summary": "List pending invitations",
        "description": "Owner/admin only. Never includes tokens.",
        "operationId": "portalListInvites",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create an invitation link",
        "description": "Owner/admin only. Stateless signed token; expires, cannot be unsent.",
        "operationId": "portalCreateInvite",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "owner",
                      "admin",
                      "member",
                      "guest"
                    ]
                  },
                  "expires_in_days": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 30
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/invites/{token}": {
      "get": {
        "summary": "Preview an invitation",
        "description": "Public. 404 for forged, expired, or withdrawn-organization tokens.",
        "operationId": "portalPreviewInvite",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/invites/{token}/accept": {
      "post": {
        "summary": "Accept an invitation",
        "description": "Signed-in user joins the organization. Idempotent.",
        "operationId": "portalAcceptInvite",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/audit/verify": {
      "post": {
        "summary": "Verify organization audit chain",
        "description": "Owner/admin only. Answers only whether the chain is intact.",
        "operationId": "portalVerifyAudit",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "from": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "until": {
                    "type": "string",
                    "format": "date-time"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/passkeys/begin": {
      "post": {
        "summary": "Begin passkey registration",
        "description": "Requires the current password. Returns WebAuthn creation options with a single-use challenge.",
        "operationId": "portalBeginPasskeyRegistration",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "current_password"
                ],
                "properties": {
                  "current_password": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/passkeys/finish": {
      "post": {
        "summary": "Finish passkey registration",
        "description": "Verifies attestation (none, packed self, fido-u2f). Verified immediately: attestation proves possession.",
        "operationId": "portalFinishPasskeyRegistration",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "credential_id",
                  "attestation_object",
                  "client_data_json"
                ],
                "properties": {
                  "credential_id": {
                    "type": "string"
                  },
                  "attestation_object": {
                    "type": "string"
                  },
                  "client_data_json": {
                    "type": "string"
                  },
                  "transports": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "nickname": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/passkeys/authenticate/begin": {
      "post": {
        "summary": "Begin passkey authentication",
        "description": "Challenge plus the account credential list.",
        "operationId": "portalBeginPasskeyAuthentication",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {}
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/me/passkeys/authenticate/finish": {
      "post": {
        "summary": "Verify passkey authentication",
        "description": "Checks signature and counter; equal-or-lower counter is a clone or replay.",
        "operationId": "portalFinishPasskeyAuthentication",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "credential_id",
                  "authenticator_data",
                  "client_data_json",
                  "signature"
                ],
                "properties": {
                  "credential_id": {
                    "type": "string"
                  },
                  "authenticator_data": {
                    "type": "string"
                  },
                  "client_data_json": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/portal/organizations/{id}/invites/{inviteId}": {
      "delete": {
        "summary": "Revoke an invitation",
        "description": "Owner/admin only. Idempotent.",
        "operationId": "portalRevokeInvite",
        "tags": [
          "Portal"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "inviteId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Done"
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/auth-policy": {
      "get": {
        "summary": "The tenant's authentication policy",
        "description": "Returns the effective policy: what an operator configured, and the product's defaults for everything else.\n\n**Never 404s.** `configured: false` means the tenant has never called `PUT`; a miss would otherwise be indistinguishable from a cross-tenant id. Read `policy.set` to tell a chosen value from a default one.\n\n**Which fields are enforced is stated per field.** Three groups are not, and say so: `password.max_age_days`, `password.forbid_reuse_count`, and all of `mfa`.\n\n**MCP tool:** `ulex_get_auth_policy`\n\n**Scopes:** `ulex:admin`",
        "operationId": "getAuthPolicy",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_get_auth_policy",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthPolicyResponse"
                },
                "examples": {
                  "result": {
                    "value": {
                      "policy": {
                        "id": "pol_01M3PSVY108K5TEHHQ82WN30YK",
                        "tenant_id": "ten_01M3PSVY108K5TEHHQ82WN30YK",
                        "object": "auth_policy",
                        "environment": "prod",
                        "password": {
                          "min_length": 14,
                          "require_uppercase": true,
                          "require_lowercase": true,
                          "require_number": true,
                          "require_symbol": true,
                          "check_breached_passwords": true,
                          "max_age_days": 365,
                          "forbid_reuse_count": 5
                        },
                        "session": {
                          "lifetime_seconds": 43200,
                          "idle_timeout_seconds": 3600,
                          "reauthenticate_after_seconds": 3600,
                          "bind_to_ip": false,
                          "bind_to_user_agent": true,
                          "cross_app_sso": false
                        },
                        "mfa": {
                          "mode": "adaptive",
                          "methods": [
                            "totp",
                            "webauthn"
                          ],
                          "remember_device_days": 30,
                          "trigger_on_new_device": true,
                          "trigger_on_ip_change": true,
                          "trigger_on_high_risk": true
                        },
                        "blocked_ip_ranges": [],
                        "created_at": "2026-09-29T14:43:20.000Z",
                        "updated_at": "2026-09-29T14:43:20.000Z",
                        "set": {
                          "password": true,
                          "session": true,
                          "mfa": false,
                          "blocked_ip_ranges": false
                        }
                      },
                      "configured": true
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorUnauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorForbidden": {
                    "$ref": "#/components/examples/errorForbidden"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorRateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorInternal": {
                    "$ref": "#/components/examples/errorInternal"
                  }
                }
              }
            }
          }
        }
      },
      "put": {
        "summary": "Create or replace the tenant's authentication policy",
        "description": "One slot per tenant, so a second `PUT` is an edit rather than a conflict, and the `id` is preserved across edits.\n\nRecords `auth_policy.updated` naming the blocks that changed **by name only** — never their values, because a copy of a security control is another place for it to be protected. `auth_policy.ip_blocked` records each refusal of a request from `blocked_ip_ranges`, with the address pseudonymised like every other network identifier.\n\n**MCP tool:** `ulex_update_auth_policy`\n\n**Scopes:** `ulex:admin`",
        "operationId": "updateAuthPolicy",
        "tags": [
          "Platform"
        ],
        "x-ulex-mcp-tool": "ulex_update_auth_policy",
        "x-ulex-scopes": [
          "ulex:admin"
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Deduplicates this write for 24 hours. A replay returns the original response byte for byte; a different body with the same key is 409.",
            "schema": {
              "type": "string",
              "maxLength": 64
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AuthPolicyUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthPolicyResponse"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorInvalidRequest": {
                    "$ref": "#/components/examples/errorInvalidRequest"
                  },
                  "errorValidationFailed": {
                    "$ref": "#/components/examples/errorValidationFailed"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorUnauthenticated": {
                    "$ref": "#/components/examples/errorUnauthenticated"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorForbidden": {
                    "$ref": "#/components/examples/errorForbidden"
                  }
                }
              }
            }
          },
          "429": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorRateLimited": {
                    "$ref": "#/components/examples/errorRateLimited"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                },
                "examples": {
                  "errorInternal": {
                    "$ref": "#/components/examples/errorInternal"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/feedback": {
      "post": {
        "summary": "Submit feedback, an error report, or a feature request",
        "description": "Agent-facing feedback intake. Call this whenever another endpoint or tool fails, returns something unexpected, or lacks a capability you need, rather than retrying indefinitely or guessing. Credentials in free-text fields are redacted before storage. Screenshots and log excerpts go to S3; only metadata lands in the record.\n\n**MCP tool:** `ulex_submit_feedback`\n\n**Scopes:** `write:feedback`",
        "operationId": "submitFeedback",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ],
        "x-ulex-mcp-tool": "ulex_submit_feedback",
        "x-ulex-scopes": [
          "write:feedback"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackCreate"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feedback"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List submitted feedback and triage status",
        "description": "Newest-first, tenant-scoped list of feedback submitted by this organization.\n\n**MCP tool:** `ulex_list_feedback`\n\n**Scopes:** `read:feedback`",
        "operationId": "listFeedback",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ],
        "x-ulex-mcp-tool": "ulex_list_feedback",
        "x-ulex-scopes": [
          "read:feedback"
        ],
        "parameters": [
          {
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "type": "string",
              "enum": [
                "new",
                "triaged",
                "in_progress",
                "resolved",
                "wont_fix",
                "closed"
              ]
            }
          },
          {
            "in": "query",
            "name": "type",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "severity",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FeedbackList"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/feedback/{id}": {
      "get": {
        "summary": "Get a single feedback report by id",
        "description": "A foreign id answers 404, indistinguishable from one that never existed.\n\n**MCP tool:** `ulex_get_feedback`\n\n**Scopes:** `read:feedback`",
        "operationId": "getFeedback",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ],
        "x-ulex-mcp-tool": "ulex_get_feedback",
        "x-ulex-scopes": [
          "read:feedback"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/feedbackId"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feedback"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Advance feedback through the triage lifecycle",
        "description": "Staff triage operation.\n\n**Scopes:** `write:feedback`",
        "operationId": "triageFeedback",
        "tags": [
          "Feedback"
        ],
        "security": [
          {
            "bearerApiKey": []
          },
          {
            "oauth2AuthorizationCode": [
              "openid",
              "profile",
              "email"
            ]
          }
        ],
        "x-ulex-scopes": [
          "write:feedback"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/feedbackId"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FeedbackTriageUpdate"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Feedback"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Unauthenticated",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Forbidden",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/roles": {
      "get": {
        "summary": "List RBAC roles",
        "description": "Returns custom and system RBAC roles in the current tenant.\n\n**MCP tool:** `ulex_list_roles`\n\n**Scopes:** `read:organizations`",
        "operationId": "listRoles",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-mcp-tool": "ulex_list_roles",
        "x-ulex-scopes": [
          "read:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create an RBAC role",
        "description": "Creates a tenant-scoped custom RBAC role with permission strings.\n\n**MCP tool:** `ulex_create_role`\n\n**Scopes:** `write:organizations`",
        "operationId": "createRole",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-mcp-tool": "ulex_create_role",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "slug"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "slug": {
                    "type": "string"
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "permissions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "role"
                  ],
                  "properties": {
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/roles/{id}": {
      "get": {
        "summary": "Get an RBAC role",
        "operationId": "getRole",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "read:organizations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "role"
                  ],
                  "properties": {
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Update an RBAC role",
        "description": "**MCP tool:** `ulex_update_role`\n\n**Scopes:** `write:organizations`",
        "operationId": "updateRole",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-mcp-tool": "ulex_update_role",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "slug": {
                    "type": "string"
                  },
                  "description": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "permissions": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "role"
                  ],
                  "properties": {
                    "role": {
                      "$ref": "#/components/schemas/Role"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete an RBAC role",
        "description": "**MCP tool:** `ulex_delete_role`\n\n**Scopes:** `write:organizations`",
        "operationId": "deleteRole",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-mcp-tool": "ulex_delete_role",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/organizations/{id}/members/{userId}/roles": {
      "put": {
        "summary": "Assign RBAC roles to an organization member",
        "description": "**MCP tool:** `ulex_assign_member_roles`\n\n**Scopes:** `write:organizations`",
        "operationId": "setMemberRoles",
        "tags": [
          "Roles"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-mcp-tool": "ulex_assign_member_roles",
        "x-ulex-scopes": [
          "write:organizations"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/organizationId"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "role_ids"
                ],
                "properties": {
                  "role_ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "membership"
                  ],
                  "properties": {
                    "membership": {
                      "$ref": "#/components/schemas/Membership"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/resource-servers": {
      "get": {
        "summary": "List custom API resource servers",
        "operationId": "listResourceServers",
        "tags": [
          "ResourceServers"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "read:resource_servers"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "$ref": "#/components/parameters/startingAfter"
          },
          {
            "$ref": "#/components/parameters/endingBefore"
          },
          {
            "$ref": "#/components/parameters/order"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ListEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "Create a custom API resource server",
        "operationId": "createResourceServer",
        "tags": [
          "ResourceServers"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "write:resource_servers"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "identifier"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "identifier": {
                    "type": "string"
                  },
                  "scopes": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "resource_server"
                  ],
                  "properties": {
                    "resource_server": {
                      "$ref": "#/components/schemas/ResourceServer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/resource-servers/{id}": {
      "get": {
        "summary": "Get a custom API resource server",
        "operationId": "getResourceServer",
        "tags": [
          "ResourceServers"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "read:resource_servers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "resource_server"
                  ],
                  "properties": {
                    "resource_server": {
                      "$ref": "#/components/schemas/ResourceServer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "patch": {
        "summary": "Update a custom API resource server",
        "operationId": "updateResourceServer",
        "tags": [
          "ResourceServers"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "write:resource_servers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "resource_server"
                  ],
                  "properties": {
                    "resource_server": {
                      "$ref": "#/components/schemas/ResourceServer"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "delete": {
        "summary": "Delete a custom API resource server",
        "operationId": "deleteResourceServer",
        "tags": [
          "ResourceServers"
        ],
        "security": [
          {
            "bearerApiKey": []
          }
        ],
        "x-ulex-scopes": [
          "write:resource_servers"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/Id"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "Deleted"
          },
          "404": {
            "description": "Not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/oauth2/par": {
      "post": {
        "summary": "Pushed Authorization Request (RFC 9126)",
        "description": "Authenticates the client (`client_secret_basic`, `client_secret_post`, `private_key_jwt`, or `none`) and stores validated authorization parameters returning a single-use `request_uri` bound to that client for 90 seconds.",
        "operationId": "pushedAuthorizationRequest",
        "tags": [
          "OAuth"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PushedAuthorizationResponse"
                }
              }
            }
          },
          "400": {
            "description": "OAuth error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Client authentication failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/portal/session/mfa-enroll": {
      "post": {
        "summary": "Confirm required MFA enrollment and complete portal sign-in",
        "operationId": "portalEnrollMfaSession",
        "tags": [
          "Portal"
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "mfa_token",
                  "code"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email"
                  },
                  "mfa_token": {
                    "type": "string"
                  },
                  "mfa_nonce": {
                    "type": "string"
                  },
                  "factor_id": {
                    "type": "string"
                  },
                  "code": {
                    "type": "string"
                  },
                  "remember_device": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/saml/idp/metadata": {
      "get": {
        "summary": "Tenant SAML 2.0 IdP metadata XML",
        "operationId": "getSamlIdpMetadata",
        "tags": [
          "SAML"
        ],
        "responses": {
          "200": {
            "description": "SAML 2.0 EntityDescriptor XML",
            "content": {
              "application/samlmetadata+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/saml/idp/sso": {
      "get": {
        "summary": "SAML 2.0 IdP Single Sign-On (HTTP-Redirect)",
        "operationId": "samlIdpSsoRedirect",
        "tags": [
          "SAML"
        ],
        "responses": {
          "200": {
            "description": "HTML SAML Response auto-POST form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid SAML request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "SAML 2.0 IdP Single Sign-On (HTTP-POST)",
        "operationId": "samlIdpSsoPost",
        "tags": [
          "SAML"
        ],
        "responses": {
          "200": {
            "description": "HTML SAML Response auto-POST form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid SAML request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/saml/idp/slo": {
      "get": {
        "summary": "SAML 2.0 IdP Single Logout (HTTP-Redirect)",
        "operationId": "samlIdpSingleLogoutRedirect",
        "tags": [
          "SAML"
        ],
        "responses": {
          "200": {
            "description": "HTML SAML LogoutResponse auto-POST form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid SAML LogoutRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      },
      "post": {
        "summary": "SAML 2.0 IdP Single Logout (HTTP-POST)",
        "operationId": "samlIdpSingleLogoutPost",
        "tags": [
          "SAML"
        ],
        "responses": {
          "200": {
            "description": "HTML SAML LogoutResponse auto-POST form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid SAML LogoutRequest",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/saml/idp/init/{appId}": {
      "get": {
        "summary": "SAML 2.0 IdP-Initiated Single Sign-On (opt-in)",
        "description": "Returns 403 unless the target application sets `saml_allow_idp_initiated: true`.",
        "operationId": "samlIdpInitiatedSso",
        "tags": [
          "SAML"
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/appIdHost"
          }
        ],
        "responses": {
          "200": {
            "description": "HTML SAML Response auto-POST form",
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "IdP-initiated SAML disabled for this application",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "parameters": {
      "limit": {
        "name": "limit",
        "in": "query",
        "required": false,
        "description": "Page size, 1–200.",
        "schema": {
          "type": "integer",
          "minimum": 1,
          "maximum": 200,
          "default": 20
        }
      },
      "startingAfter": {
        "name": "starting_after",
        "in": "query",
        "required": false,
        "description": "Opaque cursor: a resource id. Pass `next_cursor` back verbatim.",
        "schema": {
          "$ref": "#/components/schemas/Id"
        }
      },
      "endingBefore": {
        "name": "ending_before",
        "in": "query",
        "required": false,
        "description": "Opaque cursor for reverse paging. Mutually exclusive with `starting_after`.",
        "schema": {
          "$ref": "#/components/schemas/Id"
        }
      },
      "order": {
        "name": "order",
        "in": "query",
        "required": false,
        "description": "`asc` is creation order (ids are ULIDs).",
        "schema": {
          "type": "string",
          "enum": [
            "asc",
            "desc"
          ]
        }
      },
      "applicationId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Application id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
        }
      },
      "organizationId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Organization id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
        }
      },
      "userId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "User id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
        }
      },
      "groupId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Group id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "grp_01M3PSVED0M9RJTYH5AC72C253"
        }
      },
      "connectionId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Connection id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
        }
      },
      "directoryId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Directory id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
        }
      },
      "domainId": {
        "name": "domainId",
        "in": "path",
        "required": true,
        "description": "Domain id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "dom_01M3PSVCEGK9H35GZJK25HN08D"
        }
      },
      "webhookId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Webhook id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "whk_01M3PSVK981SXWGKG9JXHC1P0Y"
        }
      },
      "deliveryId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Webhook delivery id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA"
        }
      },
      "deploymentId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Deployment id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF"
        }
      },
      "auditEventId": {
        "name": "id",
        "in": "path",
        "required": true,
        "description": "Audit event id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9"
        }
      },
      "keyId": {
        "name": "keyId",
        "in": "path",
        "required": true,
        "description": "API key id.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "key_01M3PSVJA0YP2WDPM2RDR15MGH"
        }
      },
      "environmentSlug": {
        "name": "env",
        "in": "path",
        "required": true,
        "description": "Environment.",
        "schema": {
          "type": "string",
          "enum": [
            "dev",
            "stage",
            "prod"
          ]
        }
      },
      "appIdHost": {
        "name": "appId",
        "in": "path",
        "required": true,
        "description": "Application id for the hosted sign-in UI.",
        "schema": {
          "$ref": "#/components/schemas/Id",
          "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
        }
      },
      "feedbackId": {
        "in": "path",
        "name": "id",
        "required": true,
        "description": "Feedback id (fbk_...) returned by POST /feedback.",
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "invalidRequest": {
                "summary": "400 invalid_request",
                "value": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "The request body is not valid.",
                    "param": "name",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false
                  }
                }
              }
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Unauthenticated",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "unauthenticated": {
                "summary": "401 unauthenticated",
                "value": {
                  "error": {
                    "type": "authentication_error",
                    "code": "unauthenticated",
                    "message": "Missing or invalid credentials.",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false
                  }
                }
              }
            }
          }
        }
      },
      "Forbidden": {
        "description": "Forbidden",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "insufficientScope": {
                "summary": "403 insufficient_scope",
                "value": {
                  "error": {
                    "type": "permission_error",
                    "code": "insufficient_scope",
                    "message": "This credential requires the write:organizations scope.",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false,
                    "hint": "Request scope: write:organizations.",
                    "docs_url": "https://docs.ulexid.com/security/authorization#scopes"
                  }
                }
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "notFound": {
                "summary": "404 not_found",
                "value": {
                  "error": {
                    "type": "not_found_error",
                    "code": "not_found",
                    "message": "No such organization: org_01M3PSV8HGTKQFCAYF9GDWGN3C",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false
                  }
                }
              }
            }
          }
        }
      },
      "Conflict": {
        "description": "Conflict",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "resourceExists": {
                "summary": "409 resource_exists",
                "value": {
                  "error": {
                    "type": "conflict_error",
                    "code": "resource_exists",
                    "message": "A organization with that slug already exists.",
                    "param": "slug",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false,
                    "details": {
                      "slug": "already taken"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "PreconditionFailed": {
        "description": "Domain not verified",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "domainNotVerified": {
                "summary": "412 domain_not_verified",
                "value": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "domain_not_verified",
                    "message": "The domain acme.example has not been verified for this organization.",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": false,
                    "hint": "Publish the TXT record at _ulex-challenge.acme.example and retry."
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Per-IP request rate limit exceeded. Honor Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "rateLimited": {
                "summary": "429 too_many_requests",
                "value": {
                  "error": {
                    "type": "rate_limited",
                    "code": "too_many_requests",
                    "message": "Rate limit exceeded. Back off and retry."
                  }
                }
              }
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "type": "integer"
            }
          },
          "ratelimit": {
            "description": "Current request bucket rate and seconds to the next token.",
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "InternalError": {
        "description": "Server error",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorEnvelope"
            },
            "examples": {
              "internalError": {
                "summary": "500 internal_error",
                "value": {
                  "error": {
                    "type": "api_error",
                    "code": "internal_error",
                    "message": "An unexpected error occurred.",
                    "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
                    "retryable": true
                  }
                }
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerApiKey": {
        "type": "http",
        "scheme": "bearer",
        "description": "A tenant API key (`ulex_sk_live_…` or `ulex_sk_test_…`) or a user access token (a JWT). **The tenant context is derived from the credential** — there is no environment selector header. An API key can call the control plane but not `/oauth2/userinfo`; an access token is the other way round. Never put a key in a URL or a body: it lands in logs, in the audit log, and in your transcript."
      },
      "oauth2AuthorizationCode": {
        "type": "oauth2",
        "description": "Authorization code with PKCE, S256 mandatory. Add `resource=https://ulexid.com/api/v1` (RFC 8707) to obtain a token usable against the MCP endpoint.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://ulexid.com/api/v1/oauth2/authorize",
            "tokenUrl": "https://ulexid.com/api/v1/oauth2/token",
            "refreshUrl": "https://ulexid.com/api/v1/oauth2/token",
            "scopes": {
              "openid": "Request a sub claim and the OIDC discovery handshake.",
              "profile": "Name claims.",
              "email": "email and email_verified claims.",
              "offline_access": "Issue a refresh token.",
              "ulex:admin": "Everything, including key rotation and impersonation. Admin-only.",
              "read:organizations": "GET /organizations, /domains, /members.",
              "write:organizations": "Mutations on the same.",
              "read:users": "GET /users.",
              "write:users": "Mutations on /users, including suspend and unsuspend.",
              "read:groups": "GET /groups.",
              "write:groups": "Group and membership writes.",
              "read:connections": "GET /connections and SAML metadata.",
              "write:connections": "Connection CRUD, activate, verify.",
              "read:directories": "GET /directories and sync runs.",
              "write:directories": "Directory CRUD and sync.",
              "read:applications": "GET /applications, /secret, /metadata.",
              "write:applications": "Application CRUD and secret rotation.",
              "read:webhooks": "GET /webhooks and deliveries.",
              "write:webhooks": "Webhook CRUD, enable, disable, test.",
              "read:audit_logs": "GET /audit-events, including export.",
              "read:deployments": "GET /deployments, /environments, /logs.",
              "write:deployments": "POST /deployments, cancel, rollback.",
              "mcp:tools": "Every read-only MCP tool.",
              "mcp:admin": "Destructive MCP tools: reset_tenant, delete_*, rotate_*. Admin-only.",
              "scim:provision": "Inbound SCIM writes and reading SCIM bearer tokens.",
              "saml:consume": "POST the SAML ACS and SLO.",
              "sso:impersonate": "impersonation_only connections. Admin-only."
            }
          },
          "clientCredentials": {
            "tokenUrl": "https://ulexid.com/api/v1/oauth2/token",
            "scopes": {
              "read:users": "Read users.",
              "read:organizations": "Read organizations."
            }
          },
          "deviceCode": {
            "deviceAuthorizationUrl": "https://ulexid.com/api/v1/oauth2/device/code",
            "tokenUrl": "https://ulexid.com/api/v1/oauth2/token",
            "verificationUrl": "https://ulexid.com/device",
            "scopes": {
              "openid": "OIDC.",
              "profile": "Name claims.",
              "email": "Email claims."
            }
          }
        }
      },
      "scimBearerToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "A directory-scoped SCIM bearer token (`scim_…`), obtained once from `GET /directories/{id}/scim`. Grants inbound `/scim/v2` access only, and is revoked with the directory."
      }
    },
    "headers": {
      "X-Ulex-Request-Id": {
        "description": "The request id, either the one you sent or a generated one. Present on every response and stored on every audit event it touches.",
        "schema": {
          "type": "string",
          "maxLength": 64
        }
      },
      "X-Ulex-Correlation-Id": {
        "description": "Echoed from the request.",
        "schema": {
          "type": "string",
          "maxLength": 64
        }
      },
      "X-Ratelimit-Limit": {
        "description": "Requests allowed in the current window.",
        "schema": {
          "type": "integer"
        }
      },
      "X-Ratelimit-Remaining": {
        "description": "Requests left in the current window. Check before a burst, not after a rejection.",
        "schema": {
          "type": "integer"
        }
      },
      "X-Ratelimit-Reset": {
        "description": "Unix seconds at which the window resets.",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before retrying. Prefer this over parsing `hint`.",
        "schema": {
          "type": "integer"
        }
      },
      "Mcp-Session-Id": {
        "description": "MCP session handle, returned by `initialize` and required on every subsequent call.",
        "schema": {
          "type": "string"
        }
      },
      "Ulex-Signature": {
        "description": "Webhook signature, `t=<unix>,v1=<hex>` over `<timestamp>.<rawBody>`.",
        "schema": {
          "type": "string"
        }
      },
      "Ulex-Delivery-Id": {
        "description": "The `webhook_delivery` id for this attempt.",
        "schema": {
          "type": "string"
        }
      },
      "Ulex-Event": {
        "description": "The event name.",
        "schema": {
          "type": "string"
        }
      },
      "Ulex-Attempt": {
        "description": "1-based attempt number. Increments on every retry of the same event.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "examples": {
      "errorInvalidRequest": {
        "summary": "400 invalid_request",
        "value": {
          "error": {
            "type": "invalid_request_error",
            "code": "invalid_request",
            "message": "The request body is not valid.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "param": "name",
            "details": {
              "name": "Required"
            },
            "docs_url": "https://docs.ulexid.com/api-reference/errors"
          }
        }
      },
      "errorValidationFailed": {
        "summary": "400 validation_failed",
        "value": {
          "error": {
            "type": "invalid_request_error",
            "code": "validation_failed",
            "message": "slug must match ^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "param": "slug",
            "details": {
              "slug": "Must be a lowercase URL slug"
            }
          }
        }
      },
      "errorUnauthenticated": {
        "summary": "401 unauthenticated",
        "value": {
          "error": {
            "type": "authentication_error",
            "code": "unauthenticated",
            "message": "Missing or invalid credentials.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "docs_url": "https://docs.ulexid.com/api-reference/authentication"
          }
        }
      },
      "errorInvalidApiKey": {
        "summary": "401 invalid_api_key",
        "value": {
          "error": {
            "type": "authentication_error",
            "code": "invalid_api_key",
            "message": "The API key is malformed.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Copy the full ulex_sk_live_… value; check for trailing whitespace."
          }
        }
      },
      "errorInsufficientScope": {
        "summary": "403 insufficient_scope",
        "value": {
          "error": {
            "type": "permission_error",
            "code": "insufficient_scope",
            "message": "This credential requires the write:organizations scope.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Request scope: write:organizations.",
            "docs_url": "https://docs.ulexid.com/security/authorization#scopes"
          }
        }
      },
      "errorNotFound": {
        "summary": "404 not_found",
        "value": {
          "error": {
            "type": "not_found_error",
            "code": "not_found",
            "message": "No such organization: org_01M3PSV8HGTKQFCAYF9GDWGN3C",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "docs_url": "https://docs.ulexid.com/errors/not-found"
          }
        }
      },
      "errorResourceExists": {
        "summary": "409 resource_exists",
        "value": {
          "error": {
            "type": "conflict_error",
            "code": "resource_exists",
            "message": "A organization with that slug already exists.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "param": "slug",
            "details": {
              "slug": "already taken"
            },
            "hint": "Reuse the existing organization id, or choose a different slug."
          }
        }
      },
      "errorRateLimited": {
        "summary": "429 too_many_requests",
        "value": {
          "error": {
            "type": "rate_limited",
            "code": "too_many_requests",
            "message": "Rate limit exceeded. Back off and retry."
          }
        }
      },
      "errorInternalError": {
        "summary": "500 internal_error",
        "value": {
          "error": {
            "type": "api_error",
            "code": "internal_error",
            "message": "An unexpected error occurred.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": true
          }
        }
      },
      "errorDomainNotVerified": {
        "summary": "412 domain_not_verified",
        "value": {
          "error": {
            "type": "invalid_request_error",
            "code": "domain_not_verified",
            "message": "The domain acme.example has not been verified for this organization.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Publish the TXT record at _ulex-challenge.acme.example and retry."
          }
        }
      },
      "errorConnectionNotActive": {
        "summary": "403 connection_not_active",
        "value": {
          "error": {
            "type": "permission_error",
            "code": "connection_not_active",
            "message": "This connection is in state 'draft'. Every login on a draft connection is refused.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Call POST /api/v1/connections/{id}/activate, then retry."
          }
        }
      },
      "errorMcpUnauthorized": {
        "summary": "401 mcp_unauthorized",
        "value": {
          "error": {
            "type": "authentication_error",
            "code": "mcp_unauthorized",
            "message": "An access token with the mcp:tools scope is required to call ulex MCP tools.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "docs_url": "https://docs.ulexid.com/troubleshooting/mcp-issues"
          }
        }
      },
      "errorExportTooLarge": {
        "summary": "413 export too large",
        "value": {
          "error": {
            "type": "invalid_request_error",
            "code": "limit_reached",
            "message": "The export window contains more than 100000 events.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Narrow the window to 7 days and split the export.",
            "param": "until"
          }
        }
      },
      "health": {
        "summary": "Healthy",
        "value": {
          "healthy": true,
          "environment": "prod",
          "version": "2025.9.1",
          "region": "us-east-1",
          "uptime_seconds": 841233,
          "checks": [
            {
              "name": "api",
              "status": "pass",
              "latency_ms": 11
            },
            {
              "name": "dynamodb",
              "status": "pass",
              "latency_ms": 3
            },
            {
              "name": "kms",
              "status": "pass",
              "latency_ms": 7
            },
            {
              "name": "queue",
              "status": "pass",
              "latency_ms": 2
            },
            {
              "name": "directory_sync",
              "status": "pass",
              "latency_ms": 41
            }
          ]
        }
      },
      "status": {
        "summary": "Healthy",
        "value": {
          "status": "healthy",
          "environment": "prod",
          "version": "2025.9.1",
          "region": "us-east-1",
          "degradations": []
        }
      },
      "healthUnavailable": {
        "summary": "503 unavailable",
        "value": {
          "healthy": false,
          "environment": "prod",
          "version": "2025.9.1",
          "region": "us-east-1",
          "uptime_seconds": 0,
          "checks": [
            {
              "name": "api",
              "status": "fail",
              "latency_ms": 5000
            },
            {
              "name": "dynamodb",
              "status": "fail",
              "latency_ms": 5000
            },
            {
              "name": "kms",
              "status": "fail",
              "latency_ms": 5000
            }
          ]
        }
      },
      "me": {
        "summary": "Current credential and tenant",
        "value": {
          "tenant": {
            "id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
            "object": "tenant",
            "name": "Acme Sandbox",
            "slug": "acme-sandbox",
            "environment": "prod",
            "plan": "simulator_free",
            "status": "active",
            "region": "us-east-1",
            "allow_mocks": true,
            "hipaa_enabled": false,
            "hipaa_baa_reference": null,
            "data_processing_addendum_signed_at": null,
            "retention": {
              "audit_log_days": 2555,
              "webhook_delivery_days": 30,
              "session_days": 30,
              "application_inactive_days": 730
            },
            "created_at": "2026-09-01T09:00:00.000Z",
            "updated_at": "2026-09-01T09:00:00.000Z"
          },
          "credential": {
            "id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
            "type": "api_key",
            "scope": [
              "mcp:tools",
              "read:organizations",
              "write:organizations",
              "read:users",
              "write:users"
            ]
          },
          "usage": {
            "organizations": 2,
            "users": 37,
            "connections": 2,
            "applications": 1,
            "mcp_calls_current_minute": 143,
            "webhook_endpoints": 1,
            "active_deployments": 0
          },
          "environments": [
            {
              "id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
              "object": "environment",
              "slug": "production",
              "name": "Production",
              "domain": "ulexid.com",
              "region": "us-east-1",
              "created_at": "2026-09-01T09:00:00.000Z",
              "updated_at": "2026-09-01T09:00:00.000Z"
            }
          ]
        }
      },
      "tenant": {
        "summary": "Tenant",
        "value": {
          "id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
          "object": "tenant",
          "name": "Acme Sandbox",
          "slug": "acme-sandbox",
          "environment": "prod",
          "plan": "simulator_free",
          "status": "active",
          "region": "us-east-1",
          "kms_key_alias": "alias/ulex-tenant",
          "allow_mocks": true,
          "data_processing_addendum_signed_at": null,
          "hipaa_enabled": false,
          "hipaa_baa_reference": null,
          "retention": {
            "audit_log_days": 2555,
            "webhook_delivery_days": 30,
            "session_days": 30,
            "application_inactive_days": 730
          },
          "created_at": "2026-09-01T09:00:00.000Z",
          "updated_at": "2026-09-01T09:00:00.000Z",
          "deleted_at": null
        }
      },
      "tenantUpdate": {
        "summary": "Enable mocks and HIPAA mode",
        "value": {
          "allow_mocks": true,
          "hipaa_enabled": true,
          "retention": {
            "audit_log_days": 2555,
            "webhook_delivery_days": 30
          }
        }
      },
      "apiKeyList": {
        "summary": "Two live keys",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
              "object": "api_key",
              "name": "agent-bootstrap",
              "prefix": "ulex_sk_live_7Qm2K",
              "scope": [
                "mcp:tools",
                "read:organizations",
                "write:organizations",
                "read:users",
                "write:users"
              ],
              "application_id": null,
              "ip_allowlist": [],
              "last_used_at": "2026-09-29T14:45:12.000Z",
              "last_used_ip_hash": "sha256:9c2e4a6b…",
              "expires_at": "2026-12-28T09:00:00.000Z",
              "revoked_at": null,
              "expires_in_days": 90,
              "created_at": "2026-09-29T09:00:00.000Z"
            },
            {
              "id": "key_01M3PSW9R0175NAW62NYR403R8",
              "object": "api_key",
              "name": "ci-deployer",
              "prefix": "ulex_sk_live_3Qv8B",
              "scope": [
                "ulex:admin"
              ],
              "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "ip_allowlist": [
                "10.0.0.0/8"
              ],
              "last_used_at": null,
              "last_used_ip_hash": null,
              "expires_at": "2026-10-28T09:00:00.000Z",
              "revoked_at": null,
              "expires_in_days": 30,
              "created_at": "2026-09-29T09:00:00.000Z"
            }
          ],
          "first_id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
          "last_id": "key_01M3PSW9R0175NAW62NYR403R8",
          "has_more": false,
          "next_cursor": null
        }
      },
      "apiKeyCreate": {
        "summary": "Agent bootstrap key",
        "value": {
          "name": "agent-bootstrap",
          "scope": [
            "mcp:tools",
            "read:organizations",
            "write:organizations",
            "read:users",
            "write:users"
          ],
          "application_id": null,
          "ip_allowlist": [],
          "expires_in_days": 90
        }
      },
      "apiKeyCreateNarrow": {
        "summary": "Least privilege reader",
        "value": {
          "name": "read-only-dash",
          "scope": [
            "mcp:tools",
            "read:organizations",
            "read:users"
          ],
          "expires_in_days": 30,
          "ip_allowlist": [
            "10.0.0.0/8"
          ]
        }
      },
      "apiKeyWithSecret": {
        "summary": "Created; the key is shown once",
        "value": {
          "api_key": {
            "id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
            "object": "api_key",
            "name": "agent-bootstrap",
            "prefix": "ulex_sk_live_7Qm2K",
            "scope": [
              "mcp:tools",
              "read:organizations",
              "write:organizations",
              "read:users",
              "write:users"
            ],
            "application_id": null,
            "ip_allowlist": [],
            "last_used_at": null,
            "last_used_ip_hash": null,
            "expires_at": "2026-12-28T09:00:00.000Z",
            "revoked_at": null,
            "expires_in_days": 90,
            "created_at": "2026-09-29T09:00:00.000Z"
          },
          "key": "ulex_sk_live_7Qm2KpLx9Tb4Ns8RfWy3Zc1Hjf6Ee0Au",
          "warning": "This is the only time the key is returned. Store it now."
        }
      },
      "apiKeyRevoked": {
        "summary": "Revoked",
        "value": {
          "id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
          "object": "api_key",
          "name": "agent-bootstrap",
          "prefix": "ulex_sk_live_7Qm2K",
          "scope": [
            "mcp:tools"
          ],
          "revoked_at": "2026-09-29T15:02:11.000Z"
        }
      },
      "signingKeyRotation": {
        "summary": "Rotate access_token keys with a 7-day grace",
        "value": {
          "purpose": "access_token",
          "grace_period_seconds": 604800
        }
      },
      "keyRotationResult": {
        "summary": "Rotated",
        "value": {
          "rotated": true,
          "purposes": [
            "access_token",
            "id_token"
          ],
          "keys": [
            {
              "purpose": "access_token",
              "new_key": {
                "id": "key_01M3PSX7B2KQ4V6W8Y0Z1A3B5C",
                "kid": "key_01M3PSX7B2KQ4V6W8Y0Z1A3B5C",
                "algorithm": "RS256",
                "state": "active"
              },
              "previous_key": {
                "id": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
                "kid": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
                "state": "retiring"
              },
              "grace_period_seconds": 604800,
              "previous_key_revokes_at": "2026-10-06T15:02:11.000Z",
              "jwks_url": "https://ulexid.com/api/v1/oauth2/keys"
            },
            {
              "purpose": "id_token",
              "new_key": {
                "id": "key_01M3PSX9D4LKM6N8P0Q2R4S6T8",
                "kid": "key_01M3PSX9D4LKM6N8P0Q2R4S6T8",
                "algorithm": "RS256",
                "state": "active"
              },
              "previous_key": {
                "id": "key_01M3PSW9R0175NAW62NYR403R8",
                "kid": "key_01M3PSW9R0175NAW62NYR403R8",
                "state": "retiring"
              },
              "grace_period_seconds": 604800,
              "previous_key_revokes_at": "2026-10-06T15:02:11.000Z",
              "jwks_url": "https://ulexid.com/api/v1/oauth2/keys"
            }
          ],
          "jwks_url": "https://ulexid.com/api/v1/oauth2/keys"
        }
      },
      "applicationList": {
        "summary": "One application",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "object": "application",
              "name": "Acme Support",
              "slug": "acme-support",
              "type": "first_party",
              "description": "Customer support console for Acme",
              "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
              "redirect_uris": [
                "https://app.example.com/auth/callback"
              ],
              "grant_types": [
                "authorization_code",
                "refresh_token"
              ],
              "response_types": [
                "code"
              ],
              "response_mode": "form_post",
              "token_endpoint_auth_method": "client_secret_post",
              "require_pkce": true,
              "pkce_methods": [
                "S256"
              ],
              "grant_access_to_organization": true,
              "organization_usage": "allow",
              "oidc_conformant": true,
              "acr_values": null,
              "sign_in_with_email_enabled": true,
              "sign_in_with_social_enabled": false,
              "sign_up_enabled": true,
              "cookie_domain": ".ulexid.com",
              "cross_app_sso_enabled": true,
              "cross_app_sso_redirect_urls": [],
              "branding": {
                "primary_color": "#4f46e5",
                "background_color": "#ffffff",
                "logo_url": null,
                "favicon_url": null,
                "app_name": "Acme Support"
              },
              "default_locale": "en",
              "created_at": "2026-09-29T14:42:05.000Z",
              "updated_at": "2026-09-29T14:42:05.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "last_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "has_more": false,
          "next_cursor": null
        }
      },
      "applicationCreate": {
        "summary": "First-party OIDC client",
        "value": {
          "name": "Acme Support",
          "slug": "acme-support",
          "type": "first_party",
          "description": "Customer support console for Acme",
          "redirect_uris": [
            "https://app.example.com/auth/callback"
          ],
          "grant_types": [
            "authorization_code",
            "refresh_token"
          ],
          "response_types": [
            "code"
          ],
          "response_mode": "form_post",
          "token_endpoint_auth_method": "client_secret_post",
          "require_pkce": true,
          "pkce_methods": [
            "S256"
          ],
          "cross_app_sso_enabled": true,
          "cookie_domain": ".ulexid.com",
          "default_locale": "en"
        }
      },
      "applicationCreateLocalhost": {
        "summary": "With a loopback redirect for local development",
        "value": {
          "name": "Acme Support Local",
          "slug": "acme-support-local",
          "redirect_uris": [
            "http://localhost:3000/auth/callback",
            "http://127.0.0.1:5173/auth/callback"
          ],
          "grant_types": [
            "authorization_code",
            "refresh_token",
            "client_credentials",
            "urn:ietf:params:oauth:grant-type:token-exchange"
          ],
          "require_pkce": true,
          "pkce_methods": [
            "S256"
          ],
          "sign_in_with_email_enabled": true
        }
      },
      "application": {
        "summary": "Application",
        "value": {
          "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "object": "application",
          "name": "Acme Support",
          "slug": "acme-support",
          "type": "first_party",
          "description": "Customer support console for Acme",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "redirect_uris": [
            "https://app.example.com/auth/callback"
          ],
          "grant_types": [
            "authorization_code",
            "refresh_token"
          ],
          "response_types": [
            "code"
          ],
          "response_mode": "form_post",
          "token_endpoint_auth_method": "client_secret_post",
          "require_pkce": true,
          "pkce_methods": [
            "S256"
          ],
          "grant_access_to_organization": true,
          "organization_usage": "allow",
          "oidc_conformant": true,
          "acr_values": null,
          "sign_in_with_email_enabled": true,
          "sign_in_with_social_enabled": false,
          "sign_up_enabled": true,
          "cookie_domain": ".ulexid.com",
          "cross_app_sso_enabled": true,
          "cross_app_sso_redirect_urls": [],
          "branding": {
            "primary_color": "#4f46e5",
            "background_color": "#ffffff",
            "logo_url": null,
            "favicon_url": null,
            "app_name": "Acme Support"
          },
          "default_locale": "en",
          "created_at": "2026-09-29T14:42:05.000Z",
          "updated_at": "2026-09-29T14:42:05.000Z",
          "deleted_at": null
        }
      },
      "applicationUpdate": {
        "summary": "Add a redirect and enable token exchange",
        "value": {
          "redirect_uris": [
            "https://app.example.com/auth/callback",
            "https://app.example.com/auth/callback/alt"
          ],
          "grant_types": [
            "authorization_code",
            "refresh_token",
            "urn:ietf:params:oauth:grant-type:token-exchange"
          ],
          "cross_app_sso_enabled": true
        }
      },
      "deletedApplication": {
        "summary": "Soft deleted",
        "value": {
          "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "object": "application",
          "deleted": true,
          "deleted_at": "2026-09-29T16:00:00.000Z",
          "restore_window_days": 30
        }
      },
      "applicationCredentials": {
        "summary": "Credentials and endpoints",
        "value": {
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "token_endpoint_auth_method": "client_secret_post",
          "authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
          "token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
          "userinfo_endpoint": "https://ulexid.com/api/v1/oauth2/userinfo",
          "jwks_uri": "https://ulexid.com/api/v1/oauth2/keys",
          "introspection_endpoint": "https://ulexid.com/api/v1/oauth2/introspect",
          "revocation_endpoint": "https://ulexid.com/api/v1/oauth2/revoke",
          "scim_base_url": "https://ulexid.com/api/v1/scim/v2",
          "saml_sp_metadata_url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata",
          "hosted_login_url": "https://ulexid.com/auth/app_01M3PSV7J8TBSPHG95CYSEX32B",
          "saml_signing_certificate": "-----BEGIN CERTIFICATE-----\nMIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQ…\n-----END CERTIFICATE-----",
          "saml_signing_certificate_expires_at": "2027-03-11T00:00:00.000Z",
          "saml_signing_kid": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
          "issued_at": "2026-09-29T14:42:05.000Z"
        }
      },
      "rotateSecret": {
        "summary": "Rotate with a 24-hour grace",
        "value": {
          "grace_period_seconds": 86400
        }
      },
      "secretRotation": {
        "summary": "New secret; the old one is valid for 24 hours",
        "value": {
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_Tn4Wv8Kp2LmQ6Rb9Yc3Xd7Fs1Hg0Ja5E",
          "previous_secret_expires_at": "2026-09-30T14:55:00.000Z",
          "grace_period_seconds": 86400
        }
      },
      "samlMetadata": {
        "summary": "ulex as IdP",
        "value": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<EntityDescriptor xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B\">\n  <IDPSSODescriptor WantAuthnRequestsSigned=\"false\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\">\n    <KeyDescriptor use=\"signing\">\n      <ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\n        <ds:X509Data><ds:X509Certificate>MIIDQjCCAiqgAwIBAgIGATz/FuLiMA0GCSqGSIb3DQ…</ds:X509Certificate></ds:X509Data>\n      </ds:KeyInfo>\n    </KeyDescriptor>\n    <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</NameIDFormat>\n    <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso\"/>\n    <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" Location=\"https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso\"/>\n    <SingleLogoutService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/slo\"/>\n    <AttributeConsumingService index=\"1\">\n      <ServiceName xml:lang=\"en\">Acme Support</ServiceName>\n      <RequestedAttribute Name=\"email\" NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:basic\" isRequired=\"1\"/>\n      <RequestedAttribute Name=\"firstName\" isRequired=\"0\"/>\n      <RequestedAttribute Name=\"groups\" isRequired=\"0\"/>\n    </AttributeConsumingService>\n  </IDPSSODescriptor>\n</EntityDescriptor>"
      },
      "idpMetadata": {
        "summary": "Customer IdP",
        "value": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<EntityDescriptor xmlns=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7\">\n  <IDPSSODescriptor WantAuthnRequestsSigned=\"false\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\">\n    <KeyDescriptor use=\"signing\">\n      <ds:KeyInfo xmlns:ds=\"http://www.w3.org/2000/09/xmldsig#\">\n        <ds:X509Data><ds:X509Certificate>MIIE1DCCA3CgAwIBAgIULSJ+aV2PvJ0d1d1pTqU2KzKzANBgkqhkiG9w0BAQUFADCBpDELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwHhcNMjYwNDI4MDAwMDAwWhcNMjcwNDE4MDAwMDAwWjCBhzELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwggEiMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ…</ds:X509Certificate></ds:X509Data>\n      </ds:KeyInfo>\n    </KeyDescriptor>\n    <NameIDFormat>urn:oasis:names:tc:SAML:2.0:nameid-format:persistent</NameIDFormat>\n    <SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml\"/>\n    <SingleLogoutService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" Location=\"https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/slo/saml\"/>\n  </IDPSSODescriptor>\n</EntityDescriptor>"
      },
      "oidcDiscovery": {
        "summary": "Discovery",
        "value": {
          "issuer": "https://ulexid.com",
          "authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
          "token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
          "userinfo_endpoint": "https://ulexid.com/api/v1/oauth2/userinfo",
          "jwks_uri": "https://ulexid.com/api/v1/oauth2/keys",
          "introspection_endpoint": "https://ulexid.com/api/v1/oauth2/introspect",
          "revocation_endpoint": "https://ulexid.com/api/v1/oauth2/revoke",
          "device_authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize/device",
          "end_session_endpoint": "https://ulexid.com/auth/session/end",
          "response_types_supported": [
            "code",
            "id_token",
            "code id_token"
          ],
          "response_modes_supported": [
            "query",
            "fragment",
            "form_post"
          ],
          "grant_types_supported": [
            "authorization_code",
            "refresh_token",
            "client_credentials",
            "urn:ietf:params:oauth:grant-type:device_code",
            "urn:ietf:params:oauth:grant-type:token-exchange"
          ],
          "subject_types_supported": [
            "public",
            "pairwise"
          ],
          "id_token_signing_alg_values_supported": [
            "RS256",
            "RS384",
            "RS512",
            "ES256",
            "ES384",
            "PS256",
            "EdDSA"
          ],
          "userinfo_signing_alg_values_supported": [
            "none",
            "RS256"
          ],
          "token_endpoint_auth_methods_supported": [
            "client_secret_basic",
            "client_secret_post",
            "private_key_jwt",
            "tls_client_auth",
            "self_signed_tls_client_auth",
            "none"
          ],
          "dpop_signing_alg_values_supported": [
            "ES256",
            "ES384",
            "RS256",
            "PS256",
            "EdDSA"
          ],
          "tls_client_certificate_bound_access_tokens": true,
          "token_endpoint_auth_signing_alg_values_supported": [
            "RS256",
            "PS256",
            "ES256"
          ],
          "scopes_supported": [
            "openid",
            "profile",
            "email",
            "offline_access",
            "ulex:admin",
            "read:organizations",
            "write:organizations",
            "read:users",
            "write:users",
            "read:groups",
            "write:groups",
            "read:connections",
            "write:connections",
            "read:directories",
            "write:directories",
            "read:applications",
            "write:applications",
            "read:audit_logs",
            "read:webhooks",
            "write:webhooks",
            "read:deployments",
            "write:deployments",
            "mcp:tools",
            "mcp:admin",
            "scim:provision",
            "saml:consume",
            "sso:impersonate"
          ],
          "claims_supported": [
            "iss",
            "sub",
            "aud",
            "exp",
            "iat",
            "nbf",
            "jti",
            "azp",
            "name",
            "given_name",
            "family_name",
            "preferred_username",
            "email",
            "email_verified",
            "locale",
            "picture",
            "updated_at",
            "org_id",
            "org_slug",
            "connection_id",
            "sid",
            "amr",
            "acr",
            "https://ulexid.com/claims"
          ],
          "code_challenge_methods_supported": [
            "S256",
            "plain"
          ],
          "dpop_signing_alg_values_supported": [
            "ES256",
            "RS256"
          ],
          "backchannel_logout_supported": true,
          "backchannel_logout_session_supported": true,
          "claims_parameter_supported": true,
          "request_parameter_supported": true,
          "require_pushed_authorization_requests": false
        }
      },
      "organizationList": {
        "summary": "Two customers",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "object": "organization",
              "name": "Acme Corp",
              "slug": "acme",
              "logo_url": "https://cdn.example.com/acme.png",
              "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "sso_only": true,
              "allow_profiles_outside_organization": false,
              "default_connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "metadata": {
                "plan_tier": "enterprise"
              },
              "created_at": "2026-09-29T14:42:06.000Z",
              "updated_at": "2026-09-29T14:42:06.000Z",
              "deleted_at": null
            },
            {
              "id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
              "object": "organization",
              "name": "Globex",
              "slug": "globex",
              "logo_url": null,
              "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "connection_id": null,
              "sso_only": false,
              "allow_profiles_outside_organization": false,
              "default_connection_id": null,
              "metadata": {},
              "created_at": "2026-09-29T14:42:06.000Z",
              "updated_at": "2026-09-29T14:42:06.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "last_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
          "has_more": false,
          "next_cursor": null
        }
      },
      "organizationCreate": {
        "summary": "SSO-only customer",
        "value": {
          "name": "Acme Corp",
          "slug": "acme",
          "sso_only": true,
          "allow_profiles_outside_organization": false
        }
      },
      "organizationCreateWithMetadata": {
        "summary": "With flat metadata",
        "value": {
          "name": "Globex",
          "slug": "globex",
          "logo_url": "https://cdn.example.com/globex.png",
          "metadata": {
            "plan_tier": "enterprise",
            "csm": "dana@acme.example"
          }
        }
      },
      "organization": {
        "summary": "Organization",
        "value": {
          "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "object": "organization",
          "name": "Acme Corp",
          "slug": "acme",
          "logo_url": "https://cdn.example.com/acme.png",
          "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "sso_only": true,
          "allow_profiles_outside_organization": false,
          "default_connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "metadata": {
            "plan_tier": "enterprise"
          },
          "created_at": "2026-09-29T14:42:06.000Z",
          "updated_at": "2026-09-29T14:42:06.000Z",
          "deleted_at": null
        }
      },
      "organizationUpdate": {
        "summary": "Bind the SSO connection",
        "value": {
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "default_connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "sso_only": true
        }
      },
      "deletedOrganization": {
        "summary": "Soft deleted",
        "value": {
          "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "object": "organization",
          "deleted": true,
          "deleted_at": "2026-09-29T16:00:00.000Z",
          "restore_window_days": 30
        }
      },
      "domainList": {
        "summary": "One verified domain",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
              "object": "domain",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "name": "acme.example",
              "state": "verified",
              "verification_token": "ulex-verify-9f3b7c1a4d8e2f60a5b9c3d7e1f48260",
              "verification_strategy": "dns",
              "verified_at": "2026-09-29T14:42:10.000Z",
              "created_at": "2026-09-29T14:42:10.000Z",
              "updated_at": "2026-09-29T14:42:10.000Z"
            }
          ],
          "first_id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
          "last_id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
          "has_more": false,
          "next_cursor": null
        }
      },
      "domainCreate": {
        "summary": "Add acme.example",
        "value": {
          "domain": "acme.example",
          "verification_strategy": "dns"
        }
      },
      "domainPending": {
        "summary": "Pending verification",
        "value": {
          "id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
          "object": "domain",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "acme.example",
          "state": "pending",
          "verification_token": "ulex-verify-9f3b7c1a4d8e2f60a5b9c3d7e1f48260",
          "verification_strategy": "dns",
          "dns_records": [
            {
              "type": "TXT",
              "name": "_ulex-challenge.acme.example",
              "value": "ulex-verify-9f3b7c1a4d8e2f60a5b9c3d7e1f48260",
              "ttl": 3600,
              "purpose": "Domain ownership verification (RFC 8555 style challenge)"
            }
          ],
          "created_at": "2026-09-29T14:42:10.000Z",
          "updated_at": "2026-09-29T14:42:10.000Z"
        }
      },
      "domainVerified": {
        "summary": "Verified",
        "value": {
          "id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
          "object": "domain",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "acme.example",
          "state": "verified",
          "verification_token": "ulex-verify-9f3b7c1a4d8e2f60a5b9c3d7e1f48260",
          "verification_strategy": "dns",
          "verified_at": "2026-09-29T14:42:10.000Z",
          "created_at": "2026-09-29T14:42:10.000Z",
          "updated_at": "2026-09-29T14:42:10.000Z"
        }
      },
      "deletedDomain": {
        "summary": "Removed",
        "value": {
          "id": "dom_01M3PSVCEGK9H35GZJK25HN08D",
          "object": "domain",
          "deleted": true
        }
      },
      "membershipList": {
        "summary": "Two members",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT",
              "object": "organization_membership",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "role": "owner",
              "group_ids": [
                "grp_01M3PSVED0M9RJTYH5AC72C253"
              ],
              "created_at": "2026-09-29T14:42:11.000Z",
              "updated_at": "2026-09-29T14:42:11.000Z",
              "organization": {
                "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
                "name": "Acme Corp",
                "slug": "acme"
              }
            },
            {
              "id": "mem_01M3PSW0YRNEQQAP9T1JP9FC2Y",
              "object": "organization_membership",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "user_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "role": "member",
              "group_ids": [
                "grp_01M3PSVED0M9RJTYH5AC72C253"
              ],
              "created_at": "2026-09-29T14:47:04.000Z",
              "updated_at": "2026-09-29T14:47:04.000Z",
              "organization": {
                "id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
                "name": "Acme Corp",
                "slug": "acme"
              }
            }
          ],
          "first_id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT",
          "last_id": "mem_01M3PSW0YRNEQQAP9T1JP9FC2Y",
          "has_more": false,
          "next_cursor": null
        }
      },
      "membership": {
        "summary": "Owner membership",
        "value": {
          "id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT",
          "object": "organization_membership",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "role": "owner",
          "group_ids": [
            "grp_01M3PSVED0M9RJTYH5AC72C253"
          ],
          "created_at": "2026-09-29T14:42:11.000Z",
          "updated_at": "2026-09-29T14:42:11.000Z"
        }
      },
      "membershipCreate": {
        "summary": "Add Dana as owner",
        "value": {
          "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "role": "owner",
          "group_ids": [
            "grp_01M3PSVED0M9RJTYH5AC72C253"
          ]
        }
      },
      "membershipUpdate": {
        "summary": "Promote Pat to admin",
        "value": {
          "user_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
          "role": "admin",
          "group_ids": [
            "grp_01M3PSVED0M9RJTYH5AC72C253"
          ]
        }
      },
      "deletedMembership": {
        "summary": "Removed",
        "value": {
          "id": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT",
          "object": "organization_membership",
          "deleted": true
        }
      },
      "groupList": {
        "summary": "One group",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
              "object": "group",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "name": "Engineering",
              "slug": "engineering",
              "description": "Eng staff",
              "scim_id": null,
              "source": "rule",
              "member_count": 2,
              "created_at": "2026-09-29T14:42:12.000Z",
              "updated_at": "2026-09-29T14:42:12.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "last_id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "has_more": false,
          "next_cursor": null
        }
      },
      "group": {
        "summary": "Group",
        "value": {
          "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "object": "group",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "Engineering",
          "slug": "engineering",
          "description": "Eng staff",
          "scim_id": null,
          "source": "rule",
          "member_count": 2,
          "created_at": "2026-09-29T14:42:12.000Z",
          "updated_at": "2026-09-29T14:42:12.000Z",
          "deleted_at": null
        }
      },
      "groupCreate": {
        "summary": "Rule-based group",
        "value": {
          "name": "Engineering",
          "slug": "engineering",
          "description": "Eng staff",
          "source": "rule"
        }
      },
      "groupUpdate": {
        "summary": "Rename",
        "value": {
          "name": "Engineering & Platform",
          "description": "Renamed 2026-09"
        }
      },
      "deletedGroup": {
        "summary": "Deleted",
        "value": {
          "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "object": "group",
          "deleted": true
        }
      },
      "groupMembersReplace": {
        "summary": "Replace the member set",
        "value": {
          "user_ids": [
            "usr_01M3PSV9GRT8GQGEG686AR1W9S",
            "usr_01M3PSWBPGS08FWV4NV7P9VNFN"
          ]
        }
      },
      "groupWithMembers": {
        "summary": "Group with members inlined",
        "value": {
          "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "object": "group",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "Engineering",
          "slug": "engineering",
          "description": "Eng staff",
          "scim_id": null,
          "source": "rule",
          "member_count": 2,
          "members": [
            {
              "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "email": "dana@acme.example"
            },
            {
              "user_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "email": "pat@acme.example"
            }
          ],
          "created_at": "2026-09-29T14:42:12.000Z",
          "updated_at": "2026-09-29T14:42:12.000Z",
          "deleted_at": null
        }
      },
      "userList": {
        "summary": "Two users",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "object": "user",
              "email": "dana@acme.example",
              "email_verified": true,
              "first_name": "Dana",
              "last_name": "Okafor",
              "display_name": "Dana Okafor",
              "external_id": "okta-00u1sAM2xY8ZQ4H1",
              "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "job_title": "Support Lead",
              "department": "Customer Success",
              "scim": {
                "title": "Support Lead",
                "user_type": "Employee",
                "preferred_language": "en-US",
                "active": true
              },
              "status": "active",
              "last_seen_at": "2026-09-29T14:45:12.000Z",
              "metadata": {
                "source": "bootstrap"
              },
              "created_at": "2026-09-29T14:42:07.000Z",
              "updated_at": "2026-09-29T14:42:07.000Z",
              "deleted_at": null
            },
            {
              "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "object": "user",
              "email": "pat@acme.example",
              "email_verified": true,
              "first_name": "Pat",
              "last_name": "Iyer",
              "display_name": "Pat Iyer",
              "external_id": "okta-00u9xK2mB7yLt4N",
              "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "job_title": "Support Engineer",
              "department": "Customer Success",
              "scim": {
                "title": "Support Lead",
                "user_type": "Employee",
                "preferred_language": "en-US",
                "active": true
              },
              "status": "active",
              "last_seen_at": "2026-09-29T14:45:12.000Z",
              "metadata": {
                "source": "bootstrap"
              },
              "created_at": "2026-09-29T14:42:07.000Z",
              "updated_at": "2026-09-29T14:42:07.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "last_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
          "has_more": false,
          "next_cursor": null
        }
      },
      "userCreate": {
        "summary": "Create Dana",
        "value": {
          "email": "dana@acme.example",
          "email_verified": true,
          "first_name": "Dana",
          "last_name": "Okafor",
          "job_title": "Support Lead",
          "department": "Customer Success",
          "metadata": {
            "source": "bootstrap"
          }
        }
      },
      "userCreateWithScim": {
        "summary": "Create with SCIM sub-attributes",
        "value": {
          "email": "pat@acme.example",
          "email_verified": true,
          "first_name": "Pat",
          "last_name": "Iyer",
          "scim": {
            "user_type": "Employee",
            "preferred_language": "en-US",
            "locale": "en-US",
            "timezone": "America/New_York",
            "active": true
          },
          "external_id": "okta-00u9xK2mB7yLt4N"
        }
      },
      "user": {
        "summary": "User",
        "value": {
          "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "object": "user",
          "email": "dana@acme.example",
          "email_verified": true,
          "first_name": "Dana",
          "last_name": "Okafor",
          "display_name": "Dana Okafor",
          "external_id": "okta-00u1sAM2xY8ZQ4H1",
          "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "job_title": "Support Lead",
          "department": "Customer Success",
          "scim": {
            "title": "Support Lead",
            "user_type": "Employee",
            "preferred_language": "en-US",
            "active": true
          },
          "status": "active",
          "last_seen_at": "2026-09-29T14:45:12.000Z",
          "metadata": {
            "source": "bootstrap"
          },
          "created_at": "2026-09-29T14:42:07.000Z",
          "updated_at": "2026-09-29T14:42:07.000Z",
          "deleted_at": null
        }
      },
      "userUpdate": {
        "summary": "Promote and re-title",
        "value": {
          "job_title": "Head of Support",
          "status": "active"
        }
      },
      "deletedUser": {
        "summary": "Soft deleted",
        "value": {
          "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "object": "user",
          "deleted": true,
          "deleted_at": "2026-09-29T16:12:00.000Z",
          "restore_window_days": 30
        }
      },
      "suspendUser": {
        "summary": "Offboarding",
        "value": {
          "reason": "Offboarded 2026-09-29"
        }
      },
      "suspendResult": {
        "summary": "Suspended; sessions and token families revoked",
        "value": {
          "id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "object": "user",
          "status": "suspended",
          "revoked_sessions": 2,
          "revoked_refresh_token_families": 2,
          "webhook_events_emitted": [
            "user.suspended",
            "session.revoked"
          ],
          "audit_action": "user.suspended"
        }
      },
      "passkeyList": {
        "summary": "One passkey",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A",
              "object": "passkey",
              "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "credential_id": "8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mN",
              "counter": 0,
              "transports": [
                "internal",
                "hybrid"
              ],
              "aaguid": "adce0002-35bc-c60a-648b-0b25f1f05503",
              "device_type": "multi_device",
              "backed_up": true,
              "name": "MacBook Pro",
              "created_at": "2026-09-29T14:42:22.000Z",
              "last_used_at": "2026-09-29T14:45:12.000Z"
            }
          ],
          "first_id": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A",
          "last_id": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A",
          "has_more": false,
          "next_cursor": null
        }
      },
      "mfaFactorList": {
        "summary": "One MFA factor",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ",
              "object": "mfa_factor",
              "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "type": "totp",
              "target_hint": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
              "verified": true,
              "created_at": "2026-09-29T14:42:23.000Z",
              "last_used_at": "2026-09-29T14:45:12.000Z"
            }
          ],
          "first_id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ",
          "last_id": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ",
          "has_more": false,
          "next_cursor": null
        }
      },
      "connectionList": {
        "summary": "One active connection",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "object": "connection",
              "tenant_id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "name": "Acme SSO",
              "state": "active",
              "config": {
                "strategy": "mock_sso",
                "mock": {
                  "seed_users": [
                    {
                      "email": "dana@acme.example",
                      "first_name": "Dana",
                      "last_name": "Okafor",
                      "groups": [
                        "engineering"
                      ],
                      "mfa_enrolled": false,
                      "status": "active"
                    }
                  ],
                  "force_failure": false,
                  "latency_ms": 0
                }
              },
              "domains": [
                "acme.example"
              ],
              "domains_state": "verified",
              "organization_ids": [
                "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
              ],
              "directory_ids": [],
              "discovery": {
                "authorization_endpoint": null,
                "token_endpoint": null,
                "userinfo_endpoint": null,
                "jwks_uri": null,
                "issuer": null,
                "fetched_at": null,
                "error": null
              },
              "last_auth_at": "2026-09-29T14:45:12.000Z",
              "last_auth_result": "success",
              "last_auth_error": null,
              "created_at": "2026-09-29T14:42:08.000Z",
              "updated_at": "2026-09-29T14:42:08.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "last_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "has_more": false,
          "next_cursor": null
        }
      },
      "connectionCreateMockSso": {
        "summary": "Built-in simulated IdP",
        "value": {
          "name": "Acme SSO",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "domains": [
            "acme.example"
          ],
          "config": {
            "strategy": "mock_sso",
            "mock": {
              "seed_users": [
                {
                  "email": "dana@acme.example",
                  "first_name": "Dana",
                  "last_name": "Okafor",
                  "job_title": "Support Lead",
                  "department": "Customer Success",
                  "groups": [
                    "engineering"
                  ],
                  "mfa_enrolled": false,
                  "status": "active"
                }
              ],
              "force_failure": false,
              "latency_ms": 0
            }
          }
        }
      },
      "connectionCreateOktaOidc": {
        "summary": "Real Okta issuer, secret from the environment",
        "value": {
          "name": "Okta Acme",
          "config": {
            "strategy": "okta_oidc",
            "oidc": {
              "issuer": "https://acme.okta.com/oauth2/default",
              "client_id": "0oa3kq9x2mB7cVd1Rf6sT4pW8L",
              "client_secret": "env:ULEX_TEST_OKTA_SECRET",
              "scopes": [
                "openid",
                "profile",
                "email",
                "groups"
              ],
              "allowed_domains": [
                "acme.example"
              ],
              "require_jit_provisioning": true,
              "jit_default_role": "member",
              "attribute_mapping": {
                "email": "email",
                "first_name": "given_name",
                "last_name": "family_name",
                "display_name": "name",
                "job_title": "job_title",
                "department": "department",
                "external_id": "sub",
                "groups": "groups"
              }
            }
          }
        }
      },
      "connectionCreateSaml": {
        "summary": "Customer SAML IdP",
        "value": {
          "name": "Globex SAML",
          "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
          "config": {
            "strategy": "saml",
            "saml": {
              "entity_id": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7",
              "sso_url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml",
              "slo_url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/slo/saml",
              "x509_certificate": "MIIE1DCCA3CgAwIBAgIULSJ+aV2PvJ0d1d1pTqU2KzKzANBgkqhkiG9w0BAQUFADCBpDELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwHhcNMjYwNDI4MDAwMDAwWhcNMjcwNDE4MDAwMDAwWjCBhzELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwggEiMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ…",
              "name_id_format": "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
              "binding": "saml_redirect",
              "want_response_signed": true,
              "want_assertion_signed": true,
              "signature_validation": "strict",
              "allowed_clock_skew_seconds": 120,
              "name_id_transformations": "email",
              "allow_create": true,
              "allow_update": true,
              "allow_link": true,
              "group_attribute": "groups",
              "groups_attribute": "groups",
              "active_attribute": "active",
              "active_value": "true",
              "attribute_mapping": {
                "email": "email",
                "first_name": "firstName",
                "last_name": "lastName",
                "display_name": "displayName",
                "job_title": "title",
                "department": "department",
                "external_id": "userId",
                "groups": "groups"
              }
            }
          }
        }
      },
      "connection": {
        "summary": "Connection in draft",
        "value": {
          "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "object": "connection",
          "tenant_id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "Acme SSO",
          "state": "draft",
          "config": {
            "strategy": "mock_sso",
            "mock": {
              "seed_users": [
                {
                  "email": "dana@acme.example",
                  "first_name": "Dana",
                  "last_name": "Okafor",
                  "groups": [
                    "engineering"
                  ],
                  "mfa_enrolled": false,
                  "status": "active"
                }
              ],
              "force_failure": false,
              "latency_ms": 0
            }
          },
          "domains": [
            "acme.example"
          ],
          "domains_state": "verified",
          "organization_ids": [
            "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          ],
          "directory_ids": [],
          "discovery": {
            "authorization_endpoint": null,
            "token_endpoint": null,
            "userinfo_endpoint": null,
            "jwks_uri": null,
            "issuer": null,
            "fetched_at": null,
            "error": null
          },
          "last_auth_at": null,
          "last_auth_result": null,
          "last_auth_error": null,
          "created_at": "2026-09-29T14:42:08.000Z",
          "updated_at": "2026-09-29T14:42:08.000Z",
          "deleted_at": null
        }
      },
      "connectionUpdate": {
        "summary": "Arm a forced failure",
        "value": {
          "config": {
            "strategy": "mock_sso",
            "mock": {
              "seed_users": [
                {
                  "email": "dana@acme.example"
                }
              ],
              "force_failure": true,
              "latency_ms": 0
            }
          }
        }
      },
      "connectionActive": {
        "summary": "Activated",
        "value": {
          "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "object": "connection",
          "tenant_id": "ten_01M3PSV6K0HFZ62YZ6AKB191WW",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "Acme SSO",
          "state": "active",
          "config": {
            "strategy": "mock_sso",
            "mock": {
              "seed_users": [
                {
                  "email": "dana@acme.example",
                  "first_name": "Dana",
                  "last_name": "Okafor",
                  "groups": [
                    "engineering"
                  ],
                  "mfa_enrolled": false,
                  "status": "active"
                }
              ],
              "force_failure": false,
              "latency_ms": 0
            }
          },
          "domains": [
            "acme.example"
          ],
          "domains_state": "verified",
          "organization_ids": [
            "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          ],
          "directory_ids": [],
          "discovery": {
            "authorization_endpoint": null,
            "token_endpoint": null,
            "userinfo_endpoint": null,
            "jwks_uri": null,
            "issuer": null,
            "fetched_at": null,
            "error": null
          },
          "last_auth_at": "2026-09-29T14:45:12.000Z",
          "last_auth_result": "success",
          "last_auth_error": null,
          "created_at": "2026-09-29T14:42:08.000Z",
          "updated_at": "2026-09-29T14:42:08.000Z",
          "deleted_at": null
        }
      },
      "deletedConnection": {
        "summary": "Soft deleted; sessions survive until they expire",
        "value": {
          "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "object": "connection",
          "deleted": true,
          "revoked_sessions": 2
        }
      },
      "connectionVerification": {
        "summary": "Every check passed, and the endpoints were cached",
        "value": {
          "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
          "valid": true,
          "checks": [
            {
              "check": "client_id present",
              "status": "passed",
              "detail": "0oa1b2c3d4e5f6g7h8i9"
            },
            {
              "check": "issuer present",
              "status": "passed",
              "detail": "https://acme.okta.com/oauth2/default"
            },
            {
              "check": "openid scope requested",
              "status": "passed",
              "detail": "openid email profile"
            },
            {
              "check": "discovery document",
              "status": "passed",
              "detail": "issuer matches https://acme.okta.com/oauth2/default"
            },
            {
              "check": "authorization code flow",
              "status": "passed",
              "detail": "https://acme.okta.com/oauth2/default/v1/authorize"
            },
            {
              "check": "token endpoint",
              "status": "passed",
              "detail": "https://acme.okta.com/oauth2/default/v1/token"
            },
            {
              "check": "jwks",
              "status": "passed",
              "detail": "https://acme.okta.com/oauth2/default/v1/keys"
            },
            {
              "check": "client_id configured",
              "status": "passed",
              "detail": "0oa1b2c3d4e5f6g7h8i9 — ulex cannot confirm the IdP recognises it until someone signs in"
            }
          ]
        }
      },
      "samlLoginUrl": {
        "summary": "AuthnRequest URL",
        "value": {
          "url": "https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/sso/saml?SAMLRequest=PHNhbWxwOlJlc3BvbnNlIHhtbG5zOnNhbWxw…&RelayState=st_9Kq2WmB7yLt4NxZ",
          "request_id": "req_01M3PSX7B2KQ4V6W8Y0Z1A3B5C",
          "expires_at": "2026-09-29T14:50:00.000Z"
        }
      },
      "samlAcs": {
        "summary": "Assertion posted by the customer IdP",
        "value": {
          "SAMLResponse": "PHNhbWw6UmVzcG9uc2UgeG1sbnM6c2FtbHA6UmVzcG9uc2U…",
          "RelayState": "st_9Kq2WmB7yLt4NxZ"
        }
      },
      "samlAcsResult": {
        "summary": "Assertion consumed",
        "value": {
          "session_id": "ses_01M3PSW6T8FT4M24DH9P8YAY32",
          "user_id": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
          "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
          "outcome": "success",
          "stage": "complete",
          "strategy": "saml",
          "amr": [
            "saml"
          ],
          "relay_state": "st_9Kq2WmB7yLt4NxZ",
          "acs_redirect": "https://app.example.com/auth/callback?code=ac_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8&state=st_9Kq2WmB7yLt4NxZ",
          "duration_ms": 96
        }
      },
      "samlSlo": {
        "summary": "LogoutRequest",
        "value": {
          "SAMLRequest": "PHNhbWxwOkxvZ291dFJlcXVlc3QgeG1sbnM6c2FtbHA6c2FtbHA…",
          "RelayState": "st_9Kq2WmB7yLt4NxZ"
        }
      },
      "samlSso": {
        "summary": "Unsolicited assertion",
        "value": {
          "SAMLResponse": "PHNhbWw6UmVzcG9uc2UgeG1sbnM6c2FtbHA6UmVzcG9uc2U…",
          "RelayState": "st_9Kq2WmB7yLt4NxZ"
        }
      },
      "samlSsoResult": {
        "summary": "IdP-initiated session created",
        "value": {
          "session_id": "ses_01M3PSW6T8FT4M24DH9P8YAY32",
          "user_id": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
          "organization_id": "org_01M3PSVT404FMFWPN6QAMM2R4P",
          "outcome": "success",
          "stage": "complete",
          "strategy": "saml",
          "amr": [
            "saml"
          ],
          "acs_redirect": "https://app.example.com/auth/callback?code=ac_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8&state=st_9Kq2WmB7yLt4NxZ",
          "duration_ms": 88
        }
      },
      "authAttemptList": {
        "summary": "One successful attempt",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
              "object": "auth_attempt",
              "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "strategy": "mock_sso",
              "outcome": "success",
              "stage": "complete",
              "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "error_code": null,
              "error_message": null,
              "duration_ms": 214,
              "ip_hash": "sha256:9c2e4a6b…",
              "user_agent": "ulex-mcp/2025.9.1",
              "correlation_id": "onboard-acme-2026-09-29",
              "started_at": "2026-09-29T14:45:12.000Z",
              "finished_at": "2026-09-29T14:45:12.000Z"
            }
          ],
          "first_id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
          "last_id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
          "has_more": false,
          "next_cursor": null
        }
      },
      "directoryList": {
        "summary": "One directory",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "object": "directory",
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "name": "Acme (Okta)",
              "provider": "okta",
              "state": "active",
              "domain": "acme.example",
              "scim_base_url": "https://acme.okta.com/scim/v2",
              "inbound_scim_enabled": true,
              "scim_poll_interval_seconds": 900,
              "has_scim_token": true,
              "has_inbound_scim_token": true,
              "has_client_secret": false,
              "last_synced_at": "2026-09-29T14:50:00.000Z",
              "last_sync_status": "ok",
              "last_sync_error": null,
              "created_at": "2026-09-29T14:42:09.000Z",
              "updated_at": "2026-09-29T14:50:00.000Z",
              "deleted_at": null
            }
          ],
          "first_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "last_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "has_more": false,
          "next_cursor": null
        }
      },
      "directoryCreateInbound": {
        "summary": "Inbound SCIM endpoint for a customer IdP",
        "value": {
          "name": "Acme (Okta)",
          "provider": "okta",
          "domain": "acme.example",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "inbound_scim_enabled": true,
          "scim_poll_interval_seconds": 900
        }
      },
      "directoryCreateOutbound": {
        "summary": "Outbound poll of an upstream SCIM provider",
        "value": {
          "name": "Acme (Okta)",
          "provider": "okta",
          "domain": "acme.example",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "scim_base_url": "https://acme.okta.com/scim/v2",
          "scim_token": "env:ULEX_TEST_OKTA_SCIM_TOKEN",
          "scim_poll_interval_seconds": 900,
          "user_filter": "active eq true",
          "deprovision_upstream_removals": true
        }
      },
      "directory": {
        "summary": "Directory",
        "value": {
          "id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "object": "directory",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "name": "Acme (Okta)",
          "provider": "okta",
          "state": "active",
          "domain": "acme.example",
          "scim_base_url": "https://acme.okta.com/scim/v2",
          "inbound_scim_enabled": true,
          "scim_poll_interval_seconds": 900,
          "has_scim_token": true,
          "has_inbound_scim_token": true,
          "has_client_secret": false,
          "last_synced_at": "2026-09-29T14:50:00.000Z",
          "last_sync_status": "ok",
          "last_sync_error": null,
          "created_at": "2026-09-29T14:42:09.000Z",
          "updated_at": "2026-09-29T14:50:00.000Z",
          "deleted_at": null
        }
      },
      "directoryUpdate": {
        "summary": "Rotate the inbound token",
        "value": {
          "inbound_scim_enabled": true,
          "scim_poll_interval_seconds": 900
        }
      },
      "deletedDirectory": {
        "summary": "Soft deleted",
        "value": {
          "id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "object": "directory",
          "deleted": true
        }
      },
      "directorySync": {
        "summary": "Queued; poll it",
        "value": {
          "id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
          "object": "directory_sync",
          "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
          "state": "running",
          "trigger": "manual",
          "stats": {
            "users_created": 0,
            "users_updated": 0,
            "users_deactivated": 0,
            "users_failed": 0,
            "groups_synced": 0
          },
          "error": null,
          "started_at": "2026-09-29T14:50:00.000Z",
          "finished_at": null
        }
      },
      "directorySyncList": {
        "summary": "One completed run",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
              "object": "directory_sync",
              "directory_id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "state": "succeeded",
              "trigger": "manual",
              "stats": {
                "users_created": 12,
                "users_updated": 3,
                "users_deactivated": 1,
                "users_failed": 0,
                "groups_synced": 4
              },
              "error": null,
              "started_at": "2026-09-29T14:50:00.000Z",
              "finished_at": "2026-09-29T14:50:04.000Z"
            }
          ],
          "first_id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
          "last_id": "job_01M3PSVQ68YGZREJKDVZSMQ64T",
          "has_more": false,
          "next_cursor": null
        }
      },
      "scimConfiguration": {
        "summary": "Paste this into Okta",
        "value": {
          "base_url": "https://ulexid.com/api/v1/scim/v2",
          "bearer_token": "scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ",
          "inbound_scim_enabled": true,
          "poll_interval_seconds": 900,
          "user_filter": "userName eq \"pat@acme.example\"",
          "group_filter": null,
          "deprovision_upstream_removals": true,
          "schemas_supported": [
            "urn:ietf:params:scim:schemas:core:2.0:User",
            "urn:ietf:params:scim:schemas:core:2.0:Group"
          ],
          "bulk_supported": true,
          "max_operations_per_bulk": 100
        }
      },
      "scimServiceProviderConfig": {
        "summary": "ServiceProviderConfig",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:ServiceProviderConfig"
          ],
          "documentationUri": "https://docs.ulexid.com/scim/schema-reference",
          "patch": {
            "supported": true
          },
          "bulk": {
            "supported": true,
            "maxOperations": 100,
            "maxPayloadSize": 10485760
          },
          "filter": {
            "supported": true,
            "maxResults": 200,
            "comparisonOperators": [
              "eq",
              "ne",
              "co",
              "sw",
              "ew",
              "gt",
              "lt",
              "ge",
              "le",
              "pr"
            ],
            "caseExact": false,
            "complexAttributes": false
          },
          "changePassword": {
            "supported": false
          },
          "sort": {
            "supported": true
          },
          "etag": {
            "supported": true
          },
          "authenticationSchemes": [
            {
              "type": "oauthbearertoken",
              "name": "OAuth Bearer Token",
              "description": "Authentication with a directory-scoped bearer token",
              "specUri": "http://www.rfc-editor.org/info/rfc6750",
              "primary": true
            }
          ],
          "meta": {
            "resourceType": "ServiceProviderConfig",
            "location": "https://ulexid.com/api/v1/scim/v2/ServiceProviderConfig"
          }
        }
      },
      "scimSchemas": {
        "summary": "Supported schemas",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:ListResponse"
          ],
          "totalResults": 7,
          "itemsPerPage": 7,
          "startIndex": 1,
          "Resources": [
            {
              "id": "urn:ietf:params:scim:schemas:core:2.0:User",
              "name": "User"
            },
            {
              "id": "urn:ietf:params:scim:schemas:core:2.0:Group",
              "name": "Group"
            },
            {
              "id": "urn:ietf:params:scim:api:messages:2.0:PatchOp",
              "name": "PatchOp"
            },
            {
              "id": "urn:ietf:params:scim:api:messages:2.0:BulkRequest",
              "name": "BulkRequest"
            },
            {
              "id": "urn:ietf:params:scim:api:messages:2.0:BulkResponse",
              "name": "BulkResponse"
            },
            {
              "id": "urn:ietf:params:scim:api:messages:2.0:ListResponse",
              "name": "ListResponse"
            },
            {
              "id": "urn:ietf:params:scim:api:messages:2.0:Error",
              "name": "Error"
            }
          ]
        }
      },
      "scimResourceTypes": {
        "summary": "User and Group only",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:ListResponse"
          ],
          "totalResults": 2,
          "itemsPerPage": 2,
          "startIndex": 1,
          "Resources": [
            {
              "id": "User",
              "endpoint": "/Users",
              "schema": "urn:ietf:params:scim:schemas:core:2.0:User",
              "meta": {
                "location": "/Users",
                "resourceType": "ResourceType"
              }
            },
            {
              "id": "Group",
              "endpoint": "/Groups",
              "schema": "urn:ietf:params:scim:schemas:core:2.0:Group",
              "meta": {
                "location": "/Groups",
                "resourceType": "ResourceType"
              }
            }
          ]
        }
      },
      "scimListUsers": {
        "summary": "Two matching users",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:ListResponse"
          ],
          "totalResults": 2,
          "itemsPerPage": 2,
          "startIndex": 1,
          "Resources": [
            {
              "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User"
              ],
              "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "userName": "pat@acme.example",
              "displayName": "Pat Iyer",
              "active": true
            },
            {
              "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:User"
              ],
              "id": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
              "userName": "sam@acme.example",
              "displayName": "Sam Rivera",
              "active": true
            }
          ]
        }
      },
      "scimListGroups": {
        "summary": "One group",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:ListResponse"
          ],
          "totalResults": 1,
          "itemsPerPage": 1,
          "startIndex": 1,
          "Resources": [
            {
              "schemas": [
                "urn:ietf:params:scim:schemas:core:2.0:Group"
              ],
              "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
              "externalId": "okta-g-9k2mB7yLt4N",
              "displayName": "Support",
              "members": [
                {
                  "value": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
                  "display": "Pat Iyer",
                  "$ref": "https://ulexid.com/api/v1/scim/v2/Users/usr_01M3PSWBPGS08FWV4NV7P9VNFN"
                },
                {
                  "value": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
                  "display": "Sam Rivera"
                }
              ],
              "meta": {
                "resourceType": "Group",
                "created": "2026-09-29T14:49:02.000Z",
                "lastModified": "2026-09-29T14:49:02.000Z",
                "version": "W/\"v1.0\""
              }
            }
          ]
        }
      },
      "scimUserCreate": {
        "summary": "What Okta POSTs",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:User"
          ],
          "userName": "pat@acme.example",
          "name": {
            "givenName": "Pat",
            "familyName": "Iyer",
            "formatted": "Pat Iyer"
          },
          "displayName": "Pat Iyer",
          "emails": [
            {
              "value": "pat@acme.example",
              "type": "work",
              "primary": true
            }
          ],
          "active": true,
          "title": "Support Engineer",
          "department": "Customer Success",
          "preferredLanguage": "en-US",
          "locale": "en-US",
          "externalId": "okta-00u9xK2mB7yLt4N",
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
            "employeeNumber": "E-4417",
            "costCenter": "CS-100",
            "organization": "Customer Success",
            "manager": {
              "value": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
            }
          }
        }
      },
      "scimUser": {
        "summary": "Created",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:User"
          ],
          "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
          "externalId": "okta-00u9xK2mB7yLt4N",
          "userName": "pat@acme.example",
          "name": {
            "givenName": "Pat",
            "familyName": "Iyer",
            "formatted": "Pat Iyer"
          },
          "displayName": "Pat Iyer",
          "emails": [
            {
              "value": "pat@acme.example",
              "type": "work",
              "primary": true
            }
          ],
          "active": true,
          "title": "Support Engineer",
          "department": "Customer Success",
          "preferredLanguage": "en-US",
          "locale": "en-US",
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
            "employeeNumber": "E-4417",
            "costCenter": "CS-100",
            "organization": "Customer Success",
            "manager": {
              "value": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
            }
          },
          "meta": {
            "resourceType": "User",
            "created": "2026-09-29T14:47:03.000Z",
            "lastModified": "2026-09-29T14:47:03.000Z",
            "version": "W/\"v1.0\"",
            "location": "https://ulexid.com/api/v1/scim/v2/Users/usr_01M3PSWBPGS08FWV4NV7P9VNFN"
          }
        }
      },
      "scimUserReplace": {
        "summary": "Full replace",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:User"
          ],
          "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
          "userName": "pat@acme.example",
          "name": {
            "givenName": "Pat",
            "familyName": "Iyer"
          },
          "active": true
        }
      },
      "scimUserPatch": {
        "summary": "PatchOp with an optimistic lock",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:PatchOp"
          ],
          "Operations": [
            {
              "op": "replace",
              "path": "name.givenName",
              "value": "Patricia"
            },
            {
              "op": "replace",
              "path": "department",
              "value": "Customer Experience"
            },
            {
              "op": "add",
              "path": "roles",
              "value": [
                {
                  "value": "admin"
                }
              ]
            }
          ]
        }
      },
      "scimUserPatched": {
        "summary": "Patched",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:User"
          ],
          "id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
          "externalId": "okta-00u9xK2mB7yLt4N",
          "userName": "pat@acme.example",
          "name": {
            "givenName": "Patricia",
            "familyName": "Iyer",
            "formatted": "Pat Iyer"
          },
          "displayName": "Pat Iyer",
          "emails": [
            {
              "value": "pat@acme.example",
              "type": "work",
              "primary": true
            }
          ],
          "active": true,
          "title": "Support Engineer",
          "department": "Customer Experience",
          "preferredLanguage": "en-US",
          "locale": "en-US",
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
            "employeeNumber": "E-4417",
            "costCenter": "CS-100",
            "organization": "Customer Success",
            "manager": {
              "value": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
            }
          },
          "meta": {
            "resourceType": "User",
            "created": "2026-09-29T14:47:03.000Z",
            "lastModified": "2026-09-29T14:49:41.000Z",
            "version": "W/\"v1.1\"",
            "location": "https://ulexid.com/api/v1/scim/v2/Users/usr_01M3PSWBPGS08FWV4NV7P9VNFN"
          }
        }
      },
      "scimGroupCreate": {
        "summary": "Create a group with members",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:Group"
          ],
          "displayName": "Support",
          "externalId": "okta-g-9k2mB7yLt4N",
          "members": [
            {
              "value": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "display": "Pat Iyer",
              "$ref": "https://ulexid.com/api/v1/scim/v2/Users/usr_01M3PSWBPGS08FWV4NV7P9VNFN"
            },
            {
              "value": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
              "display": "Sam Rivera"
            }
          ]
        }
      },
      "scimGroup": {
        "summary": "Group",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:Group"
          ],
          "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "externalId": "okta-g-9k2mB7yLt4N",
          "displayName": "Support",
          "members": [
            {
              "value": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
              "display": "Pat Iyer",
              "$ref": "https://ulexid.com/api/v1/scim/v2/Users/usr_01M3PSWBPGS08FWV4NV7P9VNFN"
            },
            {
              "value": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
              "display": "Sam Rivera"
            }
          ],
          "meta": {
            "resourceType": "Group",
            "created": "2026-09-29T14:49:02.000Z",
            "lastModified": "2026-09-29T14:49:02.000Z",
            "version": "W/\"v1.0\""
          }
        }
      },
      "scimGroupReplace": {
        "summary": "Full replace of the group and its members",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:schemas:core:2.0:Group"
          ],
          "id": "grp_01M3PSVED0M9RJTYH5AC72C253",
          "displayName": "Support",
          "members": [
            {
              "value": "usr_01M3PSWBPGS08FWV4NV7P9VNFN"
            },
            {
              "value": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ"
            }
          ]
        }
      },
      "scimGroupPatch": {
        "summary": "Add and remove members",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:PatchOp"
          ],
          "Operations": [
            {
              "op": "add",
              "path": "members",
              "value": [
                {
                  "value": "usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
                  "display": "Sam Rivera"
                }
              ]
            },
            {
              "op": "remove",
              "path": "members[value eq \"usr_01M3PSVBPGS08FWV4NV7P9VNFN\"]"
            }
          ]
        }
      },
      "scimBulk": {
        "summary": "Create two users and a group referencing them",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:BulkRequest"
          ],
          "failOnErrors": 1,
          "Operations": [
            {
              "method": "POST",
              "path": "/Users",
              "bulkId": "alex",
              "data": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:User"
                ],
                "userName": "alex@acme.example",
                "name": {
                  "givenName": "Alex",
                  "familyName": "Chen"
                },
                "emails": [
                  {
                    "value": "alex@acme.example",
                    "primary": true
                  }
                ],
                "active": true
              }
            },
            {
              "method": "POST",
              "path": "/Users",
              "bulkId": "robin",
              "data": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:User"
                ],
                "userName": "robin@acme.example",
                "name": {
                  "givenName": "Robin",
                  "familyName": "Vega"
                },
                "emails": [
                  {
                    "value": "robin@acme.example",
                    "primary": true
                  }
                ],
                "active": true
              }
            },
            {
              "method": "POST",
              "path": "/Groups",
              "bulkId": "g1",
              "data": {
                "schemas": [
                  "urn:ietf:params:scim:schemas:core:2.0:Group"
                ],
                "displayName": "Support",
                "members": [
                  {
                    "value": "alex"
                  },
                  {
                    "value": "robin"
                  }
                ]
              }
            }
          ]
        }
      },
      "scimBulkResponse": {
        "summary": "All three succeeded",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:BulkResponse"
          ],
          "Operations": [
            {
              "method": "POST",
              "bulkId": "alex",
              "version": "W/\"v1.0\"",
              "location": "/Users/usr_01M3PSWCNRG3H18C3A2AHBRYRZ",
              "status": "201"
            },
            {
              "method": "POST",
              "bulkId": "robin",
              "version": "W/\"v1.0\"",
              "location": "/Users/usr_01M3PSW0YRNEQQAP9T1JP9FC2Y",
              "status": "201"
            },
            {
              "method": "POST",
              "bulkId": "g1",
              "version": "W/\"v1.0\"",
              "location": "/Groups/grp_01M3PSVED0M9RJTYH5AC72C253",
              "status": "201"
            }
          ]
        }
      },
      "scimErrorUniqueness": {
        "summary": "409 uniqueness",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "409",
          "scimType": "uniqueness",
          "detail": "A User with userName pat@acme.example already exists.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "scimErrorNotFound": {
        "summary": "404",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "404",
          "detail": "User usr_01M3PSWBPGS08FWV4NV7P9VNFN not found.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "scimErrorMutability": {
        "summary": "409 mutability",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "409",
          "scimType": "mutability",
          "detail": "The attribute 'id' is immutable.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "scimErrorStaleEtag": {
        "summary": "412 stale ETag",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "412",
          "scimType": "mutability",
          "detail": "The resource has changed since version W/\"v1.0\". Re-read and re-apply.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "scimErrorInvalidPath": {
        "summary": "400 invalidPath",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "400",
          "scimType": "invalidPath",
          "detail": "Attribute path 'nickname' does not exist.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "scimErrorBulkExceeded": {
        "summary": "413 bulk too large",
        "value": {
          "schemas": [
            "urn:ietf:params:scim:api:messages:2.0:Error"
          ],
          "status": "413",
          "detail": "A Bulk request may contain at most 100 operations; received 250.",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8"
        }
      },
      "openidConfiguration": {
        "summary": "Discovery",
        "value": {
          "issuer": "https://ulexid.com",
          "authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
          "token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
          "userinfo_endpoint": "https://ulexid.com/api/v1/oauth2/userinfo",
          "jwks_uri": "https://ulexid.com/api/v1/oauth2/keys",
          "introspection_endpoint": "https://ulexid.com/api/v1/oauth2/introspect",
          "revocation_endpoint": "https://ulexid.com/api/v1/oauth2/revoke",
          "device_authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize/device",
          "end_session_endpoint": "https://ulexid.com/auth/session/end",
          "response_types_supported": [
            "code",
            "id_token",
            "code id_token"
          ],
          "response_modes_supported": [
            "query",
            "fragment",
            "form_post"
          ],
          "grant_types_supported": [
            "authorization_code",
            "refresh_token",
            "client_credentials",
            "urn:ietf:params:oauth:grant-type:device_code",
            "urn:ietf:params:oauth:grant-type:token-exchange"
          ],
          "subject_types_supported": [
            "public",
            "pairwise"
          ],
          "id_token_signing_alg_values_supported": [
            "RS256",
            "RS384",
            "RS512",
            "ES256",
            "ES384",
            "PS256",
            "EdDSA"
          ],
          "userinfo_signing_alg_values_supported": [
            "none",
            "RS256"
          ],
          "token_endpoint_auth_methods_supported": [
            "client_secret_basic",
            "client_secret_post",
            "private_key_jwt",
            "tls_client_auth",
            "self_signed_tls_client_auth",
            "none"
          ],
          "dpop_signing_alg_values_supported": [
            "ES256",
            "ES384",
            "RS256",
            "PS256",
            "EdDSA"
          ],
          "tls_client_certificate_bound_access_tokens": true,
          "token_endpoint_auth_signing_alg_values_supported": [
            "RS256",
            "PS256",
            "ES256"
          ],
          "scopes_supported": [
            "openid",
            "profile",
            "email",
            "offline_access",
            "ulex:admin",
            "read:organizations",
            "write:organizations",
            "read:users",
            "write:users",
            "read:groups",
            "write:groups",
            "read:connections",
            "write:connections",
            "read:directories",
            "write:directories",
            "read:applications",
            "write:applications",
            "read:audit_logs",
            "read:webhooks",
            "write:webhooks",
            "read:deployments",
            "write:deployments",
            "mcp:tools",
            "mcp:admin",
            "scim:provision",
            "saml:consume",
            "sso:impersonate"
          ],
          "claims_supported": [
            "iss",
            "sub",
            "aud",
            "exp",
            "iat",
            "nbf",
            "jti",
            "azp",
            "name",
            "given_name",
            "family_name",
            "preferred_username",
            "email",
            "email_verified",
            "locale",
            "picture",
            "updated_at",
            "org_id",
            "org_slug",
            "connection_id",
            "sid",
            "amr",
            "acr",
            "https://ulexid.com/claims"
          ],
          "code_challenge_methods_supported": [
            "S256",
            "plain"
          ],
          "dpop_signing_alg_values_supported": [
            "ES256",
            "RS256"
          ],
          "backchannel_logout_supported": true,
          "backchannel_logout_session_supported": true,
          "claims_parameter_supported": true,
          "request_parameter_supported": true,
          "require_pushed_authorization_requests": false
        }
      },
      "oauthProtectedResource": {
        "summary": "RFC 9728",
        "value": {
          "resource": "https://ulexid.com/api/v1",
          "authorization_servers": [
            "https://ulexid.com"
          ],
          "scopes_supported": [
            "mcp:tools",
            "mcp:admin",
            "read:organizations",
            "write:organizations",
            "read:users",
            "write:users",
            "read:groups",
            "write:groups",
            "read:connections",
            "write:connections",
            "read:directories",
            "write:directories",
            "read:applications",
            "write:applications",
            "read:webhooks",
            "write:webhooks",
            "read:audit_logs",
            "read:deployments",
            "write:deployments"
          ],
          "bearer_methods_supported": [
            "header"
          ],
          "resource_documentation": "https://docs.ulexid.com/agents/mcp-tools"
        }
      },
      "tokenAuthorizationCode": {
        "summary": "Authorization code exchange",
        "value": {
          "grant_type": "authorization_code",
          "code": "ac_8Kq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "redirect_uri": "https://app.example.com/auth/callback",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk"
        }
      },
      "tokenRefresh": {
        "summary": "Refresh; the token rotates",
        "value": {
          "grant_type": "refresh_token",
          "refresh_token": "rt_51KpXq8WvN0kTzRb7YcLd2mXe9Pf6Sg3AuV8",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8"
        }
      },
      "tokenClientCredentials": {
        "summary": "Machine token, no user",
        "value": {
          "grant_type": "client_credentials",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "scope": "read:users read:organizations"
        }
      },
      "tokenResponse": {
        "summary": "Tokens",
        "value": {
          "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleV8wMU0zUFNWSkEwWVAyV0RQTTJSRFIxNU1HSCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3VsZXhpZC5jb20iLCJzdWIiOiJ1c3JfMDFNM1BTVjlHUlQ4R1FHRUc2ODZBUjFXOVMiLCJhdWQiOlsiY2xpZW50XzAxTTNQU1Y3SjhUQlNQSEc5NUNZU0VYMzJCIl0sImF6cCI6ImNsaWVudF8wMU0zUFNWN0o4VEJTUEhHOTVDWVNFWDMyQiIsImV4cCI6MTc5MDY5NjcxMiwiaWF0IjoxNzkwNjkzMTEyLCJuYmYiOjE3OTA2OTMxMTIsImp0aSI6Imp0aV8wMU0zUFNXQjJLSjhYUTRSRDdUNVY2VzhZMFoiLCJjbGllbnRfaWQiOiJjbGllbnRfMDFNM1BTVjdKOFRCU1BIRzk1Q1lTRVgzMkIiLCJvcmdfaWQiOiJvcmdfMDFNM1BTVjhIR1RLUUZDQVlGOUdEV0dOM0MiLCJvcmdfc2x1ZyI6ImFjbWUiLCJjb25uZWN0aW9uX2lkIjoiY29uXzAxTTNQU1ZBRzBRRkpHOTlSME01RFhTUjVBIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBvZmZsaW5lX2FjY2VzcyIsInNpZCI6InNlc18wMU0zUFNWRkM4TUFCMzhRWUFBOFExSzlNRyIsImFtciI6WyJwd2QiLCJvdHAiLCJtZmEiXSwiYWNyIjoidXJuOnVsZXg6YWNyOm1mYSIsImh0dHBzOi8vdWxleGlkLmNvbS9jbGFpbXMiOnsib3JnX3JvbGUiOiJvd25lciIsImdyb3VwcyI6WyJlbmdpbmVlcmluZyJdfX0.8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2",
          "token_type": "Bearer",
          "expires_in": 3600,
          "refresh_token": "rt_51KpXq8WvN0kTzRb7YcLd2mXe9Pf6Sg3AuV8",
          "refresh_token_expires_in": 2592000,
          "id_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleV8wMU0zUFNWSkEwWVAyV0RQTTJSRFIxNU1HSCIsInR5cCI6IkpXVCJ9.eyJhdXRoX3RpbWUiOjE3OTA2OTMxMTIsInNpZCI6InNlc18wMU0zUFNWRkM4TUFCMzhRWUFBOFExSzlNRyJ9.sig",
          "scope": "openid profile email offline_access"
        }
      },
      "tokenExchange": {
        "summary": "Re-issue for a downstream audience",
        "value": {
          "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange",
          "subject_token_type": "urn:ietf:params:oauth:token-type:access_token",
          "subject_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleV8wMU0zUFNWSkEwWVAyV0RQTTJSRFIxNU1HSCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3VsZXhpZC5jb20iLCJzdWIiOiJ1c3JfMDFNM1BTVjlHUlQ4R1FHRUc2ODZBUjFXOVMiLCJhdWQiOlsiY2xpZW50XzAxTTNQU1Y3SjhUQlNQSEc5NUNZU0VYMzJCIl0sImF6cCI6ImNsaWVudF8wMU0zUFNWN0o4VEJTUEhHOTVDWVNFWDMyQiIsImV4cCI6MTc5MDY5NjcxMiwiaWF0IjoxNzkwNjkzMTEyLCJuYmYiOjE3OTA2OTMxMTIsImp0aSI6Imp0aV8wMU0zUFNXQjJLSjhYUTRSRDdUNVY2VzhZMFoiLCJjbGllbnRfaWQiOiJjbGllbnRfMDFNM1BTVjdKOFRCU1BIRzk1Q1lTRVgzMkIiLCJvcmdfaWQiOiJvcmdfMDFNM1BTVjhIR1RLUUZDQVlGOUdEV0dOM0MiLCJvcmdfc2x1ZyI6ImFjbWUiLCJjb25uZWN0aW9uX2lkIjoiY29uXzAxTTNQU1ZBRzBRRkpHOTlSME01RFhTUjVBIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBvZmZsaW5lX2FjY2VzcyIsInNpZCI6InNlc18wMU0zUFNWRkM4TUFCMzhRWUFBOFExSzlNRyIsImFtciI6WyJwd2QiLCJvdHAiLCJtZmEiXSwiYWNyIjoidXJuOnVsZXg6YWNyOm1mYSIsImh0dHBzOi8vdWxleGlkLmNvbS9jbGFpbXMiOnsib3JnX3JvbGUiOiJvd25lciIsImdyb3VwcyI6WyJlbmdpbmVlcmluZyJdfX0.8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2",
          "audience": "client_01M3PSVV38V3BJQ4SDHQPT8WMJ",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8"
        }
      },
      "introspectToken": {
        "summary": "Introspect an access token",
        "value": {
          "token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleV8wMU0zUFNWSkEwWVAyV0RQTTJSRFIxNU1HSCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3VsZXhpZC5jb20iLCJzdWIiOiJ1c3JfMDFNM1BTVjlHUlQ4R1FHRUc2ODZBUjFXOVMiLCJhdWQiOlsiY2xpZW50XzAxTTNQU1Y3SjhUQlNQSEc5NUNZU0VYMzJCIl0sImF6cCI6ImNsaWVudF8wMU0zUFNWN0o4VEJTUEhHOTVDWVNFWDMyQiIsImV4cCI6MTc5MDY5NjcxMiwiaWF0IjoxNzkwNjkzMTEyLCJuYmYiOjE3OTA2OTMxMTIsImp0aSI6Imp0aV8wMU0zUFNXQjJLSjhYUTRSRDdUNVY2VzhZMFoiLCJjbGllbnRfaWQiOiJjbGllbnRfMDFNM1BTVjdKOFRCU1BIRzk1Q1lTRVgzMkIiLCJvcmdfaWQiOiJvcmdfMDFNM1BTVjhIR1RLUUZDQVlGOUdEV0dOM0MiLCJvcmdfc2x1ZyI6ImFjbWUiLCJjb25uZWN0aW9uX2lkIjoiY29uXzAxTTNQU1ZBRzBRRkpHOTlSME01RFhTUjVBIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBvZmZsaW5lX2FjY2VzcyIsInNpZCI6InNlc18wMU0zUFNWRkM4TUFCMzhRWUFBOFExSzlNRyIsImFtciI6WyJwd2QiLCJvdHAiLCJtZmEiXSwiYWNyIjoidXJuOnVsZXg6YWNyOm1mYSIsImh0dHBzOi8vdWxleGlkLmNvbS9jbGFpbXMiOnsib3JnX3JvbGUiOiJvd25lciIsImdyb3VwcyI6WyJlbmdpbmVlcmluZyJdfX0.8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2",
          "token_type_hint": "access_token"
        }
      },
      "introspectionResponse": {
        "summary": "Active",
        "value": {
          "active": true,
          "token_type": "access_token",
          "scope": "openid profile email offline_access",
          "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "sub": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "org_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "sid": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
          "exp": 1790696712,
          "iat": 1790693112,
          "auth_time": 1790693112,
          "amr": [
            "pwd",
            "otp",
            "mfa"
          ],
          "acr": "urn:ulex:acr:mfa"
        }
      },
      "revokeToken": {
        "summary": "Revoke a refresh token; the family dies with it",
        "value": {
          "token": "rt_51KpXq8WvN0kTzRb7YcLd2mXe9Pf6Sg3AuV8",
          "token_type_hint": "refresh_token"
        }
      },
      "revokeResponse": {
        "summary": "Revoked",
        "value": {
          "revoked": true,
          "token_type": "refresh_token",
          "family_revoked": true,
          "sessions_revoked": 0
        }
      },
      "userinfo": {
        "summary": "Claims",
        "value": {
          "sub": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "iss": "https://ulexid.com",
          "aud": "client_01M3PSV7J8TBSPHG95CYSEX32B",
          "name": "Dana Okafor",
          "given_name": "Dana",
          "family_name": "Okafor",
          "preferred_username": "dana@acme.example",
          "email": "dana@acme.example",
          "email_verified": true,
          "job_title": "Support Lead",
          "department": "Customer Success",
          "locale": "en-US",
          "updated_at": 1790693112,
          "org_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "org_slug": "acme",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "sid": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
          "amr": [
            "pwd",
            "otp",
            "mfa"
          ],
          "acr": "urn:ulex:acr:mfa",
          "https://ulexid.com/claims": {
            "org_role": "owner",
            "groups": [
              "engineering"
            ]
          }
        }
      },
      "jwks": {
        "summary": "Two keys during a rotation",
        "value": {
          "keys": [
            {
              "kty": "RSA",
              "use": "sig",
              "alg": "RS256",
              "kid": "key_01M3PSVJA0YP2WDPM2RDR15MGH",
              "n": "0vx7agoKGcRMgpjY4XqbJ7Xm3vJ7XQ…",
              "e": "AQAB",
              "x5t": "MfKw2WL8iJ7YQ3n1bPqR0sA=="
            },
            {
              "kty": "RSA",
              "use": "sig",
              "alg": "RS256",
              "kid": "key_01M3PSX7B2KQ4V6W8Y0Z1A3B5C",
              "n": "1vy3f0cRMgpjY4XqbJ7Xm3vJ7XQ…",
              "e": "AQAB",
              "x5t": "8dQw2WL8iJ7YQ3n1bPqR1sA=="
            }
          ]
        }
      },
      "deviceCode": {
        "summary": "Device authorization",
        "value": {
          "device_code": "dc_7Kq2WmB4yLt4NxZ1pRc6HdE0sJg3AuV8",
          "user_code": "WXYZ-1234",
          "verification_uri": "https://ulexid.com/device",
          "verification_uri_complete": "https://ulexid.com/device?user_code=WXYZ-1234",
          "expires_in": 900,
          "interval": 5
        }
      },
      "hostedCallback": {
        "summary": "Hosted sign-in form post",
        "value": {
          "email": "dana@acme.example",
          "organization": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "redirect_uri": "https://app.example.com/auth/callback",
          "state": "st_9Kq2WmB7yLt4NxZ"
        }
      },
      "oauthErrorInvalidGrant": {
        "summary": "400 invalid_grant",
        "value": {
          "error": "invalid_grant",
          "error_description": "The authorization code has already been used.",
          "error_uri": "https://docs.ulexid.com/api-reference/errors#invalid_grant",
          "type": "authentication_error",
          "code": "invalid_grant",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
          "retryable": false,
          "hint": "Authorization codes are single use. Start a new login."
        }
      },
      "oauthErrorInvalidClient": {
        "summary": "401 invalid_client",
        "value": {
          "error": "invalid_client",
          "error_description": "Client authentication failed.",
          "type": "authentication_error",
          "code": "invalid_client",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
          "retryable": false
        }
      },
      "oauthErrorUnauthorizedClient": {
        "summary": "403 unauthorized_client",
        "value": {
          "error": "unauthorized_client",
          "error_description": "The target application does not allow token exchange.",
          "type": "permission_error",
          "code": "unauthorized_client",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
          "retryable": false,
          "hint": "Add urn:ietf:params:oauth:grant-type:token-exchange to the application's grant_types."
        }
      },
      "oauthErrorRateLimited": {
        "summary": "429 token rate limit",
        "value": {
          "error": "rate_limit_error",
          "error_description": "Token endpoint rate limit reached: 30 requests per minute.",
          "type": "rate_limit_error",
          "code": "rate_limit_error",
          "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
          "retryable": true,
          "hint": "Retry after 12s."
        }
      },
      "webhookList": {
        "summary": "One endpoint",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
              "object": "webhook",
              "url": "https://hooks.example.com/ulex",
              "status": "enabled",
              "events": [
                "dsync.user.created",
                "dsync.user.deleted",
                "dsync.user.updated",
                "user.suspended"
              ],
              "secret_prefix": "whsec_3Kq9",
              "description": "Identity events for the Acme Support pipeline",
              "failure_count": 0,
              "disabled_at": null,
              "disabled_reason": null,
              "last_delivery_at": "2026-09-29T14:42:18.000Z",
              "last_delivery_status": 200,
              "api_version": "2025-01-01",
              "created_at": "2026-09-29T14:42:17.000Z",
              "updated_at": "2026-09-29T14:42:17.000Z"
            }
          ],
          "first_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "last_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "has_more": false,
          "next_cursor": null
        }
      },
      "webhookCreate": {
        "summary": "Subscribe to identity events",
        "value": {
          "url": "https://hooks.example.com/ulex",
          "events": [
            "dsync.user.created",
            "dsync.user.updated",
            "dsync.user.deleted",
            "user.suspended",
            "session.created"
          ],
          "description": "Identity events for the Acme Support pipeline",
          "api_version": "2025-01-01"
        }
      },
      "webhook": {
        "summary": "Endpoint",
        "value": {
          "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "object": "webhook",
          "url": "https://hooks.example.com/ulex",
          "status": "enabled",
          "events": [
            "dsync.user.created",
            "dsync.user.deleted",
            "dsync.user.updated",
            "user.suspended"
          ],
          "secret_prefix": "whsec_3Kq9",
          "description": "Identity events for the Acme Support pipeline",
          "failure_count": 0,
          "disabled_at": null,
          "disabled_reason": null,
          "last_delivery_at": "2026-09-29T14:42:18.000Z",
          "last_delivery_status": 200,
          "api_version": "2025-01-01",
          "created_at": "2026-09-29T14:42:17.000Z",
          "updated_at": "2026-09-29T14:42:17.000Z"
        }
      },
      "webhookWithSecret": {
        "summary": "Created; the secret is shown once",
        "value": {
          "webhook": {
            "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
            "object": "webhook",
            "url": "https://hooks.example.com/ulex",
            "status": "enabled",
            "events": [
              "dsync.user.created",
              "dsync.user.deleted",
              "dsync.user.updated",
              "user.suspended"
            ],
            "secret_prefix": "whsec_3Kq9",
            "description": "Identity events for the Acme Support pipeline",
            "failure_count": 0,
            "disabled_at": null,
            "disabled_reason": null,
            "last_delivery_at": "2026-09-29T14:42:18.000Z",
            "last_delivery_status": 200,
            "api_version": "2025-01-01",
            "created_at": "2026-09-29T14:42:17.000Z",
            "updated_at": "2026-09-29T14:42:17.000Z"
          },
          "secret": "whsec_3Kq9Xa2mB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "signature_algorithm": "HMAC-SHA256",
          "signature_header": "Ulex-Signature",
          "signature_example": "t=1790693112,v1=8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2"
        }
      },
      "webhookUpdate": {
        "summary": "Trim the event set",
        "value": {
          "events": [
            "dsync.user.created",
            "dsync.user.deleted"
          ],
          "description": "Trimmed 2026-09"
        }
      },
      "deletedWebhook": {
        "summary": "Deleted",
        "value": {
          "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "object": "webhook",
          "deleted": true
        }
      },
      "webhookEnabled": {
        "summary": "Enabled, failure_count reset",
        "value": {
          "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "object": "webhook",
          "url": "https://hooks.example.com/ulex",
          "status": "enabled",
          "events": [
            "dsync.user.created",
            "dsync.user.deleted",
            "dsync.user.updated",
            "user.suspended"
          ],
          "secret_prefix": "whsec_3Kq9",
          "description": "Identity events for the Acme Support pipeline",
          "failure_count": 0,
          "disabled_at": null,
          "disabled_reason": null,
          "last_delivery_at": "2026-09-29T14:42:18.000Z",
          "last_delivery_status": 200,
          "api_version": "2025-01-01",
          "created_at": "2026-09-29T14:42:17.000Z",
          "updated_at": "2026-09-29T14:42:17.000Z"
        }
      },
      "webhookDisabled": {
        "summary": "Disabled",
        "value": {
          "id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "object": "webhook",
          "url": "https://hooks.example.com/ulex",
          "status": "disabled",
          "events": [
            "dsync.user.created",
            "dsync.user.deleted",
            "dsync.user.updated",
            "user.suspended"
          ],
          "secret_prefix": "whsec_3Kq9",
          "description": "Identity events for the Acme Support pipeline",
          "failure_count": 0,
          "disabled_at": "2026-09-29T16:30:00.000Z",
          "disabled_reason": "manually disabled",
          "last_delivery_at": "2026-09-29T14:42:18.000Z",
          "last_delivery_status": 200,
          "api_version": "2025-01-01",
          "created_at": "2026-09-29T14:42:17.000Z",
          "updated_at": "2026-09-29T14:42:17.000Z"
        }
      },
      "webhookTest": {
        "summary": "Send a user.created test event",
        "value": {
          "event": "user.created"
        }
      },
      "webhookDelivery": {
        "summary": "Delivered",
        "value": {
          "id": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA",
          "object": "webhook_delivery",
          "webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
          "event": "dsync.user.created",
          "event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
          "status": "delivered",
          "attempt": 1,
          "max_attempts": 8,
          "response_status": 200,
          "response_body": "{\"received\":true}",
          "error": null,
          "duration_ms": 84,
          "next_attempt_at": null,
          "delivered_at": "2026-09-29T14:42:18.000Z",
          "created_at": "2026-09-29T14:42:18.000Z"
        }
      },
      "webhookDeliveryList": {
        "summary": "One delivered, one dead-lettered",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA",
              "object": "webhook_delivery",
              "webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
              "event": "dsync.user.created",
              "event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
              "status": "delivered",
              "attempt": 1,
              "max_attempts": 8,
              "response_status": 200,
              "response_body": "{\"received\":true}",
              "error": null,
              "duration_ms": 84,
              "next_attempt_at": null,
              "delivered_at": "2026-09-29T14:42:18.000Z",
              "created_at": "2026-09-29T14:42:18.000Z"
            },
            {
              "id": "dlv_01M3PSW2X8E8H2CCW1AX67T8C1",
              "object": "webhook_delivery",
              "webhook_id": "whk_01M3PSVK981SXWGKG9JXHC1P0Y",
              "event": "dsync.user.created",
              "event_id": "evt_01M3PSW3WGDDFJFJHZ4QJNNFZD",
              "status": "dead_lettered",
              "attempt": 8,
              "max_attempts": 8,
              "response_status": null,
              "response_body": "{\"received\":true}",
              "error": "connect ECONNREFUSED 10.0.0.7:8080",
              "duration_ms": 84,
              "next_attempt_at": null,
              "delivered_at": null,
              "created_at": "2026-09-29T14:42:18.000Z"
            }
          ],
          "first_id": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA",
          "last_id": "dlv_01M3PSW2X8E8H2CCW1AX67T8C1",
          "has_more": false,
          "next_cursor": null
        }
      },
      "auditEventList": {
        "summary": "One event plus the chain head",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
              "object": "audit_event",
              "environment": "prod",
              "action": "authentication.succeeded",
              "category": "authentication",
              "actor_id": null,
              "actor_hash": "sha256:3b1f0c9a7d2e4f6a8b0c2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a",
              "actor_type": "user",
              "actor_display": "Dana Okafor",
              "target": {
                "type": "application",
                "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
                "display_name": "Acme Support"
              },
              "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
              "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
              "correlation_id": "onboard-acme-2026-09-29",
              "session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
              "ip_hash": "sha256:9c2e4a6b8d0f2a4c6e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c2e4b6d8f0a2c",
              "user_agent": "ulex-mcp/2025.9.1",
              "metadata": {
                "amr": [
                  "pwd",
                  "otp",
                  "mfa"
                ],
                "acr": "urn:ulex:acr:mfa"
              },
              "outcome": "success",
              "error_code": null,
              "timestamp": 1790693112,
              "created_at": "2026-09-29T14:45:12.000Z",
              "previous_hash": "sha256:9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8",
              "entry_hash": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
              "hash_version": 2
            }
          ],
          "first_id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
          "last_id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
          "has_more": false,
          "next_cursor": null
        }
      },
      "auditEvent": {
        "summary": "One event with its chain link",
        "value": {
          "audit_event": {
            "id": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9",
            "object": "audit_event",
            "environment": "prod",
            "action": "authentication.succeeded",
            "category": "authentication",
            "actor_id": null,
            "actor_hash": "sha256:3b1f0c9a7d2e4f6a8b0c2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a",
            "actor_type": "user",
            "actor_display": "Dana Okafor",
            "target": {
              "type": "application",
              "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "display_name": "Acme Support"
            },
            "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
            "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "correlation_id": "onboard-acme-2026-09-29",
            "session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
            "ip_hash": "sha256:9c2e4a6b8d0f2a4c6e8b0d2f4a6c8e0b2d4f6a8c0e2b4d6f8a0c2e4b6d8f0a2c",
            "user_agent": "ulex-mcp/2025.9.1",
            "metadata": {
              "amr": [
                "pwd",
                "otp",
                "mfa"
              ],
              "acr": "urn:ulex:acr:mfa"
            },
            "outcome": "success",
            "error_code": null,
            "timestamp": 1790693112,
            "created_at": "2026-09-29T14:45:12.000Z",
            "previous_hash": "sha256:9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8",
            "entry_hash": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
            "hash_version": 2
          },
          "chain": {
            "sequence": 41,
            "previous_hash": "sha256:9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8",
            "entry_hash": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b"
          }
        }
      },
      "auditExportNdjson": {
        "summary": "Two events, one per line",
        "value": "{\"id\":\"aud_01M3PSVN7R3H0ECRPQVTDF1PY9\",\"action\":\"authentication.succeeded\",\"category\":\"authentication\",\"actor_id\":null,\"actor_hash\":\"sha256:3b1f0c9a…\",\"actor_type\":\"user\",\"target\":{\"type\":\"application\",\"id\":\"app_01M3PSV7J8TBSPHG95CYSEX32B\",\"display_name\":\"Acme Support\"},\"organization_id\":\"org_01M3PSV8HGTKQFCAYF9GDWGN3C\",\"request_id\":\"req_01M3PSW9R0175NAW62NYR403R8\",\"outcome\":\"success\",\"timestamp\":1790693112,\"chain\":{\"sequence\":41,\"previous_hash\":\"sha256:9f3c1a7b…\",\"entry_hash\":\"sha256:7d9f1b3a…\"}}\n{\"id\":\"aud_01M3PSW3WGDDFJFJHZ4QJNNFZD\",\"action\":\"user.created\",\"category\":\"provisioning\",\"actor_id\":null,\"actor_hash\":\"sha256:3b1f0c9a…\",\"actor_type\":\"agent\",\"target\":{\"type\":\"user\",\"id\":\"usr_01M3PSWBPGS08FWV4NV7P9VNFN\",\"display_name\":\"Pat Iyer\"},\"organization_id\":\"org_01M3PSV8HGTKQFCAYF9GDWGN3C\",\"request_id\":\"req_01M3PSW9R0175NAW62NYR403R8\",\"outcome\":\"success\",\"timestamp\":1790693121,\"chain\":{\"sequence\":42,\"previous_hash\":\"sha256:7d9f1b3a…\",\"entry_hash\":\"sha256:b2e4d6f8a…\"}}"
      },
      "deploymentList": {
        "summary": "Two deployments",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
              "object": "deployment",
              "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "environment": "prod",
              "state": "succeeded",
              "domain": "acme-support.ulexid.com",
              "strategy": "simulated",
              "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
              "progress_percent": 100,
              "created_at": "2026-09-29T14:48:20.000Z"
            },
            {
              "id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
              "object": "deployment",
              "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "environment": "prod",
              "state": "rolled_back",
              "domain": "acme-support.ulexid.com",
              "strategy": "simulated",
              "commit_sha": "3f8b2c1d9e7a5b3f1d9c7a5e3b1f9d7c5a3e1b9f7d5c3a1e9b7d5f3c1a9e7b5d3",
              "progress_percent": 100,
              "rolled_back_from": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
              "created_at": "2026-09-28T18:02:11.000Z"
            }
          ],
          "first_id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "last_id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
          "has_more": false,
          "next_cursor": null
        }
      },
      "deploymentCreate": {
        "summary": "Deploy main to prod",
        "value": {
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
          "branch": "main",
          "commit_message": "Add SAML SP wiring",
          "strategy": "simulated",
          "confirm": true
        }
      },
      "deploymentCreateProd": {
        "summary": "Deploy to prod; confirm is mandatory",
        "value": {
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
          "branch": "main",
          "commit_message": "Add SAML SP wiring",
          "strategy": "simulated",
          "confirm": true
        }
      },
      "deploymentProdUnconfirmed": {
        "summary": "400 without confirm",
        "value": {
          "error": {
            "type": "invalid_request_error",
            "code": "validation_failed",
            "message": "A prod deployment requires confirm: true.",
            "param": "confirm",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "hint": "Re-send with \"confirm\": true. This interlock exists so a mistargeted call cannot promote an application into production."
          }
        }
      },
      "deployment": {
        "summary": "Queued",
        "value": {
          "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "object": "deployment",
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "state": "queued",
          "domain": "acme-support.ulexid.com",
          "strategy": "simulated",
          "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
          "branch": "main",
          "commit_message": "Add SAML SP wiring",
          "resources": [],
          "issued": {},
          "steps": [],
          "error": null,
          "progress_percent": 0,
          "created_at": "2026-09-29T14:48:20.000Z",
          "started_at": null,
          "finished_at": null,
          "duration_ms": null
        }
      },
      "deploymentSucceeded": {
        "summary": "Succeeded with issued credentials",
        "value": {
          "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "object": "deployment",
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "state": "succeeded",
          "domain": "acme-support.ulexid.com",
          "strategy": "simulated",
          "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
          "branch": "main",
          "commit_message": "Add SAML SP wiring",
          "resources": [
            {
              "type": "application",
              "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "url": "https://acme-support.ulexid.com"
            },
            {
              "type": "oidc_client",
              "id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
              "url": null
            },
            {
              "type": "saml_sp",
              "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata"
            },
            {
              "type": "scim_endpoint",
              "id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "url": "https://ulexid.com/api/v1/scim/v2"
            }
          ],
          "issued": {
            "client_id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
            "client_secret": "cs_9fKq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
            "api_key": "ulex_sk_live_7Qm2KpLx9Tb4Ns8RfWy3Zc1Hjf6Ee0Au",
            "saml_entity_id": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B",
            "saml_acs_url": "https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/sso",
            "saml_idp_metadata_url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata",
            "oidc_issuer": "https://ulexid.com",
            "scim_base_url": "https://ulexid.com/api/v1/scim/v2",
            "scim_bearer_token": "scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ",
            "authorization_endpoint": "https://ulexid.com/api/v1/oauth2/authorize",
            "token_endpoint": "https://ulexid.com/api/v1/oauth2/token",
            "admin_email": "dana@acme.example",
            "admin_password": null
          },
          "steps": [
            {
              "name": "provision-application",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:20.412Z",
              "finished_at": "2026-09-29T14:48:20.918Z",
              "duration_ms": 506,
              "message": "Registered OIDC client app_01M3PSV7J8TBSPHG95CYSEX32B",
              "logs": [
                "client_id=client_01M3PSV7J8TBSPHG95CYSEX32B",
                "require_pkce=true",
                "redirect_uris=1"
              ]
            },
            {
              "name": "configure-saml-sp",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:20.918Z",
              "finished_at": "2026-09-29T14:48:21.104Z",
              "duration_ms": 186,
              "message": "SP metadata published",
              "logs": [
                "entity_id=https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B"
              ]
            },
            {
              "name": "configure-scim",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.104Z",
              "finished_at": "2026-09-29T14:48:21.330Z",
              "duration_ms": 226,
              "message": "SCIM endpoint published for dir_01M3PSVBF8038RK2MW2N263Q2B",
              "logs": [
                "base_url=https://ulexid.com/api/v1/scim/v2",
                "inbound_scim_enabled=true"
              ]
            },
            {
              "name": "build",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.330Z",
              "finished_at": "2026-09-29T14:48:21.402Z",
              "duration_ms": 72,
              "message": "Bundle built from 9f3c1a7",
              "logs": [
                "artifact=acme-support:9f3c1a7",
                "size=412KiB"
              ]
            },
            {
              "name": "deploy",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.402Z",
              "finished_at": "2026-09-29T14:48:21.688Z",
              "duration_ms": 286,
              "message": "Released to acme-support.ulexid.com",
              "logs": [
                "revision=14",
                "previous_revision=13"
              ]
            },
            {
              "name": "verify",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.688Z",
              "finished_at": "2026-09-29T14:48:21.920Z",
              "duration_ms": 232,
              "message": "Health check passed",
              "logs": [
                "GET / 200 in 41ms",
                "GET /.well-known/openid-configuration 200 in 12ms",
                "token_endpoint reachable"
              ]
            }
          ],
          "error": null,
          "progress_percent": 100,
          "rolled_back_from": null,
          "created_at": "2026-09-29T14:48:20.000Z",
          "started_at": "2026-09-29T14:48:20.412Z",
          "finished_at": "2026-09-29T14:48:21.920Z",
          "duration_ms": 1508
        }
      },
      "deploymentCancelled": {
        "summary": "Cancelled",
        "value": {
          "id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "object": "deployment",
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "state": "cancelled",
          "progress_percent": 60,
          "created_at": "2026-09-29T14:48:20.000Z",
          "finished_at": "2026-09-29T14:48:21.500Z"
        }
      },
      "deploymentRollback": {
        "summary": "Roll back to a specific deployment",
        "value": {
          "to_deployment_id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD"
        }
      },
      "deploymentRolledBack": {
        "summary": "A new deployment in rolled_back; issued is empty",
        "value": {
          "id": "dep_01M3PSW4VRJVGQ82XD4EZ3T6SD",
          "object": "deployment",
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "environment": "prod",
          "state": "rolled_back",
          "domain": "acme-support.ulexid.com",
          "strategy": "simulated",
          "commit_sha": "9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b",
          "branch": "main",
          "commit_message": "Add SAML SP wiring",
          "resources": [
            {
              "type": "application",
              "id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
              "url": "https://acme-support.ulexid.com"
            },
            {
              "type": "oidc_client",
              "id": "client_01M3PSV7J8TBSPHG95CYSEX32B",
              "url": null
            },
            {
              "type": "saml_sp",
              "id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
              "url": "https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B/metadata"
            },
            {
              "type": "scim_endpoint",
              "id": "dir_01M3PSVBF8038RK2MW2N263Q2B",
              "url": "https://ulexid.com/api/v1/scim/v2"
            }
          ],
          "issued": {},
          "steps": [
            {
              "name": "provision-application",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:20.412Z",
              "finished_at": "2026-09-29T14:48:20.918Z",
              "duration_ms": 506,
              "message": "Registered OIDC client app_01M3PSV7J8TBSPHG95CYSEX32B",
              "logs": [
                "client_id=client_01M3PSV7J8TBSPHG95CYSEX32B",
                "require_pkce=true",
                "redirect_uris=1"
              ]
            },
            {
              "name": "configure-saml-sp",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:20.918Z",
              "finished_at": "2026-09-29T14:48:21.104Z",
              "duration_ms": 186,
              "message": "SP metadata published",
              "logs": [
                "entity_id=https://ulexid.com/api/v1/applications/app_01M3PSV7J8TBSPHG95CYSEX32B"
              ]
            },
            {
              "name": "configure-scim",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.104Z",
              "finished_at": "2026-09-29T14:48:21.330Z",
              "duration_ms": 226,
              "message": "SCIM endpoint published for dir_01M3PSVBF8038RK2MW2N263Q2B",
              "logs": [
                "base_url=https://ulexid.com/api/v1/scim/v2",
                "inbound_scim_enabled=true"
              ]
            },
            {
              "name": "build",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.330Z",
              "finished_at": "2026-09-29T14:48:21.402Z",
              "duration_ms": 72,
              "message": "Bundle built from 9f3c1a7",
              "logs": [
                "artifact=acme-support:9f3c1a7",
                "size=412KiB"
              ]
            },
            {
              "name": "deploy",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.402Z",
              "finished_at": "2026-09-29T14:48:21.688Z",
              "duration_ms": 286,
              "message": "Released to acme-support.ulexid.com",
              "logs": [
                "revision=14",
                "previous_revision=13"
              ]
            },
            {
              "name": "verify",
              "state": "succeeded",
              "started_at": "2026-09-29T14:48:21.688Z",
              "finished_at": "2026-09-29T14:48:21.920Z",
              "duration_ms": 232,
              "message": "Health check passed",
              "logs": [
                "GET / 200 in 41ms",
                "GET /.well-known/openid-configuration 200 in 12ms",
                "token_endpoint reachable"
              ]
            }
          ],
          "error": null,
          "progress_percent": 100,
          "rolled_back_from": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "created_at": "2026-09-29T14:48:20.000Z",
          "started_at": "2026-09-29T14:48:20.412Z",
          "finished_at": "2026-09-29T14:52:04.000Z",
          "duration_ms": 1508
        }
      },
      "deploymentLogs": {
        "summary": "Verify step logs",
        "value": {
          "object": "deployment_logs",
          "deployment_id": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF",
          "steps": [
            {
              "name": "verify",
              "state": "succeeded",
              "duration_ms": 232,
              "message": "Health check passed"
            }
          ],
          "lines": [
            {
              "ts": "2026-09-29T14:48:21.688Z",
              "level": "info",
              "step": "verify",
              "message": "GET / 200 in 41ms"
            },
            {
              "ts": "2026-09-29T14:48:21.701Z",
              "level": "info",
              "step": "verify",
              "message": "GET /.well-known/openid-configuration 200 in 12ms"
            },
            {
              "ts": "2026-09-29T14:48:21.720Z",
              "level": "info",
              "step": "verify",
              "message": "token_endpoint reachable"
            },
            {
              "ts": "2026-09-29T14:48:21.920Z",
              "level": "info",
              "step": "verify",
              "message": "deployment succeeded"
            }
          ]
        }
      },
      "environmentList": {
        "summary": "Active environment",
        "value": {
          "object": "list",
          "data": [
            {
              "id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
              "object": "environment",
              "slug": "production",
              "name": "Production",
              "domain": "ulexid.com",
              "region": "us-east-1",
              "created_at": "2026-09-01T09:00:00.000Z",
              "updated_at": "2026-09-01T09:00:00.000Z"
            }
          ],
          "first_id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
          "last_id": "env_01M3PSWAQ8KTKST4M41YP8HAVK",
          "has_more": false,
          "next_cursor": null
        }
      },
      "environmentHealth": {
        "summary": "Healthy",
        "value": {
          "environment": "prod",
          "status": "healthy",
          "version": "2025.9.1",
          "region": "us-east-1",
          "uptime_seconds": 841233,
          "checks": [
            {
              "name": "api",
              "status": "pass",
              "latency_ms": 11
            },
            {
              "name": "dynamodb",
              "status": "pass",
              "latency_ms": 3
            },
            {
              "name": "kms",
              "status": "pass",
              "latency_ms": 7
            },
            {
              "name": "queue",
              "status": "pass",
              "latency_ms": 2
            },
            {
              "name": "directory_sync",
              "status": "pass",
              "latency_ms": 41
            }
          ]
        }
      },
      "simulateAuthenticate": {
        "summary": "OIDC login",
        "value": {
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "email": "dana@acme.example",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "response_type": "code"
        }
      },
      "simulateAuthenticatePkce": {
        "summary": "Return a generated PKCE verifier",
        "value": {
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "email": "dana@acme.example",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "return_pkce": true
        }
      },
      "simulateResult": {
        "summary": "Session, grant and single-use code",
        "value": {
          "session_id": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG",
          "grant_id": "grt_01M3PSVGBGJT1ZXC840F2B3NXJ",
          "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "connection_id": "con_01M3PSVAG0QFJG99R0M5DXSR5A",
          "outcome": "success",
          "stage": "complete",
          "authorization_url": "https://ulexid.com/api/v1/oauth2/authorize?response_type=code&client_id=client_01M3PSV7J8TBSPHG95CYSEX32B&redirect_uri=https%3A%2F%2Fapp.example.com%2Fauth%2Fcallback&scope=openid%20profile%20email%20offline_access&state=st_9Kq2WmB7yLt4NxZ&nonce=nc_3Fq8Lp2XvN9bTm&code_challenge=E9MelhoQ2YvW96fl8sW7aTtZbGd0mY6Xl0e8Q1sCk&code_challenge_method=S256",
          "code": "ac_8Kq2WmB7yLt4NxZ1pRc6HdE0sJg3AuV8",
          "code_expires_at": "2026-09-29T14:46:12.000Z",
          "code_verifier": "dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk",
          "amr": [
            "pwd"
          ],
          "acr": null,
          "duration_ms": 214
        }
      },
      "mintToken": {
        "summary": "Fixture token, no login",
        "value": {
          "user_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
          "application_id": "app_01M3PSV7J8TBSPHG95CYSEX32B",
          "organization_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
          "scopes": [
            "openid",
            "profile",
            "email"
          ],
          "ttl_seconds": 900,
          "amr": [
            "urn:ulex:amr:simulated"
          ]
        }
      },
      "mintedToken": {
        "summary": "Simulated token",
        "value": {
          "access_token": "eyJhbGciOiJSUzI1NiIsImtpZCI6ImtleV8wMU0zUFNWSkEwWVAyV0RQTTJSRFIxNU1HSCIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL3VsZXhpZC5jb20iLCJzdWIiOiJ1c3JfMDFNM1BTVjlHUlQ4R1FHRUc2ODZBUjFXOVMiLCJhdWQiOlsiY2xpZW50XzAxTTNQU1Y3SjhUQlNQSEc5NUNZU0VYMzJCIl0sImF6cCI6ImNsaWVudF8wMU0zUFNWN0o4VEJTUEhHOTVDWVNFWDMyQiIsImV4cCI6MTc5MDY5NjcxMiwiaWF0IjoxNzkwNjkzMTEyLCJuYmYiOjE3OTA2OTMxMTIsImp0aSI6Imp0aV8wMU0zUFNXQjJLSjhYUTRSRDdUNVY2VzhZMFoiLCJjbGllbnRfaWQiOiJjbGllbnRfMDFNM1BTVjdKOFRCU1BIRzk1Q1lTRVgzMkIiLCJvcmdfaWQiOiJvcmdfMDFNM1BTVjhIR1RLUUZDQVlGOUdEV0dOM0MiLCJvcmdfc2x1ZyI6ImFjbWUiLCJjb25uZWN0aW9uX2lkIjoiY29uXzAxTTNQU1ZBRzBRRkpHOTlSME01RFhTUjVBIiwic2NvcGUiOiJvcGVuaWQgcHJvZmlsZSBlbWFpbCBvZmZsaW5lX2FjY2VzcyIsInNpZCI6InNlc18wMU0zUFNWRkM4TUFCMzhRWUFBOFExSzlNRyIsImFtciI6WyJwd2QiLCJvdHAiLCJtZmEiXSwiYWNyIjoidXJuOnVsZXg6YWNyOm1mYSIsImh0dHBzOi8vdWxleGlkLmNvbS9jbGFpbXMiOnsib3JnX3JvbGUiOiJvd25lciIsImdyb3VwcyI6WyJlbmdpbmVlcmluZyJdfX0.8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mNqU4wE7iO2pL5xC8vB1nMg0jKhR3tFyD7wZq2",
          "token_type": "Bearer",
          "expires_in": 900,
          "expires_at": "2026-09-29T14:56:12.000Z",
          "claims": {
            "iss": "https://ulexid.com",
            "sub": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
            "aud": [
              "client_01M3PSV7J8TBSPHG95CYSEX32B"
            ],
            "org_id": "org_01M3PSV8HGTKQFCAYF9GDWGN3C",
            "amr": [
              "urn:ulex:amr:simulated"
            ],
            "acr": "urn:ulex:acr:simulated"
          },
          "warning": "Simulated token. Not a real authentication event; no session or grant was created."
        }
      },
      "simulatorReset": {
        "summary": "Clear armed failures and challenges",
        "value": {
          "scope": "simulation"
        }
      },
      "verifyChain": {
        "summary": "Verify a 12-month window",
        "value": {
          "from": "2026-01-01T00:00:00.000Z",
          "to": "2026-06-30T23:59:59.000Z"
        }
      },
      "verifyChainResult": {
        "summary": "Chain intact",
        "value": {
          "valid": true,
          "checked": 8471,
          "failure": null,
          "windowStartsMidChain": false,
          "head": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
          "summary": "Chain intact: 8471 event(s) verified from 2026-01-01T00:00:00.000Z to 2026-06-30T23:59:59.000Z. Every entry hashes to the value it had when written, and each links to its predecessor.",
          "window": {
            "from": "2026-01-01T00:00:00.000Z",
            "to": "2026-06-30T23:59:59.000Z"
          }
        }
      },
      "verifyChainBroken": {
        "summary": "Altered entry — the one kind that is a security event",
        "value": {
          "valid": false,
          "checked": 4102,
          "failure": {
            "kind": "hash_mismatch",
            "at": "aud_01M3PSW3WGDDFJFJHZ4QJNNFZD",
            "detail": "The entry's contents do not hash to the hash recorded on it. The row was altered after it was written.",
            "found_previous": "sha256:9f3c1a7b2d4e6f8a0b2c4d6e8f0a2b4c6d8e0f2a4b6c8d0e2f4a6b8c0d2e4f6a8",
            "expected_previous": "sha256:3b7d9f1a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1a5c"
          },
          "windowStartsMidChain": false,
          "head": "sha256:…",
          "guidance": {
            "severity": "security",
            "what": "An entry's contents no longer hash to the hash it was stored with. Somebody changed the row after it was written.",
            "do": "Preserve the log before anything else, then contact ulex support and your incident lead.",
            "not": "This is evidence the log itself was altered. Every other failure kind is not — do not treat them as equivalent."
          },
          "summary": "Chain verification FAILED (hash_mismatch) at event aud_01M3PSW3WGDDFJFJHZ4QJNNFZD, after verifying 4102 event(s) from 2026-01-01T00:00:00.000Z to 2026-06-30T23:59:59.000Z. …",
          "window": {
            "from": "2026-01-01T00:00:00.000Z",
            "to": "2026-06-30T23:59:59.000Z"
          }
        }
      },
      "verifyChainTruncated": {
        "summary": "Window began part-way through the chain — valid, but not a whole-chain result",
        "value": {
          "valid": true,
          "checked": 1204,
          "failure": null,
          "windowStartsMidChain": true,
          "head": "sha256:7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b3a5c7e9f1b3d5f7a9c1e3f5b7d9f1b",
          "summary": "Chain intact across 1204 event(s) from 2026-06-30T00:00:00.000Z to 2026-06-30T23:59:59.000Z. This window began part-way through the chain, so the first entry's link to its predecessor was not checked. Widen the window to cover the whole log for a complete result.",
          "window": {
            "from": "2026-06-30T00:00:00.000Z",
            "to": "2026-06-30T23:59:59.000Z"
          }
        }
      },
      "samlLogoutResponse": {
        "summary": "Signed LogoutResponse",
        "value": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<samlp:LogoutResponse xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\" ID=\"_LR_8JmQ1vZ0Xh4n7cW2sT5yP9rB3kD6fG1aH0mN\" Version=\"2.0\" IssueInstant=\"2026-09-29T15:01:04Z\" Destination=\"https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7/slo/saml\" InResponseTo=\"_LRq_4Kq9WmB2yLt7NxZ1pRc6HdE0sJg3AuV8\">\n  <saml:Issuer xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\">https://globex.okta.com/app/exk9r2mz1hRtXQ2N5s0d7</saml:Issuer>\n  <samlp:Status><samlp:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\"/></samlp:Status>\n</samlp:LogoutResponse>"
      },
      "hostedSignInHtml": {
        "summary": "The hosted sign-in screen",
        "value": "<!doctype html>\n<html lang=\"en\">\n<head><title>Sign in to Acme Support</title>\n<link rel=\"icon\" href=\"https://cdn.example.com/acme.png\">\n<style>:root{--primary:#4f46e5;--bg:#ffffff}</style></head>\n<body style=\"background:var(--bg);font-family:system-ui\">\n<main>\n  <img src=\"https://cdn.example.com/acme.png\" alt=\"Acme Corp\" width=\"120\">\n  <h1>Sign in to Acme Support</h1>\n  <form method=\"post\" action=\"https://ulexid.com/api/v1/auth/app_01M3PSV7J8TBSPHG95CYSEX32B/callback\">\n    <input type=\"hidden\" name=\"redirect_uri\" value=\"https://app.example.com/auth/callback\">\n    <input type=\"hidden\" name=\"state\" value=\"st_9Kq2WmB7yLt4NxZ\">\n    <label for=\"email\">Work email</label>\n    <input id=\"email\" name=\"email\" type=\"email\" value=\"dana@acme.example\" required>\n    <button type=\"submit\" style=\"background:var(--primary)\">Continue with Acme SSO</button>\n  </form>\n</main>\n</body>\n</html>"
      },
      "hostedSignInErrorHtml": {
        "summary": "Rendered error page, because the redirect_uri did not validate",
        "value": "<!doctype html>\n<html lang=\"en\"><head><title>Sign-in error</title></head>\n<body>\n  <h1>Sign-in error</h1>\n  <p><code>invalid_redirect_uri</code></p>\n  <p>The redirect_uri https://app.example.com/cb is not registered for client_01M3PSV7J8TBSPHG95CYSEX32B.</p>\n  <p>Request id: req_01M3PSW9R0175NAW62NYR403R8</p>\n  <p><a href=\"https://docs.ulexid.com/api-reference/errors\">Documentation</a></p>\n</body></html>"
      },
      "deviceVerificationHtml": {
        "summary": "Device code entry",
        "value": "<!doctype html>\n<html lang=\"en\"><head><title>Enter your code</title></head>\n<body>\n  <h1>Enter your code</h1>\n  <form method=\"post\" action=\"/api/v1/oauth2/device/verify\">\n    <input name=\"user_code\" value=\"WXYZ-1234\" autocomplete=\"off\" required>\n    <button type=\"submit\">Continue</button>\n  </form>\n</body></html>"
      },
      "endSessionHtml": {
        "summary": "Signed out",
        "value": "<!doctype html>\n<html lang=\"en\"><head><title>Signed out</title></head>\n<body><h1>You have been signed out</h1></body></html>"
      },
      "auditExportCsv": {
        "summary": "Flattened CSV",
        "value": "id,action,category,actor_type,organization_id,outcome,error_code,timestamp,request_id\naud_01M3PSVN7R3H0ECRPQVTDF1PY9,authentication.succeeded,authentication,user,org_01M3PSV8HGTKQFCAYF9GDWGN3C,success,,1790693112,req_01M3PSW9R0175NAW62NYR403R8\naud_01M3PSW3WGDDFJFJHZ4QJNNFZD,user.created,provisioning,agent,org_01M3PSV8HGTKQFCAYF9GDWGN3C,success,,1790693121,req_01M3PSW9R0175NAW62NYR403R8\n"
      },
      "mcpSseStream": {
        "summary": "Server-sent event frame",
        "value": "event: message\ndata: {\"jsonrpc\":\"2.0\",\"method\":\"notifications/tools/list_changed\",\"params\":{}}\n\n"
      },
      "mcpUnauthorized": {
        "summary": "401 with a WWW-Authenticate pointer",
        "value": {
          "error": {
            "type": "authentication_error",
            "code": "mcp_unauthorized",
            "message": "An access token with the mcp:tools scope is required to call ulex MCP tools.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false,
            "docs_url": "https://docs.ulexid.com/troubleshooting/mcp-issues"
          }
        }
      },
      "mcpSessionNotFound": {
        "summary": "404 unknown session",
        "value": {
          "error": {
            "type": "not_found_error",
            "code": "not_found",
            "message": "No MCP session 4f7a1c9e-8b2d-4a3f-9c61-5e0d7b1a2f84. It was terminated, or the 24-hour window expired.",
            "request_id": "req_01M3PSW9R0175NAW62NYR403R8",
            "retryable": false
          }
        }
      },
      "mcpInitialize": {
        "summary": "initialize",
        "value": {
          "jsonrpc": "2.0",
          "id": 1,
          "method": "initialize",
          "params": {
            "protocolVersion": "2025-06-18",
            "capabilities": {
              "tools": {
                "listChanged": true
              }
            },
            "clientInfo": {
              "name": "bootstrap-agent",
              "version": "1.4.0"
            }
          }
        }
      },
      "mcpToolsCall": {
        "summary": "tools/call",
        "value": {
          "jsonrpc": "2.0",
          "id": 2,
          "method": "tools/call",
          "params": {
            "name": "ulex_bootstrap_app",
            "arguments": {
              "application_name": "Acme Support",
              "organization_name": "Acme Corp",
              "organization_domain": "acme.example",
              "admin_email": "dana@acme.example",
              "connection_strategy": "mock_sso"
            }
          }
        }
      },
      "mcpInitializeResponse": {
        "summary": "SSE frame with the session id in a header",
        "value": "event: message\ndata: {\"jsonrpc\":\"2.0\",\"id\":1,\"result\":{\"protocolVersion\":\"2025-06-18\",\"capabilities\":{\"tools\":{\"listChanged\":true},\"logging\":{}},\"serverInfo\":{\"name\":\"ulex\",\"version\":\"2025.9.1\"},\"instructions\":\"ulex derives environment from the credential. Start with ulex_list_tools. ulex_bootstrap_app provisions an identity backend in one call.\"}}\n"
      },
      "mcpToolsCallResponse": {
        "summary": "SSE frame; read structuredContent",
        "value": "event: message\ndata: {\"jsonrpc\":\"2.0\",\"id\":2,\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"{\\\"application\\\":{\\\"id\\\":\\\"app_01M3PSV7J8TBSPHG95CYSEX32B\\\"},\\\"organization\\\":{\\\"id\\\":\\\"org_01M3PSV8HGTKQFCAYF9GDWGN3C\\\"}}\"}],\"structuredContent\":{\"application\":{\"id\":\"app_01M3PSV7J8TBSPHG95CYSEX32B\"},\"organization\":{\"id\":\"org_01M3PSV8HGTKQFCAYF9GDWGN3C\"}},\"isError\":false}}\n"
      },
      "mcpToolErrorResponse": {
        "summary": "isError true carries the ulex envelope",
        "value": "event: message\ndata: {\"jsonrpc\":\"2.0\",\"id\":3,\"result\":{\"content\":[{\"type\":\"text\",\"text\":\"{\\\"error\\\":{\\\"type\\\":\\\"invalid_request_error\\\",\\\"code\\\":\\\"mcp_tool_not_found\\\",\\\"message\\\":\\\"Unknown MCP tool.\\\"}}\"}],\"isError\":true}}"
      },
      "mcpParseError": {
        "summary": "JSON-RPC protocol error",
        "value": {
          "jsonrpc": "2.0",
          "id": 7,
          "error": {
            "code": -32601,
            "message": "Method not found",
            "data": {
              "method": "tools/calll"
            }
          }
        }
      },
      "connectionVerificationFailed": {
        "summary": "An unreachable or misconfigured IdP — still 200",
        "value": {
          "connection_id": "con_01M3PSVY108K5TEHHQ82WN30YK",
          "valid": false,
          "checks": [
            {
              "check": "client_id present",
              "status": "passed",
              "detail": "0oa1b2c3d4e5f6g7h8i9"
            },
            {
              "check": "issuer present",
              "status": "passed",
              "detail": "https://acme.okta.com/oauth2/default"
            },
            {
              "check": "discovery document",
              "status": "failed",
              "detail": "The document claims issuer https://evil.example.com, which does not match the issuer configured."
            }
          ]
        }
      }
    },
    "schemas": {
      "Id": {
        "type": "string",
        "description": "Prefixed ULID, e.g. org_01J…",
        "pattern": "^[a-z]{3}_[0-9A-HJKMNP-TV-Z]{26}$"
      },
      "Timestamp": {
        "type": "string",
        "format": "date-time"
      },
      "RequestId": {
        "type": "string",
        "maxLength": 64,
        "description": "Correlation id echoed from X-Ulex-Request-Id, or generated."
      },
      "IdempotencyKey": {
        "type": "string",
        "maxLength": 64,
        "description": "Deduplicates a write for 24 hours."
      },
      "Url": {
        "type": "string",
        "format": "uri",
        "maxLength": 2048
      },
      "HttpsUrl": {
        "type": "string",
        "format": "uri",
        "maxLength": 2048,
        "description": "https://, or http:// for loopback only."
      },
      "Hostname": {
        "type": "string",
        "maxLength": 253,
        "pattern": "^[^\\s/]+$"
      },
      "Email": {
        "type": "string",
        "format": "email",
        "maxLength": 320
      },
      "Slug": {
        "type": "string",
        "minLength": 2,
        "maxLength": 63,
        "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
      },
      "GroupSlug": {
        "type": "string",
        "minLength": 1,
        "maxLength": 120,
        "pattern": "^[a-zA-Z0-9._:-]+$"
      },
      "Metadata": {
        "type": "object",
        "additionalProperties": {
          "type": [
            "string",
            "number",
            "boolean",
            "null"
          ]
        }
      },
      "ErrorType": {
        "type": "string",
        "enum": [
          "invalid_request_error",
          "authentication_error",
          "permission_error",
          "not_found_error",
          "conflict_error",
          "rate_limit_error",
          "api_error",
          "rate_limited"
        ]
      },
      "ErrorCode": {
        "type": "string",
        "description": "Stable, machine-readable code. See /api-reference/errors."
      },
      "Error": {
        "type": "object",
        "required": [
          "type",
          "code",
          "message",
          "request_id",
          "retryable"
        ],
        "properties": {
          "type": {
            "$ref": "#/components/schemas/ErrorType"
          },
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "message": {
            "type": "string"
          },
          "param": {
            "type": "string",
            "description": "The offending request field."
          },
          "request_id": {
            "$ref": "#/components/schemas/RequestId"
          },
          "retryable": {
            "type": "boolean",
            "description": "Back off and retry the identical request. The only backoff signal."
          },
          "docs_url": {
            "type": "string",
            "format": "uri"
          },
          "hint": {
            "type": "string",
            "description": "Suggested next action. On 429s this is 'Retry after Ns.'."
          },
          "details": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            }
          }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        },
        "description": "The single error envelope used by REST, MCP and the CLI."
      },
      "OAuthError": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "error_description": {
            "type": "string"
          },
          "error_uri": {
            "type": "string",
            "format": "uri"
          },
          "type": {
            "$ref": "#/components/schemas/ErrorType"
          },
          "code": {
            "$ref": "#/components/schemas/ErrorCode"
          },
          "request_id": {
            "$ref": "#/components/schemas/RequestId"
          },
          "retryable": {
            "type": "boolean"
          },
          "hint": {
            "type": "string"
          }
        }
      },
      "User": {
        "type": "object",
        "required": [
          "id",
          "object",
          "email",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
          },
          "object": {
            "type": "string",
            "const": "user"
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320,
            "example": "dana@acme.example"
          },
          "email_verified": {
            "type": "boolean",
            "example": true
          },
          "first_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80,
            "example": "Dana"
          },
          "last_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80,
            "example": "Okafor"
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 160,
            "example": "Dana Okafor"
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255,
            "example": "okta-00u1sAM2xY8ZQ4H1"
          },
          "directory_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "job_title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "example": "Support Lead"
          },
          "department": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "example": "Customer Success"
          },
          "scim": {
            "type": "object",
            "additionalProperties": true,
            "example": {
              "title": "Support Lead",
              "user_type": "Employee",
              "active": true
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "suspended",
              "pending"
            ]
          },
          "last_seen_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "example": "2026-09-29T14:45:12.000Z"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "UserCreate": {
        "type": "object",
        "required": [
          "email"
        ],
        "additionalProperties": false,
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320,
            "example": "dana@acme.example"
          },
          "email_verified": {
            "type": "boolean",
            "default": false
          },
          "first_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "last_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 160
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "job_title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "department": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "suspended",
              "pending"
            ]
          },
          "scim": {
            "type": "object",
            "additionalProperties": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "UserUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320
          },
          "email_verified": {
            "type": "boolean"
          },
          "first_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "last_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "display_name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 160
          },
          "job_title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "department": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120
          },
          "external_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive",
              "suspended",
              "pending"
            ]
          },
          "scim": {
            "type": "object",
            "additionalProperties": true
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "Organization": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "slug"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "object": {
            "type": "string",
            "const": "organization"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "example": "Acme Corp"
          },
          "slug": {
            "type": "string",
            "minLength": 2,
            "maxLength": 63,
            "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",
            "example": "acme"
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "directory_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "sso_only": {
            "type": "boolean",
            "example": true
          },
          "allow_profiles_outside_organization": {
            "type": "boolean"
          },
          "default_connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "OrganizationCreate": {
        "type": "object",
        "required": [
          "name",
          "slug"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "slug": {
            "type": "string",
            "minLength": 2,
            "maxLength": 63,
            "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "sso_only": {
            "type": "boolean"
          },
          "allow_profiles_outside_organization": {
            "type": "boolean"
          },
          "connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "directory_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "OrganizationUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "logo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "sso_only": {
            "type": "boolean"
          },
          "allow_profiles_outside_organization": {
            "type": "boolean"
          },
          "connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "directory_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "number",
                "boolean",
                "null"
              ]
            }
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "Domain": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "state"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "dom_01M3PSVCEGK9H35GZJK25HN08D"
          },
          "object": {
            "type": "string",
            "const": "domain"
          },
          "organization_id": {
            "$ref": "#/components/schemas/Id",
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "name": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$",
            "example": "acme.example"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "verifying",
              "verified",
              "failed"
            ]
          },
          "verification_token": {
            "type": "string",
            "minLength": 16,
            "maxLength": 128
          },
          "verification_strategy": {
            "type": "string",
            "enum": [
              "dns",
              "manual"
            ]
          },
          "dns_records": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "const": "TXT"
                },
                "name": {
                  "type": "string"
                },
                "value": {
                  "type": "string"
                },
                "ttl": {
                  "type": "integer"
                },
                "purpose": {
                  "type": "string"
                }
              }
            }
          },
          "verified_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "DomainCreate": {
        "type": "object",
        "required": [
          "domain"
        ],
        "additionalProperties": false,
        "properties": {
          "domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "verification_strategy": {
            "type": "string",
            "enum": [
              "dns",
              "manual"
            ]
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "Membership": {
        "type": "object",
        "required": [
          "id",
          "object",
          "organization_id",
          "user_id",
          "role"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "mem_01M3PSVDDRC5YN00BRZ8E7CNMT"
          },
          "object": {
            "type": "string",
            "const": "organization_membership"
          },
          "organization_id": {
            "$ref": "#/components/schemas/Id",
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "user_id": {
            "$ref": "#/components/schemas/Id",
            "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "member",
              "guest"
            ]
          },
          "group_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Id"
            },
            "example": [
              "grp_01M3PSVED0M9RJTYH5AC72C253"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "MembershipCreate": {
        "type": "object",
        "required": [
          "user_id"
        ],
        "additionalProperties": false,
        "properties": {
          "user_id": {
            "$ref": "#/components/schemas/Id",
            "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
          },
          "role": {
            "type": "string",
            "enum": [
              "owner",
              "admin",
              "member",
              "guest"
            ]
          },
          "group_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Id"
            }
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "Group": {
        "type": "object",
        "required": [
          "id",
          "object",
          "organization_id",
          "name",
          "slug",
          "source"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "grp_01M3PSVED0M9RJTYH5AC72C253"
          },
          "object": {
            "type": "string",
            "const": "group"
          },
          "organization_id": {
            "$ref": "#/components/schemas/Id",
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "example": "Engineering"
          },
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "pattern": "^[a-zA-Z0-9._:-]+$",
            "example": "engineering"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "scim_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "source": {
            "type": "string",
            "enum": [
              "manual",
              "scim",
              "saml",
              "rule"
            ]
          },
          "member_count": {
            "type": "integer",
            "example": 2
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "GroupCreate": {
        "type": "object",
        "required": [
          "name",
          "slug"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "slug": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "pattern": "^[a-zA-Z0-9._:-]+$"
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "source": {
            "type": "string",
            "enum": [
              "manual",
              "scim",
              "saml",
              "rule"
            ]
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "GroupUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          }
        }
      },
      "GroupMembersReplace": {
        "type": "object",
        "required": [
          "user_ids"
        ],
        "additionalProperties": false,
        "properties": {
          "user_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Id"
            },
            "example": [
              "usr_01M3PSV9GRT8GQGEG686AR1W9S",
              "usr_01M3PSWBPGS08FWV4NV7P9VNFN"
            ]
          }
        }
      },
      "ConnectionStrategy": {
        "type": "string",
        "enum": [
          "mock_sso",
          "password",
          "magic_link",
          "otp_email",
          "oidc",
          "google_oidc",
          "microsoft_oidc",
          "entra_oidc",
          "okta_oidc",
          "github_oidc",
          "apple_oidc",
          "generic_oauth2",
          "saml",
          "scim",
          "directory_sync",
          "jwt_bearer",
          "x509_client_cert",
          "impersonation_only"
        ]
      },
      "OidcConfig": {
        "type": "object",
        "properties": {
          "issuer": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "example": "https://acme.okta.com/oauth2/default"
          },
          "client_id": {
            "type": "string",
            "maxLength": 255
          },
          "client_secret": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
          },
          "discovery_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 64
            },
            "example": [
              "openid",
              "profile",
              "email",
              "groups"
            ]
          },
          "attribute_mapping": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            },
            "example": {
              "email": "email",
              "first_name": "given_name",
              "external_id": "sub",
              "groups": "groups"
            }
          },
          "allowed_domains": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            },
            "maxItems": 500,
            "example": [
              "acme.example"
            ]
          },
          "require_jit_provisioning": {
            "type": "boolean",
            "description": "Legacy field name: true disables JIT account creation for unknown users; existing users can still sign in."
          },
          "jit_default_role": {
            "type": "string",
            "enum": [
              "admin",
              "member",
              "guest"
            ]
          },
          "username_template": {
            "type": "string",
            "maxLength": 255
          }
        }
      },
      "SamlConfig": {
        "type": "object",
        "properties": {
          "entity_id": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "sso_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "sign_in_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "sign_out_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "x509_certificate": {
            "type": "string",
            "minLength": 1,
            "example": "MIIE1DCCA3CgAwIBAgIULSJ+aV2PvJ0d1d1pTqU2KzKzANBgkqhkiG9w0BAQUFADCBpDELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwHhcNMjYwNDI4MDAwMDAwWhcNMjcwNDE4MDAwMDAwWjCBhzELMAkGA1UEBhMCTkIxCzAJBgNVBAYTAlVTMRMwEQYDVQQIDApBbW1hem9jMTQwggEiMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQ…"
          },
          "x509_certificate_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "acs_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "audience_uri": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "idp_initiated_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "binding": {
            "type": "string",
            "enum": [
              "saml_redirect",
              "saml_post"
            ]
          },
          "name_id_format": {
            "type": "string",
            "enum": [
              "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress",
              "urn:oasis:names:tc:SAML:2.0:nameid-format:persistent",
              "urn:oasis:names:tc:SAML:2.0:nameid-format:transient",
              "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
            ]
          },
          "want_response_signed": {
            "type": "boolean"
          },
          "want_assertion_signed": {
            "type": "boolean"
          },
          "want_authn_request_signed": {
            "type": "boolean"
          },
          "signature_algorithm": {
            "type": "string",
            "enum": [
              "rsa-sha256",
              "rsa-sha512",
              "ecdsa-sha256",
              "ecdsa-sha384"
            ]
          },
          "digest_algorithm": {
            "type": "string",
            "enum": [
              "sha256",
              "sha512"
            ]
          },
          "name_id_transformations": {
            "type": "string",
            "enum": [
              "none",
              "lowercase",
              "email",
              "email_verified",
              "saml_subject_hash"
            ]
          },
          "allow_create": {
            "type": "boolean",
            "description": "Create and provision an account from an assertion when no user matches. A refusal is audited."
          },
          "allow_update": {
            "type": "boolean",
            "description": "Apply profile claims and group changes to matched accounts. False leaves stored data unchanged and audits attempted changes."
          },
          "allow_link": {
            "type": "boolean",
            "description": "Link an email-matched account to an upstream external identifier. A refusal is audited."
          },
          "group_attribute": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "groups_attribute": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "group_name_template": {
            "type": "string",
            "maxLength": 255
          },
          "active_attribute": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "active_value": {
            "type": "string",
            "maxLength": 128
          },
          "signature_validation": {
            "type": "string",
            "enum": [
              "strict",
              "lenient"
            ],
            "description": "strict requires a signed Assertion; lenient also accepts an unsigned Assertion inside a Response signed by the pinned certificate."
          },
          "allowed_clock_skew_seconds": {
            "type": "integer",
            "minimum": 0,
            "maximum": 600
          },
          "attribute_mapping": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "acs_allowed_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048
            },
            "maxItems": 20,
            "description": "Exact allowed ACS URLs. Empty allows only this connection’s canonical ACS URL; wildcards are not supported."
          }
        }
      },
      "ScimConfig": {
        "type": "object",
        "properties": {
          "provider": {
            "$ref": "#/components/schemas/DirectoryProvider"
          },
          "base_url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "token": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
          },
          "poll_interval_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400,
            "default": 900
          },
          "user_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "group_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "deprovision_upstream_removals": {
            "type": "boolean"
          },
          "attribute_mapping": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        }
      },
      "MockConfig": {
        "type": "object",
        "properties": {
          "seed_users": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "email"
              ],
              "properties": {
                "email": {
                  "type": "string",
                  "format": "email",
                  "maxLength": 320
                },
                "first_name": {
                  "type": "string",
                  "maxLength": 80
                },
                "last_name": {
                  "type": "string",
                  "maxLength": 80
                },
                "job_title": {
                  "type": "string",
                  "maxLength": 120
                },
                "department": {
                  "type": "string",
                  "maxLength": 120
                },
                "groups": {
                  "type": "array",
                  "items": {
                    "type": "string",
                    "maxLength": 120
                  }
                },
                "password": {
                  "type": "string",
                  "maxLength": 256
                },
                "mfa_enrolled": {
                  "type": "boolean"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "active",
                    "inactive",
                    "suspended",
                    "pending"
                  ]
                },
                "external_id": {
                  "type": "string",
                  "maxLength": 255
                }
              }
            },
            "maxItems": 500
          },
          "force_failure": {
            "type": "boolean",
            "description": "Every simulated login on this connection fails."
          },
          "latency_ms": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000
          }
        }
      },
      "JwtConfig": {
        "type": "object",
        "properties": {
          "issuer": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "audience": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "jwks_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "jwks": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
          },
          "algorithms": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "RS256",
                "RS384",
                "RS512",
                "ES256",
                "ES384",
                "PS256"
              ]
            }
          },
          "claim_mapping": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          }
        }
      },
      "PasswordConfig": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "local",
              "ldap",
              "active_directory",
              "radius"
            ]
          },
          "ldap": {
            "type": "object",
            "properties": {
              "url": {
                "format": "uri"
              },
              "bind_dn": {
                "type": "string",
                "maxLength": 512
              },
              "bind_password": {
                "type": "string",
                "maxLength": 2048,
                "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
              },
              "base_dn": {
                "type": "string",
                "maxLength": 512
              },
              "user_filter": {
                "type": "string",
                "maxLength": 512
              },
              "tls_required": {
                "type": "boolean"
              },
              "start_tls": {
                "type": "boolean"
              }
            }
          },
          "radius": {
            "type": "object",
            "properties": {
              "host": {
                "type": "string",
                "maxLength": 253
              },
              "port": {
                "type": "integer",
                "minimum": 1,
                "maximum": 65535
              },
              "shared_secret": {
                "type": "string",
                "maxLength": 2048,
                "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
              }
            }
          }
        }
      },
      "ConnectionConfig": {
        "description": "Discriminated union on `strategy`. Only the namespace belonging to the chosen strategy is valid; sending any other is 400 unknown_parameter.",
        "oneOf": [
          {
            "type": "object",
            "required": [
              "strategy",
              "oidc"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "enum": [
                  "oidc",
                  "google_oidc",
                  "microsoft_oidc",
                  "entra_oidc",
                  "okta_oidc",
                  "github_oidc",
                  "apple_oidc",
                  "generic_oauth2"
                ]
              },
              "oidc": {
                "$ref": "#/components/schemas/OidcConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy",
              "saml"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "const": "saml"
              },
              "saml": {
                "$ref": "#/components/schemas/SamlConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy",
              "scim"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "enum": [
                  "scim",
                  "directory_sync"
                ]
              },
              "scim": {
                "$ref": "#/components/schemas/ScimConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy",
              "mock"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "const": "mock_sso"
              },
              "mock": {
                "$ref": "#/components/schemas/MockConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy",
              "password"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "const": "password"
              },
              "password": {
                "$ref": "#/components/schemas/PasswordConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy",
              "jwt"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "const": "jwt_bearer"
              },
              "jwt": {
                "$ref": "#/components/schemas/JwtConfig"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "strategy"
            ],
            "additionalProperties": false,
            "properties": {
              "strategy": {
                "type": "string",
                "enum": [
                  "magic_link",
                  "otp_email",
                  "x509_client_cert",
                  "impersonation_only"
                ]
              }
            }
          }
        ],
        "discriminator": {
          "propertyName": "strategy",
          "mapping": {
            "mock_sso": "#/components/schemas/ConnectionConfig/oneOf/3",
            "saml": "#/components/schemas/ConnectionConfig/oneOf/1"
          }
        }
      },
      "Connection": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "state",
          "config"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "object": {
            "type": "string",
            "const": "connection"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/Id",
            "example": "ten_01M3PSV6K0HFZ62YZ6AKB191WW"
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "example": "Acme SSO"
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "inactive",
              "expired",
              "error"
            ]
          },
          "config": {
            "$ref": "#/components/schemas/ConnectionConfig"
          },
          "domains": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            },
            "maxItems": 500,
            "example": [
              "acme.example"
            ]
          },
          "domains_state": {
            "type": "string",
            "enum": [
              "pending",
              "verified",
              "failed",
              "expired"
            ]
          },
          "organization_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Id"
            }
          },
          "directory_ids": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Id"
            }
          },
          "discovery": {
            "type": "object",
            "properties": {
              "authorization_endpoint": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "token_endpoint": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "userinfo_endpoint": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "jwks_uri": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "issuer": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "fetched_at": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date-time"
              },
              "error": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 1000
              }
            }
          },
          "last_auth_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_auth_result": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "success",
              "failure",
              "error"
            ]
          },
          "last_auth_error": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ConnectionCreate": {
        "type": "object",
        "required": [
          "name",
          "config"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "domains": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            },
            "maxItems": 500
          },
          "config": {
            "$ref": "#/components/schemas/ConnectionConfig"
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "ConnectionUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "state": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "inactive"
            ]
          },
          "domains": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 253,
              "pattern": "^[^\\s/]+$"
            },
            "maxItems": 500
          },
          "config": {
            "$ref": "#/components/schemas/ConnectionConfig"
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "VerifyCheck": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "pass",
              "fail",
              "warn",
              "skip"
            ]
          },
          "detail": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          }
        }
      },
      "ConnectionVerification": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "strategy": {
            "$ref": "#/components/schemas/ConnectionStrategy"
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/VerifyCheck"
            }
          },
          "discovery": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "DirectoryProvider": {
        "type": "string",
        "enum": [
          "okta",
          "entra_id",
          "azure_ad",
          "google_workspace",
          "onelogin",
          "jumpcloud",
          "scim_generic",
          "ulex_mock"
        ]
      },
      "Directory": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "provider",
          "state",
          "domain"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "object": {
            "type": "string",
            "const": "directory"
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "example": "Acme (Okta)"
          },
          "provider": {
            "$ref": "#/components/schemas/DirectoryProvider"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "inactive",
              "deleting",
              "failed"
            ]
          },
          "domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$",
            "example": "acme.example"
          },
          "scim_base_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "example": "https://acme.okta.com/scim/v2"
          },
          "inbound_scim_enabled": {
            "type": "boolean"
          },
          "scim_poll_interval_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400,
            "default": 900
          },
          "has_scim_token": {
            "type": "boolean"
          },
          "has_inbound_scim_token": {
            "type": "boolean"
          },
          "has_client_secret": {
            "type": "boolean"
          },
          "last_synced_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_sync_status": {
            "type": "string",
            "enum": [
              "never",
              "ok",
              "partial",
              "error"
            ]
          },
          "last_sync_error": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DirectoryCreate": {
        "type": "object",
        "required": [
          "name",
          "provider",
          "domain"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "provider": {
            "$ref": "#/components/schemas/DirectoryProvider"
          },
          "domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "scim_base_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "scim_token": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048,
            "description": "Plaintext on write; stored encrypted. Use 'env:VAR'."
          },
          "inbound_scim_enabled": {
            "type": "boolean"
          },
          "scim_poll_interval_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "user_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "group_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "deprovision_upstream_removals": {
            "type": "boolean"
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "DirectoryUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "active",
              "inactive"
            ]
          },
          "scim_base_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "scim_token": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2048
          },
          "inbound_scim_enabled": {
            "type": "boolean"
          },
          "scim_poll_interval_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "DirectorySync": {
        "type": "object",
        "required": [
          "id",
          "object",
          "directory_id",
          "state",
          "trigger"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "job_01M3PSVQ68YGZREJKDVZSMQ64T"
          },
          "object": {
            "type": "string",
            "const": "directory_sync"
          },
          "directory_id": {
            "$ref": "#/components/schemas/Id",
            "example": "dir_01M3PSVBF8038RK2MW2N263Q2B"
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "succeeded",
              "partial",
              "failed",
              "cancelled"
            ]
          },
          "trigger": {
            "type": "string",
            "enum": [
              "scheduled",
              "manual",
              "webhook",
              "scim_push"
            ]
          },
          "stats": {
            "type": "object",
            "properties": {
              "users_created": {
                "type": "integer"
              },
              "users_updated": {
                "type": "integer"
              },
              "users_deactivated": {
                "type": "integer"
              },
              "users_failed": {
                "type": "integer"
              },
              "groups_synced": {
                "type": "integer"
              }
            }
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ScimConfiguration": {
        "type": "object",
        "properties": {
          "base_url": {
            "format": "uri",
            "example": "https://ulexid.com/api/v1/scim/v2"
          },
          "bearer_token": {
            "type": "string",
            "description": "Returned once per directory rotation. Requires scim:provision.",
            "example": "scim_7Bq4Nxf2Vk9Lc3MdT6hR8wS1yP5aG0eJ"
          },
          "inbound_scim_enabled": {
            "type": "boolean"
          },
          "poll_interval_seconds": {
            "type": "integer"
          },
          "user_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "group_filter": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "deprovision_upstream_removals": {
            "type": "boolean"
          },
          "schemas_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bulk_supported": {
            "type": "boolean"
          },
          "max_operations_per_bulk": {
            "type": "integer",
            "example": 100
          }
        }
      },
      "Application": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "slug",
          "type"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "object": {
            "type": "string",
            "const": "application"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120,
            "example": "Acme Support"
          },
          "slug": {
            "type": "string",
            "minLength": 2,
            "maxLength": 63,
            "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$",
            "example": "acme-support"
          },
          "type": {
            "type": "string",
            "enum": [
              "first_party",
              "third_party"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "client_id": {
            "type": "string",
            "example": "client_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            },
            "maxItems": 50,
            "example": [
              "https://app.example.com/auth/callback"
            ]
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "authorization_code",
                "refresh_token",
                "client_credentials",
                "urn:ietf:params:oauth:grant-type:token-exchange"
              ]
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "code",
                "id_token",
                "code id_token"
              ]
            }
          },
          "response_mode": {
            "type": "string",
            "enum": [
              "query",
              "fragment",
              "form_post"
            ]
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "client_secret_basic",
              "client_secret_post",
              "private_key_jwt",
              "tls_client_auth",
              "self_signed_tls_client_auth",
              "none"
            ]
          },
          "require_pkce": {
            "type": "boolean"
          },
          "pkce_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "S256",
                "plain"
              ]
            }
          },
          "grant_access_to_organization": {
            "type": "boolean"
          },
          "organization_usage": {
            "type": "string",
            "enum": [
              "deny",
              "allow"
            ]
          },
          "oidc_conformant": {
            "type": "boolean"
          },
          "acr_values": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 256
          },
          "sign_in_with_email_enabled": {
            "type": "boolean"
          },
          "sign_in_with_social_enabled": {
            "type": "boolean"
          },
          "sign_up_enabled": {
            "type": "boolean"
          },
          "cookie_domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$",
            "example": ".ulexid.com"
          },
          "cross_app_sso_enabled": {
            "type": "boolean"
          },
          "cross_app_sso_redirect_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            }
          },
          "branding": {
            "type": "object",
            "properties": {
              "primary_color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "background_color": {
                "type": "string",
                "pattern": "^#[0-9a-fA-F]{6}$"
              },
              "logo_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "favicon_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "app_name": {
                "type": "string",
                "maxLength": 80
              }
            }
          },
          "default_locale": {
            "type": "string",
            "maxLength": 35,
            "example": "en"
          },
          "tls_client_auth_subject_dn": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "tls_client_auth_san_dns": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "tls_client_auth_san_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 255
          },
          "dpop_bound_access_tokens": {
            "type": "boolean"
          },
          "tls_client_certificate_bound_access_tokens": {
            "type": "boolean"
          },
          "subject_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "public",
              "pairwise",
              null
            ]
          },
          "sector_identifier_uri": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ApplicationCreate": {
        "type": "object",
        "required": [
          "name",
          "slug"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "slug": {
            "type": "string",
            "minLength": 2,
            "maxLength": 63,
            "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
          },
          "type": {
            "type": "string",
            "enum": [
              "first_party",
              "third_party"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            },
            "maxItems": 50
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "authorization_code",
                "refresh_token",
                "client_credentials",
                "urn:ietf:params:oauth:grant-type:token-exchange"
              ]
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "code",
                "id_token",
                "code id_token"
              ]
            }
          },
          "response_mode": {
            "type": "string",
            "enum": [
              "query",
              "fragment",
              "form_post"
            ]
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "client_secret_basic",
              "client_secret_post",
              "private_key_jwt",
              "tls_client_auth",
              "self_signed_tls_client_auth",
              "none"
            ]
          },
          "require_pkce": {
            "type": "boolean"
          },
          "pkce_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "S256",
                "plain"
              ]
            }
          },
          "cookie_domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "cross_app_sso_enabled": {
            "type": "boolean"
          },
          "cross_app_sso_redirect_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            }
          },
          "branding": {
            "type": "object",
            "additionalProperties": true
          },
          "default_locale": {
            "type": "string",
            "maxLength": 35
          },
          "tls_client_auth_subject_dn": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "tls_client_auth_san_dns": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "tls_client_auth_san_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 255
          },
          "dpop_bound_access_tokens": {
            "type": "boolean"
          },
          "tls_client_certificate_bound_access_tokens": {
            "type": "boolean"
          },
          "subject_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "public",
              "pairwise",
              null
            ]
          },
          "sector_identifier_uri": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "ApplicationUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "type": {
            "type": "string",
            "enum": [
              "first_party",
              "third_party"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            },
            "maxItems": 50
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "authorization_code",
                "refresh_token",
                "client_credentials",
                "urn:ietf:params:oauth:grant-type:token-exchange"
              ]
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "code",
                "id_token",
                "code id_token"
              ]
            }
          },
          "response_mode": {
            "type": "string",
            "enum": [
              "query",
              "fragment",
              "form_post"
            ]
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "client_secret_basic",
              "client_secret_post",
              "private_key_jwt",
              "tls_client_auth",
              "self_signed_tls_client_auth",
              "none"
            ]
          },
          "require_pkce": {
            "type": "boolean"
          },
          "pkce_methods": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "S256",
                "plain"
              ]
            }
          },
          "cookie_domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "cross_app_sso_enabled": {
            "type": "boolean"
          },
          "cross_app_sso_redirect_urls": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri",
              "maxLength": 2048,
              "description": "https://, or http:// for loopback only."
            }
          },
          "branding": {
            "type": "object",
            "additionalProperties": true
          },
          "default_locale": {
            "type": "string",
            "maxLength": 35
          },
          "tls_client_auth_subject_dn": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "tls_client_auth_san_dns": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "tls_client_auth_san_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email",
            "maxLength": 255
          },
          "dpop_bound_access_tokens": {
            "type": "boolean"
          },
          "tls_client_certificate_bound_access_tokens": {
            "type": "boolean"
          },
          "subject_type": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "public",
              "pairwise",
              null
            ]
          },
          "sector_identifier_uri": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "maxLength": 2048
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "ApplicationCredentials": {
        "type": "object",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string",
            "description": "Decrypted for the tenant-admin scope only."
          },
          "token_endpoint_auth_method": {
            "type": "string",
            "enum": [
              "client_secret_basic",
              "client_secret_post",
              "private_key_jwt",
              "tls_client_auth",
              "self_signed_tls_client_auth",
              "none"
            ]
          },
          "authorization_endpoint": {
            "format": "uri"
          },
          "token_endpoint": {
            "format": "uri"
          },
          "userinfo_endpoint": {
            "format": "uri"
          },
          "jwks_uri": {
            "format": "uri"
          },
          "introspection_endpoint": {
            "format": "uri"
          },
          "revocation_endpoint": {
            "format": "uri"
          },
          "scim_base_url": {
            "format": "uri"
          },
          "saml_sp_metadata_url": {
            "format": "uri"
          },
          "hosted_login_url": {
            "format": "uri"
          },
          "saml_signing_certificate": {
            "type": "string",
            "description": "SAML IdP signing certificate in PEM form."
          },
          "saml_signing_certificate_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "saml_signing_kid": {
            "type": "string"
          },
          "issued_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "SecretRotation": {
        "type": "object",
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string",
            "description": "Returned once. The previous secret stays valid for the grace window."
          },
          "previous_secret_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "grace_period_seconds": {
            "type": "integer"
          }
        }
      },
      "OidcDiscovery": {
        "type": "object",
        "properties": {
          "issuer": {
            "format": "uri"
          },
          "authorization_endpoint": {
            "format": "uri"
          },
          "token_endpoint": {
            "format": "uri"
          },
          "userinfo_endpoint": {
            "format": "uri"
          },
          "jwks_uri": {
            "format": "uri"
          },
          "introspection_endpoint": {
            "format": "uri"
          },
          "revocation_endpoint": {
            "format": "uri"
          },
          "device_authorization_endpoint": {
            "format": "uri"
          },
          "end_session_endpoint": {
            "format": "uri"
          },
          "response_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_modes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "subject_types_supported": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "public",
                "pairwise"
              ]
            }
          },
          "id_token_signing_alg_values_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "claims_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "claims_parameter_supported": {
            "type": "boolean"
          },
          "request_parameter_supported": {
            "type": "boolean"
          },
          "backchannel_logout_supported": {
            "type": "boolean"
          }
        }
      },
      "IdpMetadata": {
        "type": "object",
        "properties": {
          "metadata_xml": {
            "type": "string",
            "description": "SAML 2.0 EntityDescriptor XML."
          },
          "entity_id": {
            "type": "string"
          },
          "sso_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "acs_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "slo_url": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "x509_certificate": {
            "type": "string"
          },
          "name_id_format": {
            "type": "string"
          }
        }
      },
      "SamlLoginUrl": {
        "type": "object",
        "properties": {
          "url": {
            "format": "uri"
          },
          "request_id": {
            "type": "string"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookEvent": {
        "type": "string",
        "enum": [
          "dsync.activated",
          "dsync.deleted",
          "dsync.group.created",
          "dsync.group.deleted",
          "dsync.group.updated",
          "dsync.user.created",
          "dsync.user.deleted",
          "dsync.user.updated",
          "user.created",
          "user.updated",
          "user.deleted",
          "user.suspended",
          "user.unsuspended",
          "organization.created",
          "organization.updated",
          "organization.deleted",
          "connection.activated",
          "connection.deactivated",
          "connection.deleted",
          "session.created",
          "session.revoked",
          "domain.verified",
          "application.created",
          "application.updated",
          "api_key.created",
          "api_key.revoked",
          "deployment.started",
          "deployment.succeeded",
          "deployment.failed",
          "deployment.cancelled",
          "mcp.tool_invoked"
        ]
      },
      "Webhook": {
        "type": "object",
        "required": [
          "id",
          "object",
          "url",
          "status",
          "events"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "whk_01M3PSVK981SXWGKG9JXHC1P0Y"
          },
          "object": {
            "type": "string",
            "const": "webhook"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "disabled"
            ]
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            },
            "minItems": 1
          },
          "secret_prefix": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 12
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "failure_count": {
            "type": "integer",
            "minimum": 0
          },
          "disabled_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "disabled_reason": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "last_delivery_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_delivery_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "api_version": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "WebhookCreate": {
        "type": "object",
        "required": [
          "url",
          "events"
        ],
        "additionalProperties": false,
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048
          },
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            },
            "minItems": 1
          },
          "description": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 300
          },
          "api_version": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "WebhookWithSecret": {
        "type": "object",
        "properties": {
          "webhook": {
            "$ref": "#/components/schemas/Webhook"
          },
          "secret": {
            "type": "string",
            "description": "Returned once. HMAC-SHA256 signing secret.",
            "example": "whsec_3Kq9Xa2mB7yLt4NxZ1pRc6HdE0sJg3AuV8"
          },
          "signature_algorithm": {
            "type": "string",
            "const": "HMAC-SHA256"
          },
          "signature_header": {
            "type": "string",
            "const": "Ulex-Signature"
          },
          "signature_example": {
            "type": "string"
          }
        }
      },
      "WebhookDelivery": {
        "type": "object",
        "required": [
          "id",
          "object",
          "webhook_id",
          "event",
          "status"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "dlv_01M3PSVM8G1BF1SQ3FQ0FPKJJA"
          },
          "object": {
            "type": "string",
            "const": "webhook_delivery"
          },
          "webhook_id": {
            "$ref": "#/components/schemas/Id",
            "example": "whk_01M3PSVK981SXWGKG9JXHC1P0Y"
          },
          "event": {
            "$ref": "#/components/schemas/WebhookEvent"
          },
          "event_id": {
            "$ref": "#/components/schemas/Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "pending",
              "in_flight",
              "delivered",
              "failed",
              "dead_lettered"
            ]
          },
          "attempt": {
            "type": "integer",
            "minimum": 1
          },
          "max_attempts": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 8
          },
          "response_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "response_body": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "error": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "next_attempt_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "delivered_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "AuditAction": {
        "type": "string",
        "enum": [
          "api_key.created",
          "api_key.revoked",
          "application.created",
          "application.deleted",
          "application.secret_rotated",
          "application.updated",
          "authentication.api_key_failed",
          "authentication.challenge",
          "authentication.failed",
          "authentication.mfa_challenge",
          "authentication.mfa_failed",
          "authentication.saml_failed",
          "authentication.session_created",
          "authentication.session_expired",
          "authentication.session_revoked",
          "authentication.succeeded",
          "connection.activated",
          "connection.created",
          "connection.deactivated",
          "connection.deleted",
          "connection.provisioning_refused",
          "connection.updated",
          "consent.denied",
          "consent.granted",
          "consent.revoked",
          "deployment.cancelled",
          "deployment.failed",
          "deployment.started",
          "deployment.succeeded",
          "directory.sync_completed",
          "directory.sync_failed",
          "directory.sync_started",
          "domain.verified",
          "impersonation.ended",
          "impersonation.started",
          "mcp.tool_denied",
          "mcp.tool_invoked",
          "organization.created",
          "organization.deleted",
          "organization.updated",
          "sso.session_created",
          "user.created",
          "user.deleted",
          "user.email_verified",
          "user.password_reset",
          "user.suspended",
          "user.unsuspended",
          "user.updated",
          "webhook.created",
          "webhook.deleted",
          "webhook.delivery_failed",
          "webhook.disabled",
          "webhook.enabled",
          "webhook.updated"
        ]
      },
      "AuditChain": {
        "type": "object",
        "properties": {
          "previous_hash": {
            "type": "string"
          },
          "entry_hash": {
            "type": "string"
          },
          "hash_version": {
            "type": "integer"
          }
        },
        "description": "The link an audit event carries. Deprecated as a shape: the fields are flat on the event itself (`previous_hash`, `entry_hash`, `hash_version`), and there is no `sequence` — order comes from the links, because a sequence number cannot order two entries written in the same millisecond."
      },
      "AuditEvent": {
        "type": "object",
        "required": [
          "id",
          "object",
          "action",
          "category",
          "outcome",
          "timestamp",
          "entry_hash"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "aud_01M3PSVN7R3H0ECRPQVTDF1PY9"
          },
          "object": {
            "type": "string",
            "const": "audit_event"
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "action": {
            "$ref": "#/components/schemas/AuditAction"
          },
          "category": {
            "type": "string",
            "enum": [
              "authentication",
              "authorization",
              "configuration",
              "data_access",
              "data_modification",
              "provisioning",
              "security",
              "system"
            ]
          },
          "actor_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "actor_hash": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64,
            "description": "sha256 of the actor email. The email itself is never stored."
          },
          "actor_type": {
            "type": "string",
            "enum": [
              "user",
              "api_key",
              "system",
              "service",
              "agent"
            ]
          },
          "actor_display": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 200
          },
          "target": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "maxLength": 32
                  },
                  "id": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 64
                  },
                  "display_name": {
                    "type": [
                      "string",
                      "null"
                    ],
                    "maxLength": 200
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "organization_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "connection_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "correlation_id": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "session_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "ip_hash": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64,
            "description": "sha256 of the client IP. The raw address is never stored."
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true
          },
          "outcome": {
            "type": "string",
            "enum": [
              "success",
              "failure",
              "denied"
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "timestamp": {
            "type": "integer",
            "description": "Milliseconds since epoch. Primary sort key."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "previous_hash": {
            "type": [
              "string",
              "null"
            ],
            "description": "Chain link: this entry's predecessor's `entry_hash`. Null on a chain's first entry."
          },
          "entry_hash": {
            "type": "string",
            "description": "This entry's hash over its contents. Recomputable; verify with `POST /audit-events/verify_chain`."
          },
          "hash_version": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Which hashing formula produced `entry_hash`. A row written before this field existed is version 1, whose formula cannot be recomputed from storage and therefore verifies as `unverifiable`."
          }
        }
      },
      "AuditList": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ListEnvelope"
          },
          {
            "type": "object",
            "properties": {
              "chain_head": {
                "type": "string",
                "description": "entry_hash of the newest entry in this tenant."
              }
            }
          }
        ]
      },
      "DeploymentStep": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 80
          },
          "state": {
            "type": "string",
            "enum": [
              "pending",
              "running",
              "succeeded",
              "failed",
              "skipped"
            ]
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 2000
          },
          "logs": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 2000
            }
          }
        }
      },
      "Deployment": {
        "type": "object",
        "required": [
          "id",
          "object",
          "application_id",
          "environment",
          "state"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "dep_01M3PSVP70YQ9Y1YD8QMC42JXF"
          },
          "object": {
            "type": "string",
            "const": "deployment"
          },
          "application_id": {
            "$ref": "#/components/schemas/Id",
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "state": {
            "type": "string",
            "enum": [
              "queued",
              "provisioning",
              "configuring",
              "building",
              "deploying",
              "verifying",
              "succeeded",
              "failed",
              "cancelled",
              "rolled_back"
            ]
          },
          "domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "strategy": {
            "type": "string",
            "enum": [
              "simulated",
              "agent_direct",
              "cloudformation",
              "synthesize"
            ]
          },
          "commit_sha": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9a-f]{7,40}$"
          },
          "commit_message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "branch": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "resources": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "maxLength": 64
                },
                "id": {
                  "type": "string",
                  "maxLength": 255
                },
                "url": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "uri"
                }
              }
            }
          },
          "issued": {
            "type": "object",
            "properties": {
              "client_id": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              },
              "client_secret": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              },
              "api_key": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              },
              "saml_entity_id": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              },
              "saml_acs_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "saml_idp_metadata_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "oidc_issuer": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "scim_base_url": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "scim_bearer_token": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              },
              "authorization_endpoint": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "token_endpoint": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uri"
              },
              "admin_email": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 320
              },
              "admin_password": {
                "type": [
                  "string",
                  "null"
                ],
                "maxLength": 255
              }
            }
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeploymentStep"
            },
            "maxItems": 50
          },
          "error": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string",
                    "maxLength": 64
                  },
                  "message": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "retryable": {
                    "type": "boolean"
                  }
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "progress_percent": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100
          },
          "rolled_back_from": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      },
      "DeploymentCreate": {
        "type": "object",
        "required": [
          "application_id",
          "environment"
        ],
        "additionalProperties": false,
        "properties": {
          "application_id": {
            "$ref": "#/components/schemas/Id",
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "commit_sha": {
            "type": [
              "string",
              "null"
            ],
            "pattern": "^[0-9a-f]{7,40}$"
          },
          "commit_message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 500
          },
          "branch": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "strategy": {
            "type": "string",
            "enum": [
              "simulated",
              "agent_direct",
              "cloudformation",
              "synthesize"
            ]
          },
          "confirm": {
            "type": "boolean",
            "description": "Must be `true` when `environment` is `prod`. Absent or `false` in `prod` is 400 `validation_failed` with `param: \"confirm\"`. This is the interlock that stops a mistargeted call from promoting an application into production."
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "Environment": {
        "type": "object",
        "required": [
          "id",
          "object",
          "slug",
          "name",
          "domain"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string",
            "const": "environment"
          },
          "slug": {
            "type": "string",
            "enum": [
              "development",
              "staging",
              "production"
            ]
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 80
          },
          "domain": {
            "type": "string",
            "maxLength": 253,
            "pattern": "^[^\\s/]+$"
          },
          "region": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Health": {
        "type": "object",
        "properties": {
          "healthy": {
            "type": "boolean"
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "version": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "uptime_seconds": {
            "type": "integer"
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "pass",
                    "fail",
                    "warn"
                  ]
                },
                "latency_ms": {
                  "type": "integer"
                }
              }
            }
          }
        }
      },
      "Status": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "healthy",
              "degraded",
              "unavailable"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "version": {
            "type": "string"
          },
          "region": {
            "type": "string"
          },
          "degradations": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 300
            }
          }
        }
      },
      "Tenant": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "slug",
          "environment",
          "plan"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "ten_01M3PSV6K0HFZ62YZ6AKB191WW"
          },
          "object": {
            "type": "string",
            "const": "tenant"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 120
          },
          "slug": {
            "type": "string",
            "minLength": 2,
            "maxLength": 63,
            "pattern": "^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$"
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "plan": {
            "type": "string",
            "enum": [
              "simulator_free",
              "team",
              "business",
              "enterprise"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "suspended",
              "closed"
            ]
          },
          "region": {
            "type": "string",
            "example": "us-east-1"
          },
          "allow_mocks": {
            "type": "boolean"
          },
          "hipaa_enabled": {
            "type": "boolean"
          },
          "hipaa_baa_reference": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 128
          },
          "data_processing_addendum_signed_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "retention": {
            "type": "object",
            "properties": {
              "audit_log_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 365,
                "maximum": 3650
              },
              "webhook_delivery_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1,
                "maximum": 365
              },
              "session_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1,
                "maximum": 365
              },
              "application_inactive_days": {
                "type": [
                  "integer",
                  "null"
                ],
                "minimum": 1,
                "maximum": 3650
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TenantUpdate": {
        "type": "object",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "allow_mocks": {
            "type": "boolean"
          },
          "hipaa_enabled": {
            "type": "boolean"
          },
          "retention": {
            "type": "object",
            "additionalProperties": {
              "type": [
                "integer",
                "null"
              ]
            }
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "organizations": {
            "type": "integer"
          },
          "users": {
            "type": "integer"
          },
          "connections": {
            "type": "integer"
          },
          "applications": {
            "type": "integer"
          },
          "mcp_calls_current_minute": {
            "type": "integer"
          },
          "webhook_endpoints": {
            "type": "integer"
          },
          "active_deployments": {
            "type": "integer"
          }
        }
      },
      "Me": {
        "type": "object",
        "properties": {
          "tenant": {
            "$ref": "#/components/schemas/Tenant"
          },
          "credential": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "api_key",
                  "access_token",
                  "scim_token"
                ]
              },
              "scope": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "environments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Environment"
            }
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "required": [
          "id",
          "object",
          "name",
          "prefix",
          "scope"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "key_01M3PSVJA0YP2WDPM2RDR15MGH"
          },
          "object": {
            "type": "string",
            "const": "api_key"
          },
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "prefix": {
            "type": "string",
            "minLength": 8,
            "maxLength": 24
          },
          "scope": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1
          },
          "application_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "ip_allowlist": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_used_ip_hash": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "revoked_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          },
          "expires_in_days": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ApiKeyCreate": {
        "type": "object",
        "required": [
          "name",
          "scope"
        ],
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "scope": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "minItems": 1,
            "example": [
              "mcp:tools",
              "read:organizations",
              "write:organizations"
            ]
          },
          "application_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "ip_allowlist": {
            "type": "array",
            "items": {
              "type": "string",
              "maxLength": 64
            }
          },
          "expires_in_days": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "maximum": 365
          },
          "idempotency_key": {
            "$ref": "#/components/schemas/IdempotencyKey"
          }
        }
      },
      "ApiKeyWithSecret": {
        "type": "object",
        "properties": {
          "api_key": {
            "$ref": "#/components/schemas/ApiKey"
          },
          "key": {
            "type": "string",
            "description": "Returned once. Starts with ulex_sk_live_ or ulex_sk_test_.",
            "example": "ulex_sk_live_7Qm2KpLx9Tb4Ns8RfWy3Zc1Hjf6Ee0Au"
          },
          "warning": {
            "type": "string"
          }
        }
      },
      "SigningKeyRotation": {
        "type": "object",
        "properties": {
          "purpose": {
            "type": "string",
            "enum": [
              "id_token",
              "access_token",
              "webhook",
              "saml_request",
              "saml_response",
              "jwt_bearer"
            ]
          },
          "new_key": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "kid": {
                "type": "string"
              },
              "algorithm": {
                "type": "string"
              },
              "state": {
                "type": "string",
                "enum": [
                  "active",
                  "retiring",
                  "revoked"
                ]
              }
            }
          },
          "previous_key": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string"
              },
              "kid": {
                "type": "string"
              },
              "state": {
                "type": "string",
                "enum": [
                  "active",
                  "retiring",
                  "revoked"
                ]
              }
            }
          },
          "grace_period_seconds": {
            "type": "integer"
          },
          "previous_key_revokes_at": {
            "type": "string",
            "format": "date-time"
          },
          "jwks_url": {
            "format": "uri"
          }
        }
      },
      "SigningKeyRotateRequest": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "purpose": {
            "type": "string",
            "enum": [
              "id_token",
              "access_token",
              "webhook",
              "saml_request",
              "saml_response",
              "jwt_bearer"
            ]
          },
          "purposes": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "id_token",
                "access_token",
                "webhook",
                "saml_request",
                "saml_response",
                "jwt_bearer"
              ]
            }
          },
          "grace_period_seconds": {
            "type": "integer",
            "minimum": 300,
            "maximum": 2592000
          }
        }
      },
      "Jwks": {
        "type": "object",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "TokenResponse": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in"
        ],
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "const": "Bearer"
          },
          "expires_in": {
            "type": "integer",
            "example": 3600
          },
          "refresh_token": {
            "type": "string"
          },
          "refresh_token_expires_in": {
            "type": "integer",
            "example": 2592000
          },
          "id_token": {
            "type": "string"
          },
          "issued_token_type": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          }
        }
      },
      "IntrospectionResponse": {
        "type": "object",
        "required": [
          "active"
        ],
        "properties": {
          "active": {
            "type": "boolean"
          },
          "token_type": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          },
          "client_id": {
            "type": "string"
          },
          "sub": {
            "type": "string"
          },
          "org_id": {
            "type": "string"
          },
          "sid": {
            "type": "string"
          },
          "exp": {
            "type": "integer"
          },
          "iat": {
            "type": "integer"
          },
          "auth_time": {
            "type": "integer"
          },
          "amr": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "acr": {
            "type": "string"
          }
        }
      },
      "Userinfo": {
        "type": "object",
        "properties": {
          "sub": {
            "type": "string"
          },
          "iss": {
            "type": "string"
          },
          "aud": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "given_name": {
            "type": "string"
          },
          "family_name": {
            "type": "string"
          },
          "preferred_username": {
            "type": "string"
          },
          "email": {
            "type": "string"
          },
          "email_verified": {
            "type": "boolean"
          },
          "job_title": {
            "type": "string"
          },
          "department": {
            "type": "string"
          },
          "locale": {
            "type": "string"
          },
          "updated_at": {
            "type": "integer"
          },
          "org_id": {
            "type": "string"
          },
          "org_slug": {
            "type": "string"
          },
          "connection_id": {
            "type": "string"
          },
          "sid": {
            "type": "string"
          },
          "amr": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "acr": {
            "type": "string"
          },
          "https://ulexid.com/claims": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "DeviceCode": {
        "type": "object",
        "properties": {
          "device_code": {
            "type": "string"
          },
          "user_code": {
            "type": "string"
          },
          "verification_uri": {
            "format": "uri"
          },
          "verification_uri_complete": {
            "format": "uri"
          },
          "expires_in": {
            "type": "integer"
          },
          "interval": {
            "type": "integer"
          }
        }
      },
      "AuthAttempt": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "job_01M3PSVQ68YGZREJKDVZSMQ64T"
          },
          "object": {
            "type": "string",
            "const": "auth_attempt"
          },
          "connection_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "organization_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "strategy": {
            "$ref": "#/components/schemas/ConnectionStrategy"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "success",
              "failure",
              "challenge",
              "error",
              "cancelled"
            ]
          },
          "stage": {
            "type": "string",
            "enum": [
              "initiated",
              "redirected",
              "callback",
              "validated",
              "provisioned",
              "mfa",
              "complete"
            ]
          },
          "user_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "error_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "error_message": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 1000
          },
          "duration_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "ip_hash": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 512
          },
          "correlation_id": {
            "type": "string",
            "maxLength": 64
          },
          "started_at": {
            "type": "string",
            "format": "date-time"
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "SimulatorAuthenticate": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "application_id": {
            "$ref": "#/components/schemas/Id",
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 320
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "user_code": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 16
          },
          "protocol": {
            "type": "string",
            "enum": [
              "oidc",
              "saml"
            ]
          },
          "return_pkce": {
            "type": "boolean"
          },
          "return_assertion": {
            "type": "boolean"
          }
        }
      },
      "SimulatorResult": {
        "type": "object",
        "properties": {
          "session_id": {
            "$ref": "#/components/schemas/Id",
            "example": "ses_01M3PSVFC8MAB38QYAA8Q1K9MG"
          },
          "grant_id": {
            "$ref": "#/components/schemas/Id",
            "example": "grt_01M3PSVGBGJT1ZXC840F2B3NXJ"
          },
          "user_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "connection_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "con_01M3PSVAG0QFJG99R0M5DXSR5A"
          },
          "outcome": {
            "type": "string",
            "enum": [
              "success",
              "failure",
              "challenge",
              "error",
              "cancelled"
            ]
          },
          "stage": {
            "type": "string",
            "enum": [
              "initiated",
              "redirected",
              "callback",
              "validated",
              "provisioned",
              "mfa",
              "complete"
            ]
          },
          "authorization_url": {
            "format": "uri"
          },
          "code": {
            "type": "string"
          },
          "code_expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "code_verifier": {
            "type": [
              "string",
              "null"
            ],
            "description": "Returned only when return_pkce is true."
          },
          "assertion_b64": {
            "type": [
              "string",
              "null"
            ],
            "description": "Returned only when return_assertion is true."
          },
          "attributes": {
            "type": "object",
            "additionalProperties": true
          },
          "amr": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "acr": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "duration_ms": {
            "type": "integer"
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "MintToken": {
        "type": "object",
        "required": [
          "user_id"
        ],
        "additionalProperties": false,
        "properties": {
          "user_id": {
            "$ref": "#/components/schemas/Id",
            "example": "usr_01M3PSV9GRT8GQGEG686AR1W9S"
          },
          "application_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "app_01M3PSV7J8TBSPHG95CYSEX32B"
          },
          "organization_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "org_01M3PSV8HGTKQFCAYF9GDWGN3C"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "openid",
              "profile",
              "email"
            ]
          },
          "ttl_seconds": {
            "type": "integer",
            "minimum": 60,
            "maximum": 86400,
            "example": 900
          },
          "amr": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "MintedToken": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "const": "Bearer"
          },
          "expires_in": {
            "type": "integer"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "claims": {
            "type": "object",
            "additionalProperties": true
          },
          "warning": {
            "type": "string"
          }
        }
      },
      "SimulatorReset": {
        "type": "object",
        "properties": {
          "reset": {
            "type": "boolean"
          },
          "scope": {
            "type": "string",
            "enum": [
              "simulation",
              "directory_sync",
              "deployments",
              "webhooks",
              "all"
            ]
          },
          "deleted": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "kept_api_keys": {
            "type": "boolean"
          }
        }
      },
      "ScimError": {
        "type": "object",
        "required": [
          "schemas",
          "status",
          "detail"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "urn:ietf:params:scim:api:messages:2.0:Error"
            ]
          },
          "status": {
            "type": "string",
            "example": "409"
          },
          "scimType": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "invalidFilter",
              "tooMany",
              "uniqueness",
              "mutability",
              "invalidSyntax",
              "invalidPath",
              "invalidValue",
              "noTarget"
            ]
          },
          "detail": {
            "type": "string"
          },
          "request_id": {
            "$ref": "#/components/schemas/RequestId"
          }
        }
      },
      "ScimUser": {
        "type": "object",
        "required": [
          "schemas"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "usr_01M3PSWBPGS08FWV4NV7P9VNFN"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "userName": {
            "type": "string",
            "format": "email",
            "maxLength": 320,
            "example": "pat@acme.example"
          },
          "name": {
            "type": "object",
            "properties": {
              "givenName": {
                "type": "string"
              },
              "familyName": {
                "type": "string"
              },
              "formatted": {
                "type": "string"
              }
            }
          },
          "displayName": {
            "type": "string"
          },
          "nickName": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "profileUrl": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri"
          },
          "title": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "userType": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "preferredLanguage": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 35
          },
          "locale": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 35
          },
          "timezone": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 64
          },
          "active": {
            "type": "boolean"
          },
          "emails": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string",
                  "format": "email",
                  "maxLength": 320
                },
                "type": {
                  "type": "string"
                },
                "primary": {
                  "type": "boolean"
                }
              }
            }
          },
          "groups": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User": {
            "type": "object",
            "additionalProperties": true
          },
          "meta": {
            "type": "object",
            "properties": {
              "resourceType": {
                "type": "string"
              },
              "created": {
                "type": "string",
                "format": "date-time"
              },
              "lastModified": {
                "type": "string",
                "format": "date-time"
              },
              "version": {
                "type": "string",
                "example": "W/\"v1.0\""
              },
              "location": {
                "format": "uri"
              }
            }
          }
        }
      },
      "ScimGroup": {
        "type": "object",
        "required": [
          "schemas"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "grp_01M3PSVED0M9RJTYH5AC72C253"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 255
          },
          "displayName": {
            "type": "string",
            "example": "Support"
          },
          "members": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "value": {
                  "type": "string"
                },
                "display": {
                  "type": "string"
                },
                "$ref": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "meta": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ScimListResponse": {
        "type": "object",
        "required": [
          "schemas",
          "totalResults",
          "itemsPerPage",
          "startIndex",
          "Resources"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "urn:ietf:params:scim:api:messages:2.0:ListResponse"
            ]
          },
          "totalResults": {
            "type": "integer"
          },
          "itemsPerPage": {
            "type": "integer"
          },
          "startIndex": {
            "type": "integer"
          },
          "Resources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "ScimServiceProviderConfig": {
        "type": "object",
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "documentationUri": {
            "format": "uri"
          },
          "patch": {
            "type": "object",
            "properties": {
              "supported": {
                "type": "boolean"
              }
            }
          },
          "bulk": {
            "type": "object",
            "properties": {
              "supported": {
                "type": "boolean"
              },
              "maxOperations": {
                "type": "integer"
              },
              "maxPayloadSize": {
                "type": "integer"
              }
            }
          },
          "filter": {
            "type": "object",
            "additionalProperties": true
          },
          "changePassword": {
            "type": "object",
            "properties": {
              "supported": {
                "type": "boolean"
              }
            }
          },
          "sort": {
            "type": "object",
            "properties": {
              "supported": {
                "type": "boolean"
              }
            }
          },
          "etag": {
            "type": "object",
            "properties": {
              "supported": {
                "type": "boolean"
              }
            }
          },
          "authenticationSchemes": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "meta": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ScimBulkRequest": {
        "type": "object",
        "required": [
          "schemas",
          "Operations"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "urn:ietf:params:scim:api:messages:2.0:BulkRequest"
            ]
          },
          "failOnErrors": {
            "type": "integer",
            "minimum": 0
          },
          "Operations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "method",
                "path"
              ],
              "properties": {
                "method": {
                  "type": "string",
                  "enum": [
                    "POST",
                    "PUT",
                    "PATCH",
                    "DELETE"
                  ]
                },
                "path": {
                  "type": "string",
                  "enum": [
                    "/Users",
                    "/Users/{id}",
                    "/Groups",
                    "/Groups/{id}"
                  ]
                },
                "bulkId": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "data": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "ScimBulkResponse": {
        "type": "object",
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "Operations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "method": {
                  "type": "string"
                },
                "bulkId": {
                  "type": "string"
                },
                "version": {
                  "type": "string"
                },
                "location": {
                  "type": "string"
                },
                "status": {
                  "type": "integer"
                },
                "response": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      },
      "ScimPatchOp": {
        "type": "object",
        "required": [
          "schemas",
          "Operations"
        ],
        "properties": {
          "schemas": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "example": [
              "urn:ietf:params:scim:api:messages:2.0:PatchOp"
            ]
          },
          "Operations": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "op"
              ],
              "properties": {
                "op": {
                  "type": "string",
                  "enum": [
                    "add",
                    "replace",
                    "remove"
                  ]
                },
                "path": {
                  "type": "string"
                },
                "value": {}
              }
            }
          }
        }
      },
      "ListEnvelope": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ApplicationList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Application"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "OrganizationList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Organization"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "UserList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/User"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ConnectionList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Connection"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DirectoryList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Directory"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DomainList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Domain"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "MembershipList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Membership"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "GroupList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Group"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "ApiKeyList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiKey"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "WebhookList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Webhook"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "WebhookDeliveryList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookDelivery"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DirectorySyncList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DirectorySync"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "DeploymentList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Deployment"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "EnvironmentList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Environment"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AuditEventList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "has_more",
          "next_cursor"
        ],
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AuditEvent"
            }
          },
          "first_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "last_id": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Id"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AuditChainVerify": {
        "type": "object",
        "additionalProperties": false,
        "description": "The window to verify. Both bounds are optional and default to the last 24 hours. Any other key is rejected rather than ignored: an unrecognised field here would silently narrow the window, and `valid: true` over twelve hours read as twenty-four is the worst answer this endpoint can give.",
        "properties": {
          "from": {
            "type": "string",
            "format": "date-time",
            "description": "Inclusive start. Defaults to 24 hours before `to`."
          },
          "to": {
            "type": "string",
            "format": "date-time",
            "description": "Inclusive end. Defaults to now."
          }
        }
      },
      "AuditChainVerifyResult": {
        "type": "object",
        "required": [
          "valid",
          "checked",
          "failure",
          "windowStartsMidChain",
          "head"
        ],
        "properties": {
          "valid": {
            "type": "boolean",
            "description": "false only when the chain failed inside this window. An entry that was removed or reordered is reported here; a window that merely starts part-way through the chain is not a failure."
          },
          "checked": {
            "type": "integer",
            "description": "Entries actually verified. Not the size of the window: a failure stops the walk."
          },
          "failure": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/AuditChainFailure"
              }
            ],
            "description": "Null when valid."
          },
          "windowStartsMidChain": {
            "type": "boolean",
            "description": "True when the window began part-way through the chain, so its oldest entry's link to its predecessor was not checked. `valid: true` in that case means nothing inside the window is wrong, not that the window is a whole chain."
          },
          "head": {
            "anyOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/EntryHash"
              }
            ],
            "description": "`entry_hash` of the newest entry in the window, for continuing a check across windows without re-reading the last entry."
          },
          "guidance": {
            "type": "object",
            "description": "Present only when `valid` is false. `severity` is the field to branch on: `hash_mismatch` is security, the other three are operational.",
            "required": [
              "severity"
            ],
            "properties": {
              "severity": {
                "type": "string",
                "enum": [
                  "operational",
                  "security"
                ]
              },
              "what": {
                "type": "string"
              },
              "do": {
                "type": "string"
              },
              "not": {
                "type": "string"
              }
            }
          },
          "summary": {
            "type": "string",
            "description": "Prose summary of the verdict, including the mid-chain caveat when it applies."
          },
          "window": {
            "type": "object",
            "description": "The window actually verified, after defaults were applied.",
            "required": [
              "from",
              "to"
            ],
            "properties": {
              "from": {
                "type": "string",
                "format": "date-time"
              },
              "to": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "Deleted": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string"
          },
          "deleted": {
            "type": "boolean",
            "const": true
          },
          "deleted_at": {
            "type": "string",
            "format": "date-time"
          },
          "restore_window_days": {
            "type": "integer",
            "example": 30
          }
        }
      },
      "SuspendResult": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string",
            "const": "user"
          },
          "status": {
            "type": "string",
            "enum": [
              "suspended",
              "active"
            ]
          },
          "revoked_sessions": {
            "type": "integer"
          },
          "revoked_refresh_token_families": {
            "type": "integer"
          },
          "webhook_events_emitted": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebhookEvent"
            }
          },
          "audit_action": {
            "$ref": "#/components/schemas/AuditAction"
          }
        }
      },
      "DeploymentLogs": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "deployment_logs"
          },
          "deployment_id": {
            "$ref": "#/components/schemas/Id"
          },
          "steps": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DeploymentStep"
            }
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "ts": {
                  "type": "string",
                  "format": "date-time"
                },
                "level": {
                  "type": "string",
                  "enum": [
                    "debug",
                    "info",
                    "warn",
                    "error"
                  ]
                },
                "step": {
                  "type": "string"
                },
                "message": {
                  "type": "string",
                  "maxLength": 2000
                }
              }
            }
          }
        }
      },
      "KeyRotationResult": {
        "type": "object",
        "properties": {
          "rotated": {
            "type": "boolean"
          },
          "purposes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/SigningKeyRotation"
            }
          },
          "jwks_url": {
            "format": "uri"
          }
        }
      },
      "SigningKey": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string",
            "const": "signing_key"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "id_token",
              "access_token",
              "webhook",
              "saml_request",
              "saml_response",
              "jwt_bearer"
            ]
          },
          "algorithm": {
            "type": "string",
            "enum": [
              "RS256",
              "RS384",
              "RS512",
              "ES256",
              "ES384",
              "PS256",
              "EdDSA"
            ]
          },
          "kid": {
            "type": "string"
          },
          "public_key_pem": {
            "type": "string"
          },
          "state": {
            "type": "string",
            "enum": [
              "active",
              "retiring",
              "revoked"
            ]
          },
          "activated_at": {
            "type": "string",
            "format": "date-time"
          },
          "expires_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "OAuthProtectedResource": {
        "type": "object",
        "properties": {
          "resource": {
            "format": "uri"
          },
          "authorization_servers": {
            "type": "array",
            "items": {
              "format": "uri"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "bearer_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resource_documentation": {
            "format": "uri"
          }
        }
      },
      "McpError": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              },
              "data": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/ErrorEnvelope"
                  },
                  {
                    "type": "object",
                    "additionalProperties": true
                  }
                ],
                "description": "The underlying ulex error, in the same shape a REST call returns."
              }
            },
            "required": [
              "code",
              "message"
            ]
          }
        },
        "required": [
          "jsonrpc",
          "error"
        ]
      },
      "McpResult": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "result": {
            "type": "object",
            "properties": {
              "content": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "structuredContent": {
                "type": "object",
                "additionalProperties": true
              },
              "isError": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "Passkey": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "psk_01M3PSVR5GYASQ2ETPYPC11Y2A"
          },
          "object": {
            "type": "string",
            "const": "passkey"
          },
          "user_id": {
            "$ref": "#/components/schemas/Id"
          },
          "credential_id": {
            "type": "string"
          },
          "counter": {
            "type": "integer"
          },
          "transports": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "usb",
                "nfc",
                "ble",
                "internal",
                "hybrid"
              ]
            }
          },
          "aaguid": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "device_type": {
            "type": "string",
            "enum": [
              "single_device",
              "multi_device"
            ]
          },
          "backed_up": {
            "type": "boolean"
          },
          "name": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 80
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "MfaFactor": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id",
            "example": "mfa_01M3PSVS4RVKHQVRPCKNJGYBEZ"
          },
          "object": {
            "type": "string",
            "const": "mfa_factor"
          },
          "user_id": {
            "$ref": "#/components/schemas/Id"
          },
          "type": {
            "type": "string",
            "enum": [
              "totp",
              "sms",
              "email",
              "webauthn",
              "backup_code",
              "push"
            ]
          },
          "target_hint": {
            "type": [
              "string",
              "null"
            ],
            "maxLength": 120,
            "description": "sha256 of the destination. The raw value is never stored."
          },
          "verified": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "AuditChainFailure": {
        "type": "object",
        "required": [
          "kind",
          "at",
          "detail",
          "found_previous",
          "expected_previous"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "missing_predecessor",
              "broken_link",
              "hash_mismatch",
              "unverifiable"
            ],
            "description": "A closed list, because an agent switches on it exhaustively. `hash_mismatch` — the entry's contents no longer hash to its recorded hash — is the only kind that is evidence the log was altered. The other three are ways ulex wrote the log wrong: a lost write, two appenders racing for the same predecessor or a clock behind, and a hash written by a formula that cannot be recomputed from storage."
          },
          "at": {
            "type": "string",
            "description": "The entry id the failure was detected at."
          },
          "detail": {
            "type": "string",
            "maxLength": 1000,
            "description": "Prose an operator can act on. Switch on `kind` in code, not on this string."
          },
          "found_previous": {
            "type": "string",
            "nullable": true,
            "description": "What the entry claims to link from. Null for a chain's first entry."
          },
          "expected_previous": {
            "type": "string",
            "nullable": true,
            "description": "What it should have linked from, where that is knowable from the window."
          }
        }
      },
      "EntryHash": {
        "type": "string",
        "pattern": "^sha256:[0-9a-f]{64}$",
        "description": "A chain link: the `entry_hash` of an entry, as `sha256:<hex>`."
      },
      "ConnectionCheck": {
        "type": "object",
        "required": [
          "check",
          "status",
          "detail"
        ],
        "properties": {
          "check": {
            "type": "string",
            "description": "What was checked. Named so it can be asserted on; the set grows with the checks."
          },
          "status": {
            "type": "string",
            "enum": [
              "passed",
              "failed",
              "skipped"
            ],
            "description": "`skipped` means the check does not apply to this strategy — not that it passed."
          },
          "detail": {
            "type": "string",
            "description": "The observed value, or the specific reason it failed. This is what tells an integrator which field to change."
          }
        }
      },
      "ConnectionVerificationResult": {
        "type": "object",
        "required": [
          "connection_id",
          "valid",
          "checks"
        ],
        "properties": {
          "connection_id": {
            "type": "string",
            "description": "`con_…`"
          },
          "valid": {
            "type": "boolean",
            "description": "True when no check failed. A `skipped` check does not make it false."
          },
          "checks": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConnectionCheck"
            }
          }
        }
      },
      "AuthPolicyPassword": {
        "type": "object",
        "description": "Password strength. Applied where a password is chosen. `max_age_days` and `forbid_reuse_count` are accepted and returned but **not yet applied** — ulex keeps no password history and no password age, so there is nothing to compare them to. They are documented as inert here rather than implying a control that is not there.",
        "properties": {
          "min_length": {
            "type": "integer",
            "minimum": 8,
            "maximum": 128,
            "default": 12,
            "description": "Shortest accepted password. Enforced."
          },
          "require_uppercase": {
            "type": "boolean",
            "default": true,
            "description": "Enforced."
          },
          "require_lowercase": {
            "type": "boolean",
            "default": true,
            "description": "Enforced."
          },
          "require_number": {
            "type": "boolean",
            "default": true,
            "description": "Enforced."
          },
          "require_symbol": {
            "type": "boolean",
            "default": true,
            "description": "Enforced."
          },
          "check_breached_passwords": {
            "type": "boolean",
            "default": true,
            "description": "Controls breach-warning screening. The tenant value overrides ULEX_SCREEN_PASSWORDS when a tenant auth policy exists."
          },
          "max_age_days": {
            "type": "integer",
            "nullable": true,
            "default": 365,
            "description": "NOT YET ENFORCED. Stored and returned; no code compares it to a password age."
          },
          "forbid_reuse_count": {
            "type": "integer",
            "default": 5,
            "description": "NOT YET ENFORCED. Stored and returned; ulex keeps no password history."
          }
        }
      },
      "AuthPolicySession": {
        "type": "object",
        "description": "Session lifetime and binding. Every field here is enforced on the request that reads the session or mints a new one.",
        "properties": {
          "lifetime_seconds": {
            "type": "integer",
            "default": 86400,
            "description": "Absolute session lifetime. Enforced."
          },
          "idle_timeout_seconds": {
            "type": "integer",
            "default": 604800,
            "description": "Idle window. Enforced, and clamped to `lifetime_seconds` — a session must never outlive its own idle window, or it never times out at all. This was hardcoded to 7 days while remaining settable."
          },
          "reauthenticate_after_seconds": {
            "type": "integer",
            "default": 86400,
            "description": "Writes `session.reauthenticate_at`. Enforced. Hardcoded to 24h while remaining settable."
          },
          "bind_to_ip": {
            "type": "boolean",
            "default": false,
            "description": "Enforced. Default **off** because mobile networks change address mid-session. Compared against a pseudonym, never the raw address."
          },
          "bind_to_user_agent": {
            "type": "boolean",
            "default": true,
            "description": "Enforced. A mismatch **revokes** the session rather than merely refusing the request, because a session whose binding no longer holds is one an attacker may hold."
          },
          "cross_app_sso": {
            "type": "boolean",
            "default": true,
            "description": "Enforced at `/oauth2/authorize`. When false, a session created by one application cannot mint a code for another; `prompt=none` answers `login_required` with a hint saying so."
          }
        }
      },
      "AuthPolicyMfa": {
        "type": "object",
        "description": "Required mode challenges users with a usable enrolled factor but does not require enrollment; users without a factor can still sign in. Adaptive mode has no risk engine. Methods, remember-device, and trigger settings are stored but not applied.",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "optional",
              "required",
              "adaptive"
            ],
            "default": "optional",
            "description": "Required challenges users with a usable enrolled factor but does not require enrollment; users without a factor can still sign in. Adaptive is stored but not applied because no risk engine exists."
          },
          "methods": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "remember_device_days": {
            "type": "integer",
            "default": 30
          },
          "trigger_on_new_device": {
            "type": "boolean",
            "default": true
          },
          "trigger_on_ip_change": {
            "type": "boolean",
            "default": true
          },
          "trigger_on_high_risk": {
            "type": "boolean",
            "default": true
          }
        }
      },
      "AuthPolicy": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "object",
          "environment",
          "password",
          "session",
          "mfa",
          "blocked_ip_ranges",
          "created_at",
          "updated_at",
          "set"
        ],
        "description": "The tenant's authentication policy.\n\n`set` says which blocks an operator **chose** rather than inherited. A value alone cannot distinguish \"this tenant requires a 14 character password\" from \"14 is what ulex chooses for everyone\", and an auditor asking the first question cannot answer it from the number.",
        "properties": {
          "id": {
            "type": "string",
            "description": "`pol_…`. Stable across edits, so an audit event keeps naming one subject."
          },
          "tenant_id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "auth_policy"
            ]
          },
          "environment": {
            "type": "string",
            "enum": [
              "dev",
              "stage",
              "prod"
            ]
          },
          "password": {
            "$ref": "#/components/schemas/AuthPolicyPassword"
          },
          "session": {
            "$ref": "#/components/schemas/AuthPolicySession"
          },
          "mfa": {
            "$ref": "#/components/schemas/AuthPolicyMfa"
          },
          "blocked_ip_ranges": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "IPv4 CIDR blocks refused on **every authenticated request**, not only at the sign-in form. The source is `requestContext.http.sourceIp`, which API Gateway populates from the connection and a client cannot set.\n\n`allowed_countries` was **removed from this record** rather than implemented. The only data source for a country is `CloudFront-Viewer-Country`, which no origin request policy in `infra/` overwrites, so an allowlist built on it would be defeatable with one request header while looking enforced — worse than an absent one, because an auditor would tick the box."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "set": {
            "type": "object",
            "description": "Which blocks were explicitly configured rather than inherited from the product defaults.",
            "properties": {
              "password": {
                "type": "boolean"
              },
              "session": {
                "type": "boolean"
              },
              "mfa": {
                "type": "boolean"
              },
              "blocked_ip_ranges": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "AuthPolicyResponse": {
        "type": "object",
        "required": [
          "policy",
          "configured"
        ],
        "properties": {
          "policy": {
            "$ref": "#/components/schemas/AuthPolicy"
          },
          "configured": {
            "type": "boolean",
            "description": "False when the tenant has never called `PUT`. Never a 404: a miss would be indistinguishable from a cross-tenant id."
          }
        }
      },
      "AuthPolicyUpdate": {
        "type": "object",
        "description": "Any subset of the blocks. Merged onto the **stored** policy, not onto the defaults, so a partial write leaves the blocks it did not mention alone.\n\n`id`, `tenant_id`, `environment` and the timestamps are the server's and are **refused** here — a field that is accepted and discarded is worse than one that is rejected.",
        "additionalProperties": false,
        "properties": {
          "password": {
            "$ref": "#/components/schemas/AuthPolicyPassword"
          },
          "session": {
            "$ref": "#/components/schemas/AuthPolicySession"
          },
          "mfa": {
            "$ref": "#/components/schemas/AuthPolicyMfa"
          },
          "blocked_ip_ranges": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "Feedback": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "object",
          "title",
          "description",
          "status",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^fbk_",
            "description": "Feedback id, e.g. fbk_..."
          },
          "tenant_id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "feedback"
            ]
          },
          "type": {
            "type": "string",
            "enum": [
              "bug",
              "error",
              "feature_request",
              "documentation",
              "question",
              "other"
            ]
          },
          "severity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "maxLength": 10000,
            "description": "Credentials redacted before storage."
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 20
          },
          "context": {
            "type": "object",
            "description": "Allow-listed diagnostics; unknown keys are dropped.",
            "additionalProperties": true
          },
          "attachments": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FeedbackAttachment"
            },
            "maxItems": 5
          },
          "attachment_count": {
            "type": "integer"
          },
          "total_attachment_bytes": {
            "type": "integer"
          },
          "submitted_by": {
            "type": "object",
            "properties": {
              "actor_type": {
                "type": "string"
              },
              "actor_id": {
                "type": "string",
                "nullable": true
              },
              "display": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "status": {
            "type": "string",
            "enum": [
              "new",
              "triaged",
              "in_progress",
              "resolved",
              "wont_fix",
              "closed"
            ]
          },
          "triage_note": {
            "type": "string",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "FeedbackAttachment": {
        "type": "object",
        "required": [
          "attachment_id",
          "kind",
          "filename",
          "content_type",
          "size_bytes",
          "sha256"
        ],
        "properties": {
          "attachment_id": {
            "type": "string"
          },
          "kind": {
            "type": "string",
            "enum": [
              "inline",
              "external"
            ]
          },
          "filename": {
            "type": "string"
          },
          "content_type": {
            "type": "string",
            "description": "Submitter-declared; the stored object is always application/octet-stream."
          },
          "size_bytes": {
            "type": "integer"
          },
          "sha256": {
            "type": "string"
          },
          "s3_bucket": {
            "type": "string",
            "nullable": true
          },
          "s3_key": {
            "type": "string",
            "nullable": true
          },
          "url": {
            "type": "string",
            "nullable": true,
            "description": "Only for external attachments."
          }
        }
      },
      "FeedbackList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "total",
          "count"
        ],
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Feedback"
            }
          },
          "first_id": {
            "type": "string",
            "nullable": true
          },
          "last_id": {
            "type": "string",
            "nullable": true
          },
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "total": {
            "type": "integer"
          },
          "count": {
            "type": "integer"
          }
        }
      },
      "FeedbackCreate": {
        "type": "object",
        "required": [
          "title",
          "description"
        ],
        "properties": {
          "title": {
            "type": "string",
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "minLength": 10,
            "maxLength": 10000
          },
          "type": {
            "type": "string",
            "enum": [
              "bug",
              "error",
              "feature_request",
              "documentation",
              "question",
              "other"
            ]
          },
          "severity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "critical"
            ]
          },
          "tags": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "maxItems": 20
          },
          "context": {
            "type": "object",
            "additionalProperties": true
          },
          "attachments": {
            "type": "array",
            "maxItems": 5,
            "items": {
              "type": "object",
              "properties": {
                "filename": {
                  "type": "string"
                },
                "content_type": {
                  "type": "string"
                },
                "data": {
                  "type": "string",
                  "description": "Base64 file contents."
                },
                "url": {
                  "type": "string",
                  "description": "External artifact URL."
                }
              }
            }
          }
        }
      },
      "FeedbackTriageUpdate": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "new",
              "triaged",
              "in_progress",
              "resolved",
              "wont_fix",
              "closed"
            ]
          },
          "triage_note": {
            "type": "string",
            "maxLength": 2000
          }
        }
      },
      "Role": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "object",
          "name",
          "slug",
          "permissions",
          "is_system",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string",
            "enum": [
              "role"
            ]
          },
          "name": {
            "type": "string"
          },
          "slug": {
            "type": "string"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "permissions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "is_system": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "ResourceServer": {
        "type": "object",
        "required": [
          "id",
          "tenant_id",
          "object",
          "name",
          "identifier",
          "scopes",
          "access_token_ttl_seconds",
          "allow_offline_access",
          "signing_alg",
          "created_at",
          "updated_at"
        ],
        "properties": {
          "id": {
            "$ref": "#/components/schemas/Id"
          },
          "tenant_id": {
            "$ref": "#/components/schemas/Id"
          },
          "object": {
            "type": "string",
            "enum": [
              "resource_server"
            ]
          },
          "name": {
            "type": "string"
          },
          "identifier": {
            "type": "string"
          },
          "scopes": {
            "type": "array",
            "items": {
              "type": "object"
            }
          },
          "access_token_ttl_seconds": {
            "type": "integer"
          },
          "allow_offline_access": {
            "type": "boolean"
          },
          "signing_alg": {
            "type": "string"
          },
          "metadata": {
            "type": "object"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          },
          "deleted_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "PushedAuthorizationResponse": {
        "type": "object",
        "required": [
          "request_uri",
          "expires_in"
        ],
        "properties": {
          "request_uri": {
            "type": "string"
          },
          "expires_in": {
            "type": "integer"
          }
        }
      }
    }
  },
  "x-ulex-conventions": {
    "objectShape": "{ id, object, ...fields }",
    "idFormat": "^[a-z]{3}_[0-9A-HJKMNP-TV-Z]{26}$ (prefixed ULID; lexicographic order is creation order)",
    "errorEnvelope": "components.schemas.ErrorEnvelope",
    "listEnvelope": "{ object: 'list', data, first_id, last_id, has_more, next_cursor }",
    "pagination": "cursor only: limit (1-200, default 20), starting_after, ending_before, order. No offset.",
    "idempotency": "Idempotency-Key header, or idempotency_key on create bodies. 24-hour window, scoped to (method, path, key).",
    "rateLimits": {
      "rest": "1000/min/api key",
      "mcp": "600/min/tenant",
      "token": "30/min/client",
      "scim": "3000/min/bearer token",
      "webhook": "25/s/endpoint"
    },
    "environments": {
      "prod": "ulexid.com"
    },
    "auditChainVerify": "POST /audit-events/verify_chain",
    "mcp": {
      "endpoint": "POST/GET/DELETE /mcp",
      "protocolVersion": "2025-06-18",
      "toolCount": 86,
      "protectedResource": "/.well-known/oauth-protected-resource"
    }
  }
}
