{"openapi":"3.1.0","info":{"title":"Platform Cloud","description":"Tenants, quotas, and Clerk mediator.","version":"0.1.0"},"paths":{"/health":{"get":{"summary":"Health","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}},"/console-config":{"get":{"summary":"Console Config","operationId":"console_config_console_config_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ConsoleConfig"}}}}}}},"/internal/tenants/{tenant_id}/endpoints":{"get":{"tags":["internal-support"],"summary":"Get Tenant Endpoints","operationId":"get_tenant_endpoints_internal_tenants__tenant_id__endpoints_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[A-Za-z0-9_-]+$","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Endpoints Internal Tenants  Tenant Id  Endpoints Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/lookup":{"get":{"tags":["internal-support"],"summary":"Lookup Tenants","description":"Resolve a tenant from a pasted name or slug — backs support-mcp's\n``tenant_resolve`` tool.\n\nSame auth wall as ``/endpoints``: support-mcp's machine sub alone, unset\nfails closed. ``q`` matches ``name`` OR ``slug`` case-insensitively\n(``TenantRepository.list_tenants(search=...)``). ``limit`` is clamped to\n``_LOOKUP_MAX_LIMIT`` so a broad needle can never return the whole fleet.","operationId":"lookup_tenants_internal_tenants_lookup_get","parameters":[{"name":"q","in":"query","required":true,"schema":{"type":"string","minLength":1,"description":"name-or-slug substring","title":"Q"},"description":"name-or-slug substring"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":10,"title":"Limit"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Lookup Tenants Internal Tenants Lookup Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/support-account-summary":{"get":{"tags":["internal-support"],"summary":"Get Support Account Summary","description":"Account status and usage for one tenant — backs support-mcp's\n``get_account_plan_and_usage`` (spec 2026-10-27 §10.1).\n\nSame auth wall as ``/lookup``: support-mcp's machine sub alone. It reads:\nno Stripe call (``include_pending_change=False``) and no cap re-evaluation —\nthe persisted ``tenant_cap_state`` rows are returned as they are, so a\nsupport lookup never writes.\n\n``subscription.status`` is the raw row (plan decision P-3), because the\nentitlement summary reports no subscription at all for a non-active one. It\nis fresh for a lifecycle-active tenant (the cap_eval loop relabels the row\neach tick) and possibly stale for any other. The reads are separate\nstatements, so a webhook landing between them can tear the snapshot (say a\nplan changed after the status was read); that is harmless for a support read.\n\nIf the entitlement summary cannot be built because of an operational failure\n(``_OPERATIONAL_FAILURES``: the database, the network, a timeout, a bad\nconversion-rate row) the route degrades instead of failing: the tenant, the\nrow status and the cap rows are still returned, the billing fields are None\nand ``billing_unavailable`` is true. Anything else, a ``TypeError`` or\n``KeyError`` from our own code, is a bug and propagates as a 500, as\n``entitlement_summary._pending_change_key`` does for its own Stripe read.","operationId":"get_support_account_summary_internal_tenants__tenant_id__support_account_summary_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[A-Za-z0-9_-]+$","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Support Account Summary Internal Tenants  Tenant Id  Support Account Summary Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/blob-objects":{"get":{"tags":["internal-support"],"summary":"List Tenant Blob Objects","description":"List one tenant's stored blob objects — metadata only, credential-free.\n\nBacks support-mcp's ``get_blob_objects`` tool (see\n``support_service.backends.blob_meta``). Same auth wall as the other\n``/internal/tenants/*`` routes: support-mcp's machine sub alone, unset fails\nclosed.\n\nThe tenant is scoped **server-side**: the registry resolves this tenant's\nprovider AND its per-tenant key prefix, and the caller's ``prefix`` is\nappended, so it can only ever narrow within that one tenant's store — it can\nnever escape to another tenant's objects (blob keys are opaque strings; a\n``..`` segment matches nothing because the result still starts with the\ntenant prefix). Only ``size_bytes``/``content_type``/``last_modified`` plus\nthe key are returned; no bytes, no storage key, SAS token or connection\nstring ever leaves this endpoint.","operationId":"list_tenant_blob_objects_internal_tenants__tenant_id__blob_objects_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","maxLength":64,"pattern":"^[A-Za-z0-9_-]+$","title":"Tenant Id"}},{"name":"prefix","in":"query","required":false,"schema":{"type":"string","description":"narrow WITHIN the tenant's own store","default":"","title":"Prefix"},"description":"narrow WITHIN the tenant's own store"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","minimum":1,"default":100,"title":"Limit"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response List Tenant Blob Objects Internal Tenants  Tenant Id  Blob Objects Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants":{"post":{"summary":"Create Tenant","description":"Create a new tenant: Clerk Organization + admin invitation + local row.\n\nSpec C — the admin invitation is sent via Clerk only; we no longer\npersist it in a local ``invitations`` mirror.\n\n``service_auth_secret`` is returned **once** in this response. The\noperator must persist it on the tenant-app before the response is\ndiscarded. Use ``POST /admin/tenants/{id}/rotate-service-auth-secret``\nif the secret is lost.","operationId":"create_tenant_internal_tenants_post","parameters":[{"name":"x-admin-key","in":"header","required":false,"schema":{"type":"string","default":"","title":"X-Admin-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTenantRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__tenants__CreateTenantResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/adopt":{"post":{"summary":"Adopt Tenant","description":"Register an existing Clerk Organization as a tenant.\n\nUnlike :func:`create_tenant` which mints a fresh Clerk org, this adopts an\norg that already exists (e.g. created manually in the Clerk dashboard, or\nbefore the cloud platform was in play).\n\nSpec C — we no longer mirror Clerk memberships into a local\n``tenant_members`` table. The tenant-app reconcile flow (Task 14)\nis the seam that pulls Clerk membership into per-tenant ``users``.","operationId":"adopt_tenant_internal_tenants_adopt_post","parameters":[{"name":"x-admin-key","in":"header","required":false,"schema":{"type":"string","default":"","title":"X-Admin-Key"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdoptTenantRequest"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AdoptTenantResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}":{"get":{"summary":"Get Tenant","operationId":"get_tenant_internal_tenants__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"x-admin-key","in":"header","required":false,"schema":{"type":"string","default":"","title":"X-Admin-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantDetailsResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/webhooks/clerk":{"post":{"summary":"Clerk Webhook","operationId":"clerk_webhook_webhooks_clerk_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Clerk Webhook Webhooks Clerk Post"}}}}}}},"/webhooks/stripe":{"post":{"tags":["webhooks"],"summary":"Stripe Webhook","operationId":"stripe_webhook_webhooks_stripe_post","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Stripe Webhook Webhooks Stripe Post"}}}}}}},"/v1/blobs":{"post":{"tags":["blobs"],"summary":"Upload Blob","description":"Upload bytes; return a blob_ref (always) + a public_url (when access=public).\n\n``access=private`` (default) preserves the existing tenant-scoped flow:\nroutes via tenant_blob_config or BLOB_DEFAULT_*, returns blob_ref only.\n``access=public`` routes to the platform-owned public bucket\n(BLOB_PUBLIC_*), returns blob_ref + public_url.\n\n``category=<c>`` (private flow) keys the object under a lifecycle-scoped\nSUB-prefix of the tenant blob prefix (``{prefix}{category}/{uuid}`` —\nstill ``startswith(prefix)``, so the read/head/delete tenant-scope checks\nkeep passing) and tags it ``lifecycle=<category>`` so shared-bucket\nprovider lifecycle rules can expire it. Today's only caller value is\n``insight_previews`` (tenant-app preview blobs, orphans by design); see\ntenant-app/docs/superpowers/runbooks/insight-preview-blob-lifecycle.md.\n\nPlan 2026-04-30-platform-public-blob-serving Task 6.","operationId":"upload_blob_v1_blobs_post","parameters":[{"name":"access","in":"query","required":false,"schema":{"enum":["private","public"],"type":"string","default":"private","title":"Access"}},{"name":"category","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^[a-z0-9][a-z0-9_-]*$"},{"type":"null"}],"title":"Category"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Upload Blob V1 Blobs Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/blobs/{blob_ref}":{"get":{"tags":["blobs"],"summary":"Download Blob","operationId":"download_blob_v1_blobs__blob_ref__get","parameters":[{"name":"blob_ref","in":"path","required":true,"schema":{"type":"string","title":"Blob Ref"}},{"name":"access","in":"query","required":false,"schema":{"enum":["private","public"],"type":"string","default":"private","title":"Access"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"head":{"tags":["blobs"],"summary":"Head Blob","operationId":"head_blob_v1_blobs__blob_ref__head","parameters":[{"name":"blob_ref","in":"path","required":true,"schema":{"type":"string","title":"Blob Ref"}},{"name":"access","in":"query","required":false,"schema":{"enum":["private","public"],"type":"string","default":"private","title":"Access"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["blobs"],"summary":"Overwrite Blob","description":"Replace the content of an existing blob, preserving its blob_ref.\n\nReturns ``{blob_ref, size_bytes, content_type, updated_at}`` on success.\n404 if the blob doesn't exist (use POST to create a new one).\n413 if the replacement body exceeds the upload cap.\n\nAuth: same bearer-token rules as POST — tenant_id is derived from the\nJWT, not the path, so cross-tenant overwrites are impossible by construction.\n\nPlan 2026-05-10-brand-footer-and-email-validator Task 8.","operationId":"overwrite_blob_v1_blobs__blob_ref__put","parameters":[{"name":"blob_ref","in":"path","required":true,"schema":{"type":"string","title":"Blob Ref"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Overwrite Blob V1 Blobs  Blob Ref  Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["blobs"],"summary":"Delete Blob","description":"Delete a blob. ``access=public`` deletes from the tenant's PUBLIC\nlocation (every uploaded image lives there) — the same resolution and\nthe same tenant-prefix scope check as the read/head routes.","operationId":"delete_blob_v1_blobs__blob_ref__delete","parameters":[{"name":"blob_ref","in":"path","required":true,"schema":{"type":"string","title":"Blob Ref"}},{"name":"access","in":"query","required":false,"schema":{"enum":["private","public"],"type":"string","default":"private","title":"Access"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Blob V1 Blobs  Blob Ref  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/clerk-status":{"get":{"tags":["tenants"],"summary":"Get Clerk Status","description":"Return the Clerk-sourced read-only view of a tenant's org.\n\n404 if ``tenant_id`` is unknown. Result is cached for 60 seconds\nkeyed on ``(tenant_id, clerk_org_id)`` — so an org-id rotation\n(rare, but possible during operator-driven org migration) does not\nserve stale numbers from the prior org for up to 60 seconds.","operationId":"get_clerk_status_api_v1_tenants__tenant_id__clerk_status_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ClerkStatusResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/reconcile-users":{"post":{"tags":["tenants"],"summary":"Reconcile Users","description":"Trigger tenant-app to reconcile its local users table with Clerk.\n\nReturns tenant-app's response shape:\n``{inserted, updated, deactivated, rescinded}``. 404 if ``tenant_id``\nis unknown; 502 if tenant-app returns non-200 or the call fails at\nthe transport level (timeout, connection refused, etc.).","operationId":"reconcile_users_api_v1_tenants__tenant_id__reconcile_users_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Reconcile Users Api V1 Tenants  Tenant Id  Reconcile Users Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/clerk/invitations":{"post":{"tags":["clerk-proxy"],"summary":"Create Invitation","description":"Proxy: create org-scoped Clerk invitation.\n\nTenant-app calls this; cloud holds the Clerk Backend API secret and\nmakes the actual upstream request.  The Clerk org_id comes from the\ntenant row — callers cannot override it.","operationId":"create_invitation_api_v1_tenants__tenant_id__clerk_invitations_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/InviteIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["clerk-proxy"],"summary":"List Invitations","description":"Proxy: list org-scoped Clerk invitations (reconcile read).\n\nThe ``status`` query parameter is forwarded to Clerk (default: ``pending``).\nGated by :func:`require_org_member` — any authenticated tenant user may\nread.  The org_id comes from the tenant row; callers cannot target a\ndifferent org.","operationId":"list_invitations_api_v1_tenants__tenant_id__clerk_invitations_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"status","in":"query","required":false,"schema":{"type":"string","default":"pending","title":"Status"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/clerk/invitations/{invitation_id}/revoke":{"post":{"tags":["clerk-proxy"],"summary":"Revoke Invitation Route","description":"Proxy: revoke an org-scoped Clerk invitation.\n\n``requesting_user_id`` is populated from the caller's JWT sub so\nClerk audit logs show who initiated the revocation.","operationId":"revoke_invitation_route_api_v1_tenants__tenant_id__clerk_invitations__invitation_id__revoke_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"invitation_id","in":"path","required":true,"schema":{"type":"string","title":"Invitation Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/clerk/memberships":{"post":{"tags":["clerk-proxy"],"summary":"Add Membership","description":"Proxy: add a user to the Clerk org.\n\nThe org_id is taken from the tenant row — callers cannot override it.\n``user_id`` is the Clerk user sub (``user_<hex>``).","operationId":"add_membership_api_v1_tenants__tenant_id__clerk_memberships_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddMembershipIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["clerk-proxy"],"summary":"List Memberships","description":"Proxy: list all memberships for the Clerk org (reconcile read).\n\nGated by :func:`require_org_member` — any authenticated tenant user may\nread.  The org_id comes from the tenant row; callers cannot target a\ndifferent org.","operationId":"list_memberships_api_v1_tenants__tenant_id__clerk_memberships_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/api/v1/tenants/{tenant_id}/clerk/memberships/{user_id}":{"delete":{"tags":["clerk-proxy"],"summary":"Delete Membership","description":"Proxy: remove a user from the Clerk org.\n\n``user_id`` is the Clerk user sub (``user_<hex>``).  The org_id comes\nfrom the tenant row — callers cannot target a different org.","operationId":"delete_membership_api_v1_tenants__tenant_id__clerk_memberships__user_id__delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"user_id","in":"path","required":true,"schema":{"type":"string","title":"User Id"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["clerk-proxy"],"summary":"Patch Membership Role Route","description":"Proxy: update a user's role in the Clerk org.\n\n``user_id`` is the Clerk user sub (``user_<hex>``).  The org_id comes\nfrom the tenant row — callers cannot target a different org.","operationId":"patch_membership_role_route_api_v1_tenants__tenant_id__clerk_memberships__user_id__patch","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"user_id","in":"path","required":true,"schema":{"type":"string","title":"User Id"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchMembershipRoleIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/subscriptions":{"get":{"tags":["admin"],"summary":"List Subscriptions","operationId":"list_subscriptions_admin_tenants_subscriptions_get","parameters":[{"name":"order","in":"query","required":false,"schema":{"type":"string","default":"asc","title":"Order"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Search"}},{"name":"include_deleted","in":"query","required":false,"schema":{"type":"boolean","description":"Include subscriptions of soft-deleted (status='deleted') tenants","default":false,"title":"Include Deleted"},"description":"Include subscriptions of soft-deleted (status='deleted') tenants"},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionListOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/subscription":{"post":{"tags":["admin"],"summary":"Create Subscription","operationId":"create_subscription_admin_tenants__tenant_id__subscription_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionIn"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["admin"],"summary":"Get Subscription","operationId":"get_subscription_admin_tenants__tenant_id__subscription_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin"],"summary":"Patch Subscription","operationId":"patch_subscription_admin_tenants__tenant_id__subscription_patch","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PatchSubscriptionIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/subscription/extend":{"post":{"tags":["admin"],"summary":"Extend Subscription","description":"Give a tenant time until ``works_through`` (its last working day). WHAT moves is decided by\n`subscription_term.extend_kind`, never by the console: a trial's end, a managed tenant's period\nend (+ its auto-renew count), or a failed-payment Stripe tenant's grace deadline.","operationId":"extend_subscription_admin_tenants__tenant_id__subscription_extend_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtendIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionListItem"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/subscription/cancel":{"post":{"tags":["admin"],"summary":"Cancel Subscription","description":"The operator's \"Cancel subscription\" (spec 2026-10-07 §E, \"a bug fixed in the same change\").\n\n**It used to be a local status flip and nothing else** (`SubscriptionRepo.cancel`): entitlement\nstopped and the customer kept being charged. It now reaches Stripe first, and by three rules\nthat follow from who owns the status:\n\n- **A tenant WITH a Stripe subscription** is cancelled at Stripe, at the end of the period\n  already paid for — the PLAN item's, never the earliest item's — through\n  `mutations.operator_cancel`: the customer's mechanism without the question of who may ask,\n  since comped, custom-priced and invoiced accounts are what an operator cancels on someone's\n  behalf. Nothing local is written unless Stripe agreed; a refusal or an outage is the status\n  it deserves and never a quiet fall-back to a local flip, which is the bug again.\n- **A Stripe-BILLED row's status is left alone** (`billing_mode == \"stripe\"`). Its only writer\n  is the sync, which converges it from Stripe, and Stripe says 'active' until the paid period\n  ends: a local 'canceled' would be undone by the `customer.subscription.updated` our own write\n  sends, after blocking the tenant's metered capabilities for as long as that takes. This is\n  the rule `api/admin/billing.py` states for its collection switch — write THROUGH to Stripe\n  and let the webhook be the one writer of record. The entitlement ends with the period, when\n  the subscription does and the customer stops paying; for an immediate block the operator's\n  tool is Pause. A row the OPERATOR owns (`comped`, or a trial) keeps the local flip, after\n  Stripe has agreed, because `map_billing_to_entitlement` never overwrites it.\n- **A tenant with NO Stripe subscription keeps today's local-only behaviour, exactly**: the\n  status flips and the caps are re-evaluated at once. A trial or comped tenant has no Stripe\n  object, so there is nothing at Stripe to cancel and nothing being charged, and this writes no\n  audit row, as it never did.\n\nWhichever of the three it was, the customer's cached entitlement summary is evicted once the\ntransaction commits (`bust_entitlement_summary_after_commit`), as the customer's own cancel\ndoes, so the Usage tab does not keep showing the old state for up to 45 seconds.","operationId":"cancel_subscription_admin_tenants__tenant_id__subscription_cancel_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/quota-addons":{"post":{"tags":["admin"],"summary":"Add Quota Addon","operationId":"add_quota_addon_admin_tenants__tenant_id__quota_addons_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonIn"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["admin"],"summary":"List Quota Addons","operationId":"list_quota_addons_admin_tenants__tenant_id__quota_addons_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonsListOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/quota-addons/{addon_id}":{"delete":{"tags":["admin"],"summary":"Delete Quota Addon","operationId":"delete_quota_addon_admin_tenants__tenant_id__quota_addons__addon_id__delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"addon_id","in":"path","required":true,"schema":{"type":"integer","title":"Addon Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/credit-grants":{"post":{"tags":["admin"],"summary":"Grant Credits","operationId":"grant_credits_admin_tenants__tenant_id__credit_grants_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditGrantIn"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditGrantOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/credit-balance":{"get":{"tags":["admin"],"summary":"Get Credit Balance","operationId":"get_credit_balance_admin_tenants__tenant_id__credit_balance_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreditBalanceOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants":{"get":{"tags":["admin"],"summary":"List Tenants","description":"List tenants with optional name-substring search and pagination.\n\nSoft-deleted tenants are excluded by default (see\nTenantRepository.list_tenants) — pass include_deleted=true to see them.","operationId":"list_tenants_admin_tenants_get","parameters":[{"name":"search","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"description":"Substring match on tenant.name","title":"Search"},"description":"Substring match on tenant.name"},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Limit"}},{"name":"offset","in":"query","required":false,"schema":{"type":"integer","minimum":0,"default":0,"title":"Offset"}},{"name":"include_deleted","in":"query","required":false,"schema":{"type":"boolean","description":"Include soft-deleted (status='deleted') tenants","default":false,"title":"Include Deleted"},"description":"Include soft-deleted (status='deleted') tenants"},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantsListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["admin-tenant-lifecycle"],"summary":"Create Tenant Lifecycle","operationId":"create_tenant_lifecycle_admin_tenants_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTenantBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__admin__tenant_lifecycle__CreateTenantResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}":{"get":{"tags":["admin"],"summary":"Get Tenant Detail","description":"Detail view: tenant fields + 30-day usage.\n\nDeliberately does NOT 404 for a soft-deleted tenant (status='deleted')\n— an operator following an audit trail or the delete confirmation flow\nitself needs to still load this page. ``status`` is returned as-is so\nthe console can badge it distinctly instead.","operationId":"get_tenant_detail_admin_tenants__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantDetail"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin-tenant-lifecycle"],"summary":"Rename Tenant","description":"Rename a tenant — the display name only, in BOTH places it lives.\n\n`tenants.name` is what the console shows; the Clerk organisation's name is\nwhat the tenant-app's workspace switcher shows. Updating one without the\nother leaves an operator looking at a different name from their users, so\nthis writes the row inside a transaction, calls Clerk, and commits only if\nClerk accepted — a Clerk failure changes nothing.\n\nThe SLUG is deliberately immutable: the tenant's URL, its `tenantapp_<slug>`\ndatabase, its `local-tenant-<slug>` container and its blob containers are\nall keyed on it, so changing it is a migration rather than an edit.\n\nAllowed in any tenant status: the name has no operational coupling, and a\ntypo is most often caught while the tenant is still provisioning.","operationId":"rename_tenant_admin_tenants__tenant_id__patch","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RenameTenantBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RenameTenantResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/rotate-service-auth-secret":{"post":{"tags":["admin"],"summary":"Rotate Service Auth Secret","description":"Rotate the HMAC secret used by the tenant-app to authenticate\nrequests to the platform-cloud reconcile path.\n\nReturns the new secret. The caller must persist it on the tenant-app\nimmediately; it cannot be recovered after this response.\n\nReturns 404 if the tenant does not exist.","operationId":"rotate_service_auth_secret_admin_tenants__tenant_id__rotate_service_auth_secret_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RotateServiceAuthSecretResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/usage/global":{"get":{"tags":["admin"],"summary":"Get Global Usage","description":"Aggregate platform-wide activity for the last 24 hours from the usage rollups.","operationId":"get_global_usage_admin_usage_global_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GlobalUsage"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/usage/aggregate-series":{"get":{"tags":["admin"],"summary":"Get Aggregate Series","description":"All-tenant monthly series (last 12 months) for the key usage indicators.\n\nDrives the global console tiles + per-indicator charts. Counters sum per\nmonth; gauges (storage) take each tenant's month-end value, summed.","operationId":"get_aggregate_series_admin_usage_aggregate_series_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AggregateUsage"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/usage/ingest-status":{"get":{"tags":["admin"],"summary":"Get Ingest Status","description":"Per-source ingest poller liveness (cursor + last advance time).\n\nReads ``usage_ingest_cursor`` (sendgrid / twilio / litellm_spendlogs). A\nsource whose ``updated_at`` is older than ~15 min is flagged ``stale`` so\noperators can spot a wedged poller.","operationId":"get_ingest_status_admin_usage_ingest_status_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/IngestPollerStatus"},"title":"Response Get Ingest Status Admin Usage Ingest Status Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/demo-partners":{"get":{"tags":["admin"],"summary":"List Partners","operationId":"list_partners_admin_demo_partners_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnersListOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["admin"],"summary":"Create Partner","operationId":"create_partner_admin_demo_partners_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerSecretOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/demo-partners/{partner_id}":{"get":{"tags":["admin"],"summary":"Get Partner","operationId":"get_partner_admin_demo_partners__partner_id__get","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerDetailOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/demo-partners/{partner_id}/reissue":{"post":{"tags":["admin"],"summary":"Reissue","operationId":"reissue_admin_demo_partners__partner_id__reissue_post","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PartnerSecretOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/demo-partners/{partner_id}/revoke":{"post":{"tags":["admin"],"summary":"Revoke","operationId":"revoke_admin_demo_partners__partner_id__revoke_post","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/demo-partners/{partner_id}/restore":{"post":{"tags":["admin"],"summary":"Restore","operationId":"restore_admin_demo_partners__partner_id__restore_post","parameters":[{"name":"partner_id","in":"path","required":true,"schema":{"type":"string","title":"Partner Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OkOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/services":{"get":{"tags":["admin"],"summary":"List Services","description":"Read the in-memory health-checker cache.\n\nThe cache is populated by the background poller (``health_checker.run_forever``).\nUntil the poller has run at least once after boot, this returns an\nempty list — the UI handles that as \"no recent data\" rather than\ntreating it as all-services-down.","operationId":"list_services_admin_services_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/ServiceStatus"},"title":"Response List Services Admin Services Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/quotas":{"get":{"tags":["admin"],"summary":"Get Quotas","operationId":"get_quotas_admin_quotas_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuotaReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/quotas/refresh":{"post":{"tags":["admin"],"summary":"Refresh Quotas","description":"Collect live, persist a new capture batch, and return it.","operationId":"refresh_quotas_admin_quotas_refresh_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/QuotaReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/quotas/send-to-slack":{"post":{"tags":["admin"],"summary":"Send Quotas To Slack","description":"Post the current quota report to Slack on demand (console button).\n\nSends the same data the page shows: the latest stored snapshot, or a live\ncollect when none exists yet. ``sent=False`` (not an error) when the Slack\nwebhook is unset or the post fails — the operator sees why in ``detail``.","operationId":"send_quotas_to_slack_admin_quotas_send_to_slack_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__admin__quotas__SlackSendResult"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/health":{"get":{"tags":["admin"],"summary":"Get Health","operationId":"get_health_admin_health_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/health/refresh":{"post":{"tags":["admin"],"summary":"Refresh Health","operationId":"refresh_health_admin_health_refresh_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HealthReport"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/health/send-to-slack":{"post":{"tags":["admin"],"summary":"Send Health To Slack","operationId":"send_health_to_slack_admin_health_send_to_slack_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__admin__health__SlackSendResult"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/blob-config":{"get":{"tags":["admin"],"summary":"Get Blob Config","description":"Read the effective blob config for a tenant.","operationId":"get_blob_config_admin_tenants__tenant_id__blob_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlobConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin"],"summary":"Put Blob Config","description":"Upsert a per-tenant override row — after PROVING the locations exist.\n\nA typo'd bucket name used to be accepted happily and only exploded at\nthe first public upload with ``ContainerNotFound``. Before writing\nanything, this now calls the same :func:`ensure_tenant_storage` seam\n``BlobStep`` uses at tenant-create, so a bad config is rejected here\ninstead of at the first request that needs it.","operationId":"put_blob_config_admin_tenants__tenant_id__blob_config_put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlobConfigIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/BlobConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin"],"summary":"Delete Blob Config","description":"Remove the override row → tenant reverts to platform defaults.\n\nNOTE (deliberately unchanged by the Task 6 provisioning work above):\nfor an azure-default deployment, ``registry.get_public_provider()``\nraises ``PublicBucketNotConfigured`` — azure has no shared public\nfallback, only the per-tenant ``public_bucket`` this endpoint manages.\nSo on an azure deployment, DELETE can silently strip a tenant's ONLY\nworking public location, and the next public upload/read fails closed\nwith no override left to fix via PUT alone (a fresh PUT would still\nwork — it re-provisions — but between DELETE and that PUT the tenant\nhas no public storage at all). This endpoint does not warn or refuse;\nsee the Task 6 report for the reasoning on why that was left as-is\nrather than changed here.","operationId":"delete_blob_config_admin_tenants__tenant_id__blob_config_delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config":{"get":{"tags":["admin-email"],"summary":"Get Email Config","operationId":"get_email_config_admin_tenants__tenant_id__email_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin-email"],"summary":"Patch Email Config","description":"Partial update of throttle policy (Plan 25 Task 5).\n\n- Field omitted: unchanged.\n- Field present with int >= 1: set explicit value.\n- Field present with null: clear (revert to inherited default).\n- Field present with 0 / negative / non-int: 422.\n- Unknown fields: 422.","operationId":"patch_email_config_admin_tenants__tenant_id__email_config_patch","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Payload"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/email-config/byo/missing-stats-scope":{"get":{"tags":["admin-email"],"summary":"Get Byo Missing Stats Scope","description":"Admin: BYO email tenants that cannot be metered (no stats.read scope).\n\nFleet-wide list (no tenant_id path segment). These tenants connected\nbefore stats.read became required (or had it revoked), so the platform\ncan't meter their email usage; ops asks them to re-grant the scope.","operationId":"get_byo_missing_stats_scope_admin_tenants_email_config_byo_missing_stats_scope_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Byo Missing Stats Scope Admin Tenants Email Config Byo Missing Stats Scope Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/reprovision":{"post":{"tags":["admin-email"],"summary":"Reprovision","description":"Re-run provisioning end-to-end. Idempotent + recoverable.","operationId":"reprovision_admin_tenants__tenant_id__email_config_reprovision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/trial-domain/retry":{"post":{"tags":["admin-email"],"summary":"Retry Trial Domain","description":"Re-run trial-domain provisioning (idempotent; spec §5.2).","operationId":"retry_trial_domain_admin_tenants__tenant_id__email_config_trial_domain_retry_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/trial-domain/health":{"get":{"tags":["admin-email"],"summary":"Trial Domain Health","description":"Live, read-only truth about this tenant's trial sending domain.\n\nSpec 2026-11-01 §5.1/§5.6. On demand only — the console fires it from a\nbutton, never on page load, because it costs a SendGrid read plus two\nlookups per DNS record.\n\nOperator-only: the details can quote Azure and SendGrid error bodies, so\nthis never joins ``/internal/email-config``.","operationId":"trial_domain_health_admin_tenants__tenant_id__email_config_trial_domain_health_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Trial Domain Health Admin Tenants  Tenant Id  Email Config Trial Domain Health Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/trial-domain/reprovision":{"post":{"tags":["admin-email"],"summary":"Force Reprovision Trial Domain","description":"Re-provision even when we believe the domain is verified (spec §5.5).\n\nThe repair path ``retry`` cannot take: ``provision_trial_domain`` returns\nearly on a verified row, which is exactly the row a broken-but-verified\ndomain presents. Idempotent — SendGrid reuses the authenticated record and\nthe Azure writes are PUTs — so forcing a healthy domain is a safe no-op.","operationId":"force_reprovision_trial_domain_admin_tenants__tenant_id__email_config_trial_domain_reprovision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/remint-send-key":{"post":{"tags":["admin-email"],"summary":"Remint Send Key","description":"Mint (or rotate) the tenant's subuser-scoped SEND API key.\n\nRecovery path for rows whose provisioning-time mint failed, and the\nrotation tool. SendGrid allows multiple keys per subuser, so minting a\nnew key never breaks in-flight sends; the MCP picks up the new bundle\nwhen its 5-minute credential cache lapses (or immediately on the next\ncold resolve — the platform-side config cache is invalidated here).","operationId":"remint_send_key_admin_tenants__tenant_id__email_config_remint_send_key_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/disable":{"post":{"tags":["admin-email"],"summary":"Disable","description":"Soft-disable: tenant cannot send, subuser still exists at SendGrid.","operationId":"disable_admin_tenants__tenant_id__email_config_disable_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/enable":{"post":{"tags":["admin-email"],"summary":"Enable","description":"Re-enable a previously-disabled tenant. Revoked tenants must reprovision.","operationId":"enable_admin_tenants__tenant_id__email_config_enable_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/revoke":{"post":{"tags":["admin-email"],"summary":"Revoke","description":"Hard-revoke: delete subuser at SendGrid + flip status to 'revoked'.","operationId":"revoke_admin_tenants__tenant_id__email_config_revoke_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/EmailConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/byo":{"post":{"tags":["admin-email"],"summary":"Post Byo","description":"Save a tenant's BYO SendGrid key.\n\nReturns ``{mode, scope_status, signing_status}`` mirroring the spec's\nbadge UI: ``scope_status`` is always ``\"ok\"`` on a 200 (we raise\nScopeValidationError → 400 otherwise); ``signing_status`` is\n``\"enabled\"`` when SendGrid returned a pubkey and ``\"not_configured\"``\nwhen signing is off / the BYO key lacked the read scope.","operationId":"post_byo_admin_tenants__tenant_id__email_config_byo_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/_ByoBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Byo Admin Tenants  Tenant Id  Email Config Byo Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/switch-mode":{"post":{"tags":["admin-email"],"summary":"Post Switch Mode","description":"Flip a tenant between 'managed' and 'byo' modes.\n\nErrors:\n    * 400 — ack=false, missing api_key for target='byo', unknown\n      target, or scope validation failure.\n    * 409 — there are scheduled emails pending; switching now would\n      orphan them on the wrong sender. Detail carries the count.\n    * 503 — the tenant-app precondition endpoint is unreachable or\n      unconfigured; we cannot prove the switch is safe. Fail-closed.","operationId":"post_switch_mode_admin_tenants__tenant_id__email_config_switch_mode_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__admin__email_config___SwitchModeBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Switch Mode Admin Tenants  Tenant Id  Email Config Switch Mode Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/byo-domains":{"get":{"tags":["admin-email"],"summary":"Get Byo Domains","description":"List the BYO account's authenticated sending domains.\n\nPlan 2026-05-03 Task 15 — feeds the \"Sending domain status badges\"\nblock in the console BYO panel. Decrypts the stored key, calls\nSendGrid's ``/v3/whitelabel/domains``, and surfaces the list. Empty\nlist when the BYO key lacks the ``whitelabel.read`` scope (the helper\nswallows the 403 — the badge UI then shows \"scope not granted\").","operationId":"get_byo_domains_admin_tenants__tenant_id__email_config_byo_domains_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Byo Domains Admin Tenants  Tenant Id  Email Config Byo Domains Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/refresh-signing-pubkey":{"post":{"tags":["admin-email"],"summary":"Post Refresh Signing Pubkey","description":"Re-fetch and persist the SendGrid signed-webhook pubkey.\n\nDecrypts the stored BYO key via :mod:`platform_crypto`, calls\nSendGrid, and UPDATEs ``byo_webhook_pubkey``. Used after the\noperator rotates webhook signing on the SendGrid side; without a\nrefresh, signature verification on incoming webhooks would start\nfailing silently.","operationId":"post_refresh_signing_pubkey_admin_tenants__tenant_id__email_config_refresh_signing_pubkey_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Refresh Signing Pubkey Admin Tenants  Tenant Id  Email Config Refresh Signing Pubkey Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/email-config/setup-byo-webhook":{"post":{"tags":["admin-email"],"summary":"Post Setup Byo Webhook","description":"Push the per-tenant Event Webhook URL into the BYO SendGrid account.\n\nStreamlines onboarding: rather than asking the customer to copy the\nURL into their SendGrid dashboard manually, the operator can click\na button and we PATCH ``/v3/user/webhooks/event/settings`` on the\ncustomer's account directly using the BYO key on file.\n\nBehaviour:\n    * 400 if the tenant is not in BYO mode (the managed-mode webhook\n      is global; nothing to set per-tenant).\n    * 400 if no BYO key ciphertext is on record.\n    * 400 (with SendGrid's body) if the upstream PATCH fails — the\n      most common cause is the BYO key lacking\n      ``user.webhooks.event.settings.update``.\n    * 200 ``{webhook_url, status: \"configured\"}`` on success.","operationId":"post_setup_byo_webhook_admin_tenants__tenant_id__email_config_setup_byo_webhook_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Setup Byo Webhook Admin Tenants  Tenant Id  Email Config Setup Byo Webhook Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/sending-ips":{"get":{"tags":["admin-sending-ips"],"summary":"Get Sending Ips","operationId":"get_sending_ips_admin_sending_ips_get","parameters":[{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Refresh"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Sending Ips Admin Sending Ips Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sending-ips":{"get":{"tags":["admin-sending-ips"],"summary":"Get Tenant Sending Ips","operationId":"get_tenant_sending_ips_admin_tenants__tenant_id__sending_ips_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"refresh","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Refresh"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Sending Ips Admin Tenants  Tenant Id  Sending Ips Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin-sending-ips"],"summary":"Put Tenant Sending Ips","operationId":"put_tenant_sending_ips_admin_tenants__tenant_id__sending_ips_put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MoveIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Put Tenant Sending Ips Admin Tenants  Tenant Id  Sending Ips Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/trial-domains/not-ready":{"get":{"tags":["admin-sending-ips"],"summary":"Get Trial Domains Not Ready","description":"Managed tenants whose trial sending domain is not verified yet (failed,\nin flight, or never started) — the operator's fleet-wide stuck list.","operationId":"get_trial_domains_not_ready_admin_trial_domains_not_ready_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Trial Domains Not Ready Admin Trial Domains Not Ready Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/m2m-credentials":{"get":{"tags":["admin-tenant-credentials"],"summary":"Get Credentials","description":"Decrypt and return the tenant's current Clerk M2M machine credentials.\n\n404s on either of two missing-state cases:\n    * The tenant row does not exist.\n    * The tenant exists but provisioning has not populated the\n      ``clerk_machine_id`` / ``machine_secret_*`` columns yet.\n\nBoth cases collapse to the same status code -- the operator console\ntreats them the same (\"credentials are not available; trigger\nprovisioning\"). The detail string distinguishes them for the audit log.","operationId":"get_credentials_admin_tenants__tenant_id__m2m_credentials_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/M2MCredentialsOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/deployment-config":{"post":{"tags":["admin-tenant-credentials"],"summary":"Set Deployment Config","description":"Persist the tenant's deployment-kind + on-prem URL.\n\nThe kind enum mirrors the CHECK constraint added in migration 0006\n(``managed`` | ``on_prem``); we re-validate here to surface a 400\nrather than a 500 on a constraint violation. ``url`` is stored\nverbatim -- normalisation (rstrip slashes, scheme check) happens at\ncall sites that build URLs against it.","operationId":"set_deployment_config_admin_tenants__tenant_id__deployment_config_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeploymentConfigIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Deployment Config Admin Tenants  Tenant Id  Deployment Config Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/deployment-config/test-connection":{"post":{"tags":["admin-tenant-credentials"],"summary":"Test Connection","description":"Probe that platform-cloud can reach this tenant's tenant-app via M2M.\n\nIssues a real M2M-authenticated GET against an existing well-known\ninternal endpoint (``/internal/emails/scheduled-count``) so the test\nexercises both the network path AND the credential. Surfaces the\nHTTP status code + (truncated) response body verbatim on failure --\noperators need that to distinguish \"wrong URL\" from \"wrong\ncredential\" from \"tenant-app down\".\n\nNOTE: depends on ``platform_cloud.clerk_outbound``. If that module\nisn't wired yet, returns a placeholder error rather than 500'ing --\nthe console can still render the rest of the page.","operationId":"test_connection_admin_tenants__tenant_id__deployment_config_test_connection_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/_TestConnectionResult"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/m2m-credentials/force-reissue":{"post":{"tags":["admin-tenant-credentials"],"summary":"Force Reissue","description":"Create-before-delete + verify + push a fresh Clerk M2M credential.\n\nSpec 2026-05-05 §5, revised: the old delete-then-recreate flow used a\ndeterministic Clerk machine name (``tenant:{tenant_id}``), so a *second*\nreissue always 422'd (\"name is taken\") and a failed recreate left the\ntenant with zero machine. ``issue_credential_for_tenant(rotate=True)``\nfixes both: it creates the new machine under a unique name, verifies it\nmints a valid token, persists it, pushes to the running tenant-app, and\nonly then deletes the old machine -- so reissue is idempotent (safe to\ncall any number of times in a row) and never strands the tenant.\n\nReturns ``ForceReissueOut`` with the freshly-minted credentials AND\nthe push outcome, so the operator console can surface a \"push failed,\nsecret here for manual hand-off\" UI when needed.","operationId":"force_reissue_admin_tenants__tenant_id__m2m_credentials_force_reissue_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ForceReissueOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config":{"get":{"tags":["admin-nats"],"summary":"Get Nats Config","operationId":"get_nats_config_admin_tenants__tenant_id__nats_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NatsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/live":{"get":{"tags":["admin-nats"],"summary":"Get Nats Config Live","operationId":"get_nats_config_live_admin_tenants__tenant_id__nats_config_live_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/NatsConfigLiveOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/streams/{stream_name}":{"put":{"tags":["admin-nats"],"summary":"Update Stream Config","operationId":"update_stream_config_admin_tenants__tenant_id__nats_config_streams__stream_name__put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"stream_name","in":"path","required":true,"schema":{"type":"string","title":"Stream Name"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpdateStreamIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/StreamOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/streams/{stream_name}/purge":{"post":{"tags":["admin-nats"],"summary":"Purge Stream Endpoint","operationId":"purge_stream_endpoint_admin_tenants__tenant_id__nats_config_streams__stream_name__purge_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"stream_name","in":"path","required":true,"schema":{"type":"string","title":"Stream Name"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PurgeOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/reprovision":{"post":{"tags":["admin-nats"],"summary":"Reprovision Account","operationId":"reprovision_account_admin_tenants__tenant_id__nats_config_reprovision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReprovisionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/provision":{"post":{"tags":["admin-nats"],"summary":"Provision Account","description":"Provision (or re-provision) the tenant's NATS account.\n\nIdempotent. Distinct from ``reprovision`` only in that it tolerates\nthe no-row case — designed for disaster recovery where the\n``tenant_nats_config`` row was wiped (or never existed for tenants\npre-dating the NATS rollout).\n\nWhen a row exists and is ``active``, this behaves like\n``reprovision``: messages on the existing streams are lost. The\nresponse carries ``created=false`` and ``messages_lost`` (or null\nif the NATS sys-client is unreachable) so the console can warn\nappropriately.\n\nRequires the tenant itself to exist (``tenants`` row). Returns 404\nonly when the tenant is unknown — the empty ``tenant_nats_config``\ncase is the whole point of this endpoint and is NOT a 404.","operationId":"provision_account_admin_tenants__tenant_id__nats_config_provision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProvisionOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/nats-config/remint-credentials":{"post":{"tags":["admin-nats"],"summary":"Remint Credentials","description":"Non-destructively re-mint the tenant's subscriber JWT with the current\npolicy, then push a cache-invalidate to tenant-app. Distinct from\n``reprovision`` (which mints a NEW account and loses messages).","operationId":"remint_credentials_admin_tenants__tenant_id__nats_config_remint_credentials_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemintOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/nats-config/drift":{"get":{"tags":["admin-nats"],"summary":"Nats Credential Drift","operationId":"nats_credential_drift_admin_nats_config_drift_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DriftSummary"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config":{"get":{"tags":["admin-sms"],"summary":"Get Sms Config","operationId":"get_sms_config_admin_tenants__tenant_id__sms_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin-sms"],"summary":"Patch Throttle","operationId":"patch_throttle_admin_tenants__tenant_id__sms_config_patch","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/_ThrottlePatch"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/provision":{"post":{"tags":["admin-sms"],"summary":"Provision Sms Endpoint","operationId":"provision_sms_endpoint_admin_tenants__tenant_id__sms_config_provision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/reprovision":{"post":{"tags":["admin-sms"],"summary":"Reprovision Sms","description":"Re-create the Twilio subaccount + messaging service.","operationId":"reprovision_sms_admin_tenants__tenant_id__sms_config_reprovision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/disable":{"post":{"tags":["admin-sms"],"summary":"Disable Sms","operationId":"disable_sms_admin_tenants__tenant_id__sms_config_disable_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/enable":{"post":{"tags":["admin-sms"],"summary":"Enable Sms","operationId":"enable_sms_admin_tenants__tenant_id__sms_config_enable_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/revoke":{"post":{"tags":["admin-sms"],"summary":"Revoke Sms","operationId":"revoke_sms_admin_tenants__tenant_id__sms_config_revoke_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-config/switch-mode":{"post":{"tags":["admin-sms"],"summary":"Post Switch Mode","operationId":"post_switch_mode_admin_tenants__tenant_id__sms_config_switch_mode_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/platform_cloud__api__admin__sms_config___SwitchModeBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SmsConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms-compliance-bundles":{"get":{"tags":["admin-sms"],"summary":"List Compliance Bundles","operationId":"list_compliance_bundles_admin_tenants__tenant_id__sms_compliance_bundles_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","additionalProperties":true},"title":"Response List Compliance Bundles Admin Tenants  Tenant Id  Sms Compliance Bundles Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms/numbers":{"get":{"tags":["admin-sms-numbers"],"summary":"List Sms Numbers","description":"List a tenant's SMS numbers: ``{\"numbers\": [...], \"limit\": N}``.","operationId":"list_sms_numbers_admin_tenants__tenant_id__sms_numbers_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response List Sms Numbers Admin Tenants  Tenant Id  Sms Numbers Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms/numbers/release-all":{"post":{"tags":["admin-sms-numbers"],"summary":"Release All Sms Numbers","description":"Release every SMS number on a tenant: ``{\"released\": [...], \"failed\": [...]}``.","operationId":"release_all_sms_numbers_admin_tenants__tenant_id__sms_numbers_release_all_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Release All Sms Numbers Admin Tenants  Tenant Id  Sms Numbers Release All Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/sms/numbers/{phone}/release":{"post":{"tags":["admin-sms-numbers"],"summary":"Release Sms Number","description":"Release a single SMS number on a tenant.","operationId":"release_sms_number_admin_tenants__tenant_id__sms_numbers__phone__release_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"phone","in":"path","required":true,"schema":{"type":"string","title":"Phone"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Release Sms Number Admin Tenants  Tenant Id  Sms Numbers  Phone  Release Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/langfuse-config":{"post":{"tags":["admin-langfuse"],"summary":"Post Langfuse Config","description":"Register or replace/rotate the per-tenant Langfuse project key.\n\nIdempotent; each successful call bumps ``key_version``.\nThe secret is envelope-encrypted before storage and is NEVER returned.","operationId":"post_langfuse_config_admin_tenants__tenant_id__langfuse_config_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/_PostBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Post Langfuse Config Admin Tenants  Tenant Id  Langfuse Config Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["admin-langfuse"],"summary":"Get Langfuse Config","description":"Return the active Langfuse config for a tenant (no secret).","operationId":"get_langfuse_config_admin_tenants__tenant_id__langfuse_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Langfuse Config Admin Tenants  Tenant Id  Langfuse Config Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin-langfuse"],"summary":"Delete Langfuse Config","description":"Soft-disable the tenant's Langfuse config. The row is never hard-deleted.","operationId":"delete_langfuse_config_admin_tenants__tenant_id__langfuse_config_delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Langfuse Config Admin Tenants  Tenant Id  Langfuse Config Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/langfuse-config/connection":{"get":{"tags":["admin-langfuse"],"summary":"Get Langfuse Connection","description":"Probe the tenant-app's running Langfuse key_version vs the stored one.\n\nReturns:\n    stored_key_version: int | None — from the active repo row, or None if\n        no active config exists.\n    running_key_version: int | None — from the live tenant-app process via\n        ``probe_running_version``.\n    reachable: bool — False when the probe raised (network error, non-200,\n        missing deployment_url, etc.).\n    restart_pending: bool — True when reachable, both versions are known,\n        and running != stored (tenant-app has not picked up the new key yet).","operationId":"get_langfuse_connection_admin_tenants__tenant_id__langfuse_config_connection_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Langfuse Connection Admin Tenants  Tenant Id  Langfuse Config Connection Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/tenants/{tenant_id}/suspend":{"post":{"tags":["admin-model-config"],"summary":"Suspend Tenant","description":"Suspend a tenant: block its virtual LLM key and mark state='suspended'.","operationId":"suspend_tenant_internal_admin_tenants__tenant_id__suspend_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SuspendBody","default":{}}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Suspend Tenant Internal Admin Tenants  Tenant Id  Suspend Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/tenants/{tenant_id}/resume":{"post":{"tags":["admin-model-config"],"summary":"Resume Tenant","description":"Resume a tenant: unblock its virtual LLM key and mark state='active'.","operationId":"resume_tenant_internal_admin_tenants__tenant_id__resume_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Resume Tenant Internal Admin Tenants  Tenant Id  Resume Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/tenants/{tenant_id}/provision":{"post":{"tags":["admin-model-config"],"summary":"Provision Tenant","description":"Provision the tenant's LLM virtual key AND its LiteLLM team (idempotent).\n\nBacks the **\"Provision LLM key\"** button on the console's tenant *Model\nConfig* page (``/tenants/{id}/model-config``) — not the tenant detail page.\n\nMints a gateway virtual key and stores it in ``tenant_entitlement`` so the\ntenant's traffic routes through the metered gateway. Safe to call repeatedly:\nif the tenant already has a key it is returned unchanged (``created=False``)\nand no new key is minted. Returns 503 when the gateway is not configured.\n\nAlso ensures the tenant's LiteLLM team exists and that the key belongs to it\n(attaching an existing key without re-minting). A team failure does NOT fail\nthis request — the key is committed first and remains usable — so the result\ncarries ``team_ok`` / ``team_error`` instead. Callers must surface\n``team_ok=False``: the tenant is uncapped until the team exists, and a bare\n200 would hide that. Deliberately does not raise, because raising here would\nroll back ``get_tx_session`` and destroy the key row it just wrote.","operationId":"provision_tenant_internal_admin_tenants__tenant_id__provision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Provision Tenant Internal Admin Tenants  Tenant Id  Provision Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/tenants/{tenant_id}/model-config":{"get":{"tags":["admin-model-config"],"summary":"Get Tenant Model Config","description":"A tenant's model config for the console (admin view).\n\n``roles`` is the tenant's RAW per-tenant overrides (only the roles this\ntenant actually overrides), so the console can show which roles deviate\nfrom the platform default. ``default`` / ``connection`` / ``version`` come\nfrom the full resolve (global default, gateway connection, config hash).","operationId":"get_tenant_model_config_internal_admin_tenants__tenant_id__model_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Model Config Internal Admin Tenants  Tenant Id  Model Config Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/tenants/{tenant_id}/model-config/{role}":{"put":{"tags":["admin-model-config"],"summary":"Set Tenant Override","description":"Upsert a per-tenant model-config override for the given role.\n\nThe model must be in 'provider:model' format.  After the upsert the\nresolved config is re-fetched to derive a stable version hash, which is\nthen published to the tenant via NATS.\n\nRole ``default`` is not overridable per tenant at all — see\n``_TENANT_DEFAULT_ROLE_UNSETTABLE``.","operationId":"set_tenant_override_internal_admin_tenants__tenant_id__model_config__role__put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"role","in":"path","required":true,"schema":{"type":"string","title":"Role"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelConfigBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Tenant Override Internal Admin Tenants  Tenant Id  Model Config  Role  Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin-model-config"],"summary":"Delete Tenant Override","description":"Delete the per-tenant model-config override for the given role.\n\nNo-op if the row does not exist.  Publishes model_config_changed regardless\nso the tenant re-fetches its config (which will now fall back to the\nplatform default).","operationId":"delete_tenant_override_internal_admin_tenants__tenant_id__model_config__role__delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"role","in":"path","required":true,"schema":{"type":"string","title":"Role"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Tenant Override Internal Admin Tenants  Tenant Id  Model Config  Role  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/model-config/defaults/{role}":{"put":{"tags":["admin-model-config"],"summary":"Set Platform Default","description":"Upsert a platform-wide model-config default for the given role.\n\nAfter the upsert, publishes model_config_changed to every active tenant\n(v1 fan-out approach — iterates all active tenant_entitlement rows).\nA timestamp-based version is used to avoid O(n) resolver calls.","operationId":"set_platform_default_internal_admin_model_config_defaults__role__put","parameters":[{"name":"role","in":"path","required":true,"schema":{"type":"string","title":"Role"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ModelConfigBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Platform Default Internal Admin Model Config Defaults  Role  Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin-model-config"],"summary":"Delete Platform Default","description":"Delete a platform-wide model-config default.\n\nThe 'default' role is the global fallback and is protected — attempting to\ndelete it returns 400.","operationId":"delete_platform_default_internal_admin_model_config_defaults__role__delete","parameters":[{"name":"role","in":"path","required":true,"schema":{"type":"string","title":"Role"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Delete Platform Default Internal Admin Model Config Defaults  Role  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/model-config/roles":{"get":{"tags":["admin-model-config"],"summary":"List Roles","description":"Return the platform role catalog.\n\nFor each role in model_config_default, reports:\n- role: role name\n- default_model: the configured platform default\n- has_override_count: number of tenants with a per-tenant override for this role\n- runtime_known: whether the runtime knows this role\n\nSorted by role name.\n\n``aeo:``-prefixed rows (AI Visibility probe engine model versions) are\nexcluded — they are not resolvable model roles, just namespaced storage\nfor the AEO probe-engine models projected via ``resolve_model_config``'s\n``aeo_engines`` block. They get their own console editor (Task 3), not\nthe roles list.","operationId":"list_roles_internal_admin_model_config_roles_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","additionalProperties":true},"title":"Response List Roles Internal Admin Model Config Roles Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/model-config/gateway-models":{"get":{"tags":["admin-model-config"],"summary":"List Gateway Models","description":"Chat models registered in the gateway — the console's failover picker\nsource, in the stored ``provider:model`` form.\n\nRead from ``/model/info`` rather than ``/v1/models``: the latter lists the\ngateway aliases but names no provider, and a picker whose option values are\nbare ids produces chains that fail the PUT's own ``provider:model``\nvalidation. ``/model/info`` carries both halves — the provider in\n``litellm_params.model`` and the alias in ``model_name`` — so the stored\nvalue can be derived server-side; the console consumes this list verbatim\nand needs no provider table of its own.\n\nEmbedding / image / audio entries and providers the runtime cannot fail\nover to are filtered out (see ``_chat_provider_models``); the result is\nsorted and de-duplicated, since one alias can have several deployments.","operationId":"list_gateway_models_internal_admin_model_config_gateway_models_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"string"},"title":"Response List Gateway Models Internal Admin Model Config Gateway Models Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/admin/model-config/aeo-engines":{"get":{"tags":["admin-model-config"],"summary":"List Aeo Engines","description":"Return the AI Visibility (AEO) probe-engine model-version rows.\n\nMirrors ``GET /model-config/roles`` but reads the ``aeo:<engine>`` rows\nthat endpoint deliberately excludes (they are namespaced storage, not\nresolvable model roles — see its docstring and\n``docs/superpowers/specs/2026-07-21-aeo-configurable-probe-models-design.md``).\nEach row is the platform-default model string an AEO probe run resolves\nfor that gateway engine (``resolve_aeo_engine_model`` in tenant-app),\nunless a per-tenant override exists.\n\nFor each row, reports:\n- role: the namespaced role key (``aeo:chatgpt`` etc.) — pass this\n  straight to the EXISTING ``PUT``/``DELETE /model-config/defaults/{role}``\n  to edit or reset it. No new mutation endpoint is added.\n- engine: the bare engine key (``aeo:`` prefix stripped)\n- label: a human-readable engine name for the console\n- default_model: the configured platform default\n- has_override_count: number of tenants with a per-tenant override\n- runtime_known: whether the runtime knows this role\n\nSorted by engine name. Only the 5 gateway-transport engines have rows\nhere (google_ai_overview / copilot are SERP-transport and have no\nconfigurable model version).","operationId":"list_aeo_engines_internal_admin_model_config_aeo_engines_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","additionalProperties":true},"title":"Response List Aeo Engines Internal Admin Model Config Aeo Engines Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans":{"post":{"tags":["admin"],"summary":"Create Plan","description":"Create a plan: its row and the features it grants, in ONE transaction, then its Stripe\nProduct and Prices.\n\nThe features are written and audited BEFORE anything reaches Stripe, which is what keeps this\nall-or-nothing where it matters: a failure writing them rolls the plan row back with them and\nnothing has yet been created at Stripe, so there is no orphaned Product under an id that can\nnever be retried (the next attempt mints a different one). The Stripe calls come last because\nthey are best-effort and never fail the write.\n\nThe audit row is the one `PUT /admin/plans/{id}/features` writes, with `previous` empty: a\nplan's feature history then reads from one action, birth included. No `features_changed`\nnotice is queued: nobody can be subscribed to a plan that did not exist a moment ago, and this\nroute attaches no tenant to it (that is the subscription routes' job, on a plan that exists).","operationId":"create_plan_admin_plans_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["admin"],"summary":"List Plans","description":"The plan catalogue: ACTIVE plans only by default, which is what every picker in the\nconsole lists (the new-tenant wizard, the change-plan modal, the billing panel), and ALL of\nthem with ``?include_inactive=true``, which the plans page needs: a deactivated plan that the\nlist stopped returning would vanish from the page and could never be turned back on (spec\n§A1). The flag is read for its value, so ``=false`` is the default and not a widening.","operationId":"list_plans_admin_plans_get","parameters":[{"name":"include_inactive","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Inactive"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlansListOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/sellability":{"get":{"tags":["admin"],"summary":"List Plan Sellability","description":"Which plans Stripe can actually sell, and why not for the rest.\n\n**Its own endpoint, deliberately NOT a field on `GET /admin/plans`.** That list is read by\neight call sites across seven console pages (the new-tenant wizard twice, the change-plan\nmodal, the billing panel, the subscription row actions, and both tenant-request pages), none\nof which has any use for sellability, and all of which pick a plan to attach from it. Putting\na Stripe round trip on it would charge every one of them for a read only the plans page\nwants, and — worse — would couple the plan PICKERS to Stripe: this read answers 503 when\nStripe is unconfigured and 502 when it is unreachable, which on the plans list would mean an\noperator could not attach a plan to a tenant, or switch a plan off, during a Stripe outage.\nKeeping the two apart means the plans page degrades to \"sellability unknown\" and everything\nelse goes on working. Conditioning the Stripe read on `?include_inactive=true` was the other\nway to keep them in one route and was rejected for the same reason twice over: the wizard\npasses that flag too, and a flag about INACTIVE plans silently also meaning \"and pay for a\nStripe call\" is exactly the kind of coupling nobody finds again.\n\n**The cost, stated:** one paged `prices.list` call (100 Prices a page — one request for a\ncatalogue of fewer than 100) plus one `SELECT` over `plans`, per load of the console's plans\npage, and nowhere else. The console also puts this under its `[\"plans\"]` query prefix, so a\nplan write on that page buys one more of these — deliberately, because a plan CREATED in the\nconsole has a Stripe Product and no Price at all and is therefore born unsellable, and the\noperator should see that on the row rather than hear it from a customer. Plan writes are a\nhandful a day. Nothing caches it: `list_catalog_prices` has no cache on either side (the\nadd-ons page and every tenant's catalogue read pay the same call), and this answer must not\nbe stale — an operator who has just created a Price in the Stripe dashboard reloads the page\nto see whether it worked. The console's React Query `staleTime` (30s) is what keeps a mere\nrevisit from re-reading it.\n\nEVERY plan, deactivated ones included (`list_all`, the same list the page shows): a\ndeactivated plan is already unbuyable by the local flag, and an operator about to reactivate\none needs to know whether that will be enough.","operationId":"list_plan_sellability_admin_plans_sellability_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanSellabilityList"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/repair":{"post":{"tags":["admin"],"summary":"Repair Plan Sellability","description":"Apply the fix one sellability finding names, and answer the plan's re-read diagnosis.\n\nThree gates, in this order. The first two, and the first half of the third, are all BEFORE any\nwrite reaches Stripe; the third's second half is the one refusal that can only come after the\nwrite was attempted, because only Stripe knows about the holder it is for:\n\n1. `is_repairable(reason)` — the three findings this server fixes in place\n   (`_plan_repair.REPAIRS`). The other four are a 409 carrying `UNREPAIRABLE`'s own sentence\n   for that reason, which is where those words live, so this route states none of them. Three\n   of those four are Stripe immutables; `addon_metadata` is one Stripe would permit and this\n   platform refuses, because rewriting a live Price's pack metadata changes what its existing\n   holders get (that module's docstring argues it, and the client has no such write).\n2. the object named belongs to THIS plan (`_repair_price` / `_repair_product`) — without it a\n   crafted request re-keys an arbitrary Price on the account.\n3. for a key write, nothing else already holds the key — in two halves, because they find two\n   different holders: `_key_to_write` reads the ACTIVE holder before writing, and\n   `_apply_repair_at_stripe` maps Stripe's own refusal (the ARCHIVED holder that read cannot\n   see) to the same 409. Either way taking a key is `transfer_lookup_key` and may move it off\n   the Price a tenant is billed on, so it is never automatic.\n\nThe answer is the plan's row re-diagnosed off a FRESH catalogue read, not a restatement of\nwhat was written: the console updates the row from the same oracle the plans page uses\n(`_split_catalog`, through `diagnose_sellability`), so a repair that wrote the wrong thing\nshows as still-unsellable rather than as a cheerful 200.","operationId":"repair_plan_sellability_admin_plans__plan_id__repair_post","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanRepairIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanSellability"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/deactivate":{"post":{"tags":["admin"],"summary":"Deactivate Plan","operationId":"deactivate_plan_admin_plans__plan_id__deactivate_post","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/reactivate":{"post":{"tags":["admin"],"summary":"Reactivate Plan","operationId":"reactivate_plan_admin_plans__plan_id__reactivate_post","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}":{"patch":{"tags":["admin"],"summary":"Rename Plan","description":"Rename a plan: `plans.name`, the audit row, then the Stripe Product (spec §A2).\n\nThe plan is looked up in OUR table first and a miss is a 404 before anything reaches Stripe:\nthe path id is the Product id, so a route that called Stripe first would rename any Product on\nthe account. A rename to the name the plan already has is not skipped: it still pushes the\nname, which is how an operator re-syncs a Product that drifted.","operationId":"rename_plan_admin_plans__plan_id__patch","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanRename"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/trial":{"put":{"tags":["admin"],"summary":"Mark Trial Plan","description":"Offer this plan as a trial, for `trial_days` by default (spec §C1/§C2, plan 2026-10-12).\n\nAny number of plans can be offered, so this MOVES NOTHING: every other plan is left exactly as\nit is, the default trial included, and this plan does not become the default (that is\n`PUT /{plan_id}/default-trial`; a plan that already is the default stays so, which is also how\nthe operator changes the length of the default). It is independent of `active`, on purpose:\nthe plan may be one that is switched off so it can never be picked, and offering it neither\nturns it on nor needs it on.\n\nLocal only. A trial has no Stripe object, so unlike a rename this never reaches Stripe.\n\nThe length is this plan's own: the body's `trial_days` when given; otherwise the length the\nplan already carries as a trial plan (so re-offering it from a client that did not send one\ndoes not reset it); otherwise `DEFAULT_TRIAL_DAYS`. An offer that changes nothing (the plan\nalready is a trial plan, at that length) writes no audit row, so one row means one change.","operationId":"mark_trial_plan_admin_plans__plan_id__trial_put","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/PlanTrialIn"},{"type":"null"}],"title":"Body"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin"],"summary":"Clear Trial Plan","description":"Stop offering this plan as a trial (spec §C1, plan 2026-10-12).\n\nThe default must be a trial plan (`ck_plans_default_trial_is_trial`), so a plan that IS the\ndefault loses that mark here too, and `PlanRepo.clear_trial` clears both flags in the one\nwrite. That changes what provisioning does for a blank choice, so it is audited as the change\nit is: besides the `plan.trial_cleared` row the plan gets a `plan.default_trial_cleared` row,\nmarked `because: trial_cleared`. Two rows because two facts changed, and so that the default's\naction word means ONE thing whichever route took the mark away (a move, a demotion, or this):\nan operator asking why new tenants stopped starting on a plan looks that word up and is not\nsent past it by the route that happened to do it. What a blank choice resolves to with no\ndefault left is provisioning's rule (`tenant_lifecycle.create_tenant`), not this route's.\n\nIdempotent, and scoped to THIS plan: naming a plan that is not a trial plan changes nothing\n(the plans that are stay so, the default included) and writes no audit row. 404 for a plan that\ndoes not exist. Taking only the default mark off a plan, and keeping it on the trial list, is\n`DELETE /{plan_id}/default-trial`.","operationId":"clear_trial_plan_admin_plans__plan_id__trial_delete","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/default-trial":{"put":{"tags":["admin"],"summary":"Mark Default Trial Plan","description":"Make this THE trial plan a new tenant starts on when none is named (spec §C1, plan\n2026-10-12).\n\nExactly one plan carries the mark, so marking a plan MOVES it: the previous holder is cleared\nin the same transaction (`PlanRepo.set_default_trial`, which flushes the clear before the set\nso the partial unique index is never violated, whichever id sorts first). Only the MARK moves:\nthe previous holder is still a trial plan, with its own length, and this plan keeps the length\nit was offered at. It is independent of `active`, on purpose, for both plans.\n\nOnly a plan that is already offered as a trial can be the default (`PUT /{plan_id}/trial`\nfirst): any other is a 409 that names it, answered from `PlanNotTrialEligible`, which the repo\nraises BEFORE it writes anything. The rule is the repo's and is not restated here. The check\nconstraint would refuse the same request too, but as an IntegrityError that nothing in the\nrequest path handles, after the previous default had already lost its mark.\n\nLocal only. No body: the length belongs to the offer.\n\nA mark that changes nothing (the plan already is the default) writes no audit row, so one row\nmeans one change. A move writes two, one on each plan, so the trail of the plan that STOPPED\nbeing the default says why: `replaces` on the new holder's row, `replaced_by` on the old one's.","operationId":"mark_default_trial_plan_admin_plans__plan_id__default_trial_put","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin"],"summary":"Clear Default Trial Plan","description":"Stop this plan being THE default trial and leave it offered as a trial (plan 2026-10-12).\n\nHaving no default is a legal state while trial plans remain, and this plan stays on the list:\nit keeps `is_trial` and its length, and `active` is untouched. What a blank choice resolves to\nwith no default is provisioning's rule (`tenant_lifecycle.create_tenant`), not this route's.\nTaking the plan off the trial list as well is `DELETE /{plan_id}/trial`, which also takes the\ndefault mark.\n\nIdempotent, and scoped to THIS plan: naming a plan that is not the default changes nothing\n(the plan that is stays so) and writes no audit row. 404 for a plan that does not exist.","operationId":"clear_default_trial_plan_admin_plans__plan_id__default_trial_delete","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/allotments":{"get":{"tags":["admin"],"summary":"Get Allotments","operationId":"get_allotments_admin_plans__plan_id__allotments_get","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllotmentsOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin"],"summary":"Set Allotments","operationId":"set_allotments_admin_plans__plan_id__allotments_put","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllotmentsIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AllotmentsOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/cap-state":{"get":{"tags":["admin"],"summary":"Get Tenant Cap State","operationId":"get_tenant_cap_state_admin_tenants__tenant_id__cap_state_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Cap State Admin Tenants  Tenant Id  Cap State Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/cap-override":{"post":{"tags":["admin"],"summary":"Override Cap State","description":"Admin override: change cap state (typically unblock) with full audit trail.","operationId":"override_cap_state_admin_tenants__tenant_id__cap_override_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CapOverrideIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Override Cap State Admin Tenants  Tenant Id  Cap Override Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/evaluate-caps":{"post":{"tags":["admin"],"summary":"Evaluate Tenant Caps","description":"Synchronously evaluate and persist cap state for a tenant.\n\nUseful after creating/changing a subscription or plan allotments so the\nadmin console reflects the new state without waiting for the background loop.\n\nLifecycle-aware, mirroring ``cap_reeval.reevaluate_tenant_caps``: the\nmetered metrics are hard-blocked when the tenant's subscription is not\ngranted (canceled / expired / none), via ``apply_subscription_block``.\nWithout this, calling evaluate-caps on a lapsed/canceled tenant would\npersist ``evaluate_metric``'s uncapped ``ok`` for email_sends/sms_sends,\noverwriting the loop's ``blocked`` rows until the next loop tick (the MCP\nsend-gate reads cap_state, so this would transiently unblock sends).\nPeriod rolling is deliberately NOT done here — that's the loop's job.","operationId":"evaluate_tenant_caps_admin_tenants__tenant_id__evaluate_caps_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Evaluate Tenant Caps Admin Tenants  Tenant Id  Evaluate Caps Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/cap-state/blocked":{"get":{"tags":["admin"],"summary":"List Blocked Tenants","operationId":"list_blocked_tenants_admin_cap_state_blocked_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response List Blocked Tenants Admin Cap State Blocked Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/social-config/reprovision":{"post":{"tags":["admin-social"],"summary":"Reprovision Social","description":"Re-run social provisioning for the given tenant.\n\nCalls the social service's POST /internal/provision-tenant endpoint.\nOn failure the exception propagates as a 500 so the operator can see\nthe error; unlike create_tenant (which must succeed regardless) this\nadmin endpoint is explicitly recovery-oriented.\n\n409s when SOCIAL_SERVICE_MCP_URL is unset. Reporting \"ok\" for a call\nthat never left the process defeats the point of a recovery endpoint — the\noperator would retry, see ok, and still have no bundle.social team.","operationId":"reprovision_social_admin_tenants__tenant_id__social_config_reprovision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Reprovision Social Admin Tenants  Tenant Id  Social Config Reprovision Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/jobs/{job_id}":{"get":{"tags":["admin-tenant-lifecycle"],"summary":"Get Job","operationId":"get_job_admin_tenants__tenant_id__jobs__job_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobDetailResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/jobs":{"get":{"tags":["admin-tenant-lifecycle"],"summary":"List Jobs","operationId":"list_jobs_admin_tenants__tenant_id__jobs_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobsListResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/pause":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Pause Tenant","operationId":"pause_tenant_admin_tenants__tenant_id__pause_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PauseBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobIdResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/resume":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Resume Tenant","operationId":"resume_tenant_admin_tenants__tenant_id__resume_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResumeBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobIdResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/delete":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Delete Tenant","operationId":"delete_tenant_admin_tenants__tenant_id__delete_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DeleteBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobIdResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/resend-admin-invite":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Resend Admin Invite","operationId":"resend_admin_invite_admin_tenants__tenant_id__resend_admin_invite_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResendAdminInviteResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/reveal-admin-invite-link":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Reveal Admin Invite Link","description":"Decrypt and return the stored Clerk first-admin invitation link.\n\nPOST rather than GET deliberately: the call is audited and\nside-effecting, and a POST keeps the token out of URLs, referrer headers\nand access logs.\n\nThe link grants org:app_admin on the tenant, so every successful reveal\nwrites an audit row — carrying the invitation id and email, never the url\nitself. Before handing it over we re-check with Clerk that the invitation\nis still pending, so an operator is never sent after a dead link.","operationId":"reveal_admin_invite_link_admin_tenants__tenant_id__reveal_admin_invite_link_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RevealAdminInviteLinkResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/jobs/{job_id}/steps/{step_name}/retry":{"post":{"tags":["admin-tenant-lifecycle"],"summary":"Retry Job Step","operationId":"retry_job_step_admin_tenants__tenant_id__jobs__job_id__steps__step_name__retry_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"job_id","in":"path","required":true,"schema":{"type":"string","title":"Job Id"}},{"name":"step_name","in":"path","required":true,"schema":{"type":"string","title":"Step Name"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RetryResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenant-requests":{"post":{"tags":["admin"],"summary":"Create Request","operationId":"create_request_admin_tenant_requests_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestCreate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["admin"],"summary":"List Requests","operationId":"list_requests_admin_tenant_requests_get","parameters":[{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/TenantRequestOut"},"title":"Response List Requests Admin Tenant Requests Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenant-requests/{req_id}":{"get":{"tags":["admin"],"summary":"Get Request","operationId":"get_request_admin_tenant_requests__req_id__get","parameters":[{"name":"req_id","in":"path","required":true,"schema":{"type":"string","title":"Req Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin"],"summary":"Update Request","description":"Edit a still-open request before it's approved (admin only).\n\nOnly a ``requested`` row is editable — once it's provisioning/active/\nrejected the request is settled and its fields are historical. Re-runs the\nsame plan + slug validation as create (excluding this row from the\ncollision check), so an edit can't push the queue into a state that would\nfail at approve time.","operationId":"update_request_admin_tenant_requests__req_id__patch","parameters":[{"name":"req_id","in":"path","required":true,"schema":{"type":"string","title":"Req Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestCreate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenant-requests/{req_id}/approve":{"post":{"tags":["admin"],"summary":"Approve Request","operationId":"approve_request_admin_tenant_requests__req_id__approve_post","parameters":[{"name":"req_id","in":"path","required":true,"schema":{"type":"string","title":"Req Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenant-requests/{req_id}/reject":{"post":{"tags":["admin"],"summary":"Reject Request","operationId":"reject_request_admin_tenant_requests__req_id__reject_post","parameters":[{"name":"req_id","in":"path","required":true,"schema":{"type":"string","title":"Req Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RejectBody"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantRequestOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/slug-availability":{"get":{"tags":["admin"],"summary":"Check Slug Availability","operationId":"check_slug_availability_admin_slug_availability_get","parameters":[{"name":"slug","in":"query","required":true,"schema":{"type":"string","minLength":1,"maxLength":128,"title":"Slug"}},{"name":"exclude_request_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Exclude Request Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SlugAvailabilityOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing/link":{"post":{"tags":["admin-billing"],"summary":"Link Stripe Customer","operationId":"link_stripe_customer_admin_tenants__tenant_id__billing_link_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/LinkCustomerIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Link Stripe Customer Admin Tenants  Tenant Id  Billing Link Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing/mode":{"post":{"tags":["admin-billing"],"summary":"Set Billing Mode","description":"Set ``billing_mode``, and set, clear or leave alone the trial end (see ``BillingModeIn``).\n\nA move to ``trial`` writes through ``subscription_term.apply_trial_end``, which also converges\n``status`` at once from the sweep's own rule (an extended expired trial is let back in now, not\nat the next tick); when the status changed, the tenant's caps are re-evaluated immediately.\n\nOrder matters, because the answer to \"is this valid\" depends on what is stored: the tenant\nmust exist (404) and have a subscription row (409, which the console points at the tenant's\nUsage page for, rather than failing opaquely) BEFORE ``trial_end`` is judged. A first move to\n``trial`` with no date has nothing to leave alone and would leave NULL, so it is a 422.\n\nThe response and the audit row carry the value now STORED, never an echo of the request:\nechoing an absent field would report ``null`` for a trial end that was left exactly as it was.\n\nA trial's PERIOD must cover its end. The metered-usage gate (`subscription_state.resolve`, run\nby `jobs/cap_eval` for every live tenant) reads `current_period_end`, not `trial_end`: it grants\nwhile ``as_of < current_period_end``, and it relabels the row's status to match. So moving only\n`trial_end` forward leaves the banner saying \"trial active\" while the gate hard-blocks the\ntenant at the old period end (and the sweep and the gate then flip the status back and forth).\nA move to ``trial`` therefore also carries `current_period_end` out to the day AFTER the trial\nend (the period is half-open, the trial inclusive: the same invariant provisioning writes), and\nnever in: a period that already runs past the trial is an operator's choice and is left alone,\nand a shortened trial does not shorten it.","operationId":"set_billing_mode_admin_tenants__tenant_id__billing_mode_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingModeIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Billing Mode Admin Tenants  Tenant Id  Billing Mode Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing/collection":{"post":{"tags":["admin-billing"],"summary":"Switch Collection Method","operationId":"switch_collection_method_admin_tenants__tenant_id__billing_collection_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CollectionIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Switch Collection Method Admin Tenants  Tenant Id  Billing Collection Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing":{"get":{"tags":["admin-billing"],"summary":"Get Billing Panel","description":"Everything the console billing panel shows for one tenant.","operationId":"get_billing_panel_admin_tenants__tenant_id__billing_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Billing Panel Admin Tenants  Tenant Id  Billing Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing/history":{"get":{"tags":["admin-billing"],"summary":"Get Billing History","description":"The tenant's billing trail, newest first: what support needs to answer \"what has this\ncustomer done to their subscription, and are they leaving?\" without opening Stripe.\n\nThe first API over ``audit_log``: until now rows went into that table and nothing could list\nthem, so what a customer or an operator did to a subscription never reached the console.\n\n**Capped, and honest about it.** At most ``limit`` entries (default 50, never more than 500, so\nthe cap cannot be asked away): a tenant has a row for every plan change and every convergence,\nand the console must not fetch thousands. ``truncated`` says whether older rows were left out,\nso a list that was cut is never read as the whole trail. It costs one extra row read, which is\nthe only way to know: a trail of exactly ``limit`` rows is complete.\n\n**Scoped by the row's ``resource_id`` alone** (the tenant id), not by its ``resource_type``:\nthe writers file one tenant's billing rows under three types (``tenant_subscription``,\n``tenant_billing``, ``tenant_billing_offers``), and narrowing to one of them to reach the\n``(resource_type, resource_id)`` index would silently drop the rest (see\n``AuditLogRepo.recent_for_resource``).\n\n404 for a tenant that does not exist, as the panel beside it: an empty list there would say\n\"this customer has done nothing\", which is not the same statement.","operationId":"get_billing_history_admin_tenants__tenant_id__billing_history_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":500,"minimum":1,"default":50,"title":"Limit"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Billing History Admin Tenants  Tenant Id  Billing History Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/billing/reconcile":{"post":{"tags":["admin-billing"],"summary":"Force Reconcile","description":"Run Layer-3 convergence now, scoped to this tenant only.\n\nCalls ``reconcile_tenant``, not the account-wide ``reconcile_once`` sweep —\nan action scoped by URL to one tenant must not cost O(all subscriptions)\nof Stripe traffic just because the sweep happened to be the only Layer-3\nentry point when this endpoint was first written.\n\nThis is the operator's EXPLICIT action, the one place a tenant with no Stripe customer may\nhave one CREATED for it (spec 2026-10-07 §D2: the sweep only finds and adopts). So the route\ntakes the operator's identity and hands it down: the audit row for a customer made here says\nwho clicked.","operationId":"force_reconcile_admin_tenants__tenant_id__billing_reconcile_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Force Reconcile Admin Tenants  Tenant Id  Billing Reconcile Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/tracking-config":{"get":{"tags":["admin-tracking"],"summary":"Read Tracking Config","operationId":"read_tracking_config_admin_tenants__tenant_id__tracking_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin-tracking"],"summary":"Put Tracking Domains","description":"Replace the origin allowlist. Empty needs ``allow_empty`` — see the model.","operationId":"put_tracking_domains_admin_tenants__tenant_id__tracking_config_put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SetDomainsIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/tracking/provision":{"post":{"tags":["admin-tracking"],"summary":"Post Provision Tracking","description":"Mint the site_key for a tenant that has none.\n\nIdempotent on the MCP side and it never re-mints, so this is also the safe\nrepair for a tenant whose ``TrackingStep`` failed at Create time.","operationId":"post_provision_tracking_admin_tenants__tenant_id__tracking_provision_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"content":{"application/json":{"schema":{"anyOf":[{"$ref":"#/components/schemas/ProvisionIn"},{"type":"null"}],"title":"Payload"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/tracking/suspend":{"post":{"tags":["admin-tracking"],"summary":"Post Suspend Tracking","operationId":"post_suspend_tracking_admin_tenants__tenant_id__tracking_suspend_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/tracking/resume":{"post":{"tags":["admin-tracking"],"summary":"Post Resume Tracking","description":"Resume collection.\n\nDoes NOT clear ``usage_blocked_at`` — a tenant who is both operator-suspended\nand over their allowance stays dark after this call, by design.","operationId":"post_resume_tracking_admin_tenants__tenant_id__tracking_resume_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/TrackingConfigOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/offers/defaults":{"get":{"tags":["admin-offers"],"summary":"Get Default Offers","description":"The raw platform default set — NOT narrowed to active plans the way\n``purchasable_offers`` narrows a tenant's. This is the editing surface for what the\nplatform offers by default; an operator staging a plan ahead of its\nactivation must see it here, not have it silently hidden.","operationId":"get_default_offers_admin_offers_defaults_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Default Offers Admin Offers Defaults Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin-offers"],"summary":"Put Default Offers","description":"Replace the ENTIRE default set wholesale (``set_defaults``'s own\ncontract: its DELETE is unscoped and spans both kinds). The caller must\nsend the full set every time — this is a replace, not a merge; see\nmodule docstring point 3 for why ``plans``/``addons`` are required\nrather than defaulted. This is ``set_defaults``'s first production\ncaller; Task 2 left it with no contract test beyond migration 0013's\nincidental ``plan_free`` row.","operationId":"put_default_offers_admin_offers_defaults_put","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OffersIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Put Default Offers Admin Offers Defaults Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/offers":{"get":{"tags":["admin-offers"],"summary":"Get Tenant Offer Set","description":"Always the tenant's own STORED rows (``get_tenant_offers``) plus\n``mode`` as a separate field — never ``effective_offers``. An\ninherit-mode tenant's stored rows are dormant, not absent, and the\nconsole needs to show both so a mode toggle isn't a blind guess.","operationId":"get_tenant_offer_set_admin_tenants__tenant_id__offers_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Offer Set Admin Tenants  Tenant Id  Offers Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin-offers"],"summary":"Put Tenant Offer Set","description":"Sets ``mode`` always; writes the stored list ONLY when the target mode\nis ``custom``. Switching to ``inherit`` must never touch\n``tenant_billing_offers`` — deleting would destroy an operator's past\ncustom list on a mis-click, and writing the body's list here would\nsilently wipe it the same way. The dormant list is preserved exactly by\nleaving it alone.","operationId":"put_tenant_offer_set_admin_tenants__tenant_id__offers_put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/TenantOffersIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Put Tenant Offer Set Admin Tenants  Tenant Id  Offers Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/addons":{"get":{"tags":["admin-addons"],"summary":"List Addon Catalog","description":"Every active add-on Price in the Stripe catalog. See module\ndocstring for why this is intentionally unfiltered by any tenant's or\nthe platform's offer set.\n\nPlus `findings`: the add-on Prices in the same read that `_split_catalog` refuses to sell, so\none that is not monthly is visible to an operator instead of only to a Prometheus counter.\nOff the SAME `prices.list` call — no second Stripe round trip; see the findings comment above\nfor why this is a field here and a separate endpoint on the plans page.","operationId":"list_addon_catalog_admin_addons_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonCatalogList"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["admin-addons"],"summary":"Create Addon","description":"Create an add-on: its Stripe Product, the Price that is the add-on, and (unless unticked)\nthe default offer row that lets a tenant buy it (spec 2026-10-07 §B1).\n\nValidation first, all of it before the first Stripe write (see the module docstring for why):\nthe body (422), the metric (422, `validate_metric_type`, the one place that decides whether a\nmetric name is real), Stripe configured (503), the key free (409). Then the database writes,\nflushed and not committed, then Stripe. A Stripe failure raises, so the request's\ntransaction rolls the offer row and the audit row back with it.","operationId":"create_addon_admin_addons_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonCreate"}}}},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonCreated"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/addons/{lookup_key}":{"get":{"tags":["admin-addons"],"summary":"Get Addon","description":"One add-on as the edit screen shows it: its fixed facts, its editable words, and the number\nof subscriptions that hold it today.","operationId":"get_addon_admin_addons__lookup_key__get","parameters":[{"name":"lookup_key","in":"path","required":true,"schema":{"type":"string","title":"Lookup Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonEditView"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"patch":{"tags":["admin-addons"],"summary":"Edit Addon","description":"Change an add-on's name and/or description: the audit row, then ONE request to its Stripe\nProduct (spec 2026-10-07 §B2).\n\nThe add-on is found first, in Stripe, and a miss is a 404 before anything is written. What\nthe body sends is what is changed, and a name or description equal to the current one is still\npushed, as a plan rename is: it is how an operator re-syncs a Product that drifted. The audit\nrow records each field's old and new value (the Product no longer remembers the first). A\nStripe failure raises, so the audit row is rolled back with the request.","operationId":"edit_addon_admin_addons__lookup_key__patch","parameters":[{"name":"lookup_key","in":"path","required":true,"schema":{"type":"string","title":"Lookup Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonEdit"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonDetail"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/addons/{lookup_key}/price":{"post":{"tags":["admin-addons"],"summary":"Reprice Addon","description":"Change what an add-on costs: a NEW Price on the same Product, the lookup key moved onto it\n(spec 2026-10-07 §B3). Existing holders keep the old Price and the old amount; new purchases pay\nthe new one; the answer says how many holders that is.\n\nRefused before anything is written: an add-on that is not found (404 — which since 2026-10-13\nincludes one that does not recur monthly, refused by `_find_addon` for every edit route at\nonce; see its docstring, and `GET /admin/addons`'s `findings` for what the operator is told);\na price that is not the one the operator was shown (409, someone changed it meanwhile); the\nprice it already has (409: there is nothing to change, and a second identical Price would only\nbe one more for the account to carry); an add-on with no fixed price (409). The holders are\ncounted BEFORE the new Price exists, so an outage there stops the change with nothing made.\n\nThis route changes an AMOUNT, never an interval: `create_addon_price` mints a monthly Price\nand has no interval to ask for, so a non-monthly add-on reaching here would have been\nconverted to a monthly one silently. It cannot reach here.\n\nThe old Price is left exactly as it is: ACTIVE, with its amount, with no lookup key now. Every\nholder's subscription item points at it, so nothing here deactivates it, and nothing could (the\nclient has no call that changes a Price).","operationId":"reprice_addon_admin_addons__lookup_key__price_post","parameters":[{"name":"lookup_key","in":"path","required":true,"schema":{"type":"string","title":"Lookup Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonReprice"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AddonRepriced"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/features":{"get":{"tags":["admin-features"],"summary":"List Features","operationId":"list_features_admin_features_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response List Features Admin Features Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/features/{feature_key}":{"put":{"tags":["admin-features"],"summary":"Set Rollout","description":"Set a feature's platform rollout. ``disabled`` is the kill switch: it beats every\nplan and every per-tenant grant, so it notifies every tenant.","operationId":"set_rollout_admin_features__feature_key__put","parameters":[{"name":"feature_key","in":"path","required":true,"schema":{"type":"string","title":"Feature Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/RolloutIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Rollout Admin Features  Feature Key  Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/plans/{plan_id}/features":{"get":{"tags":["admin-features"],"summary":"Get Plan Features","operationId":"get_plan_features_admin_plans__plan_id__features_get","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Plan Features Admin Plans  Plan Id  Features Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"put":{"tags":["admin-features"],"summary":"Set Plan Features","description":"Replace the plan's features wholesale; notify every tenant on the plan.","operationId":"set_plan_features_admin_plans__plan_id__features_put","parameters":[{"name":"plan_id","in":"path","required":true,"schema":{"type":"string","title":"Plan Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/PlanFeaturesIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Plan Features Admin Plans  Plan Id  Features Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/features":{"get":{"tags":["admin-features"],"summary":"Get Tenant Features","operationId":"get_tenant_features_admin_tenants__tenant_id__features_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Features Admin Tenants  Tenant Id  Features Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/admin/tenants/{tenant_id}/features/{feature_key}":{"put":{"tags":["admin-features"],"summary":"Set Tenant Override","description":"Grant or revoke one feature for one tenant. A reason is required: a bespoke grant\nnobody can explain later is an operational liability.","operationId":"set_tenant_override_admin_tenants__tenant_id__features__feature_key__put","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"feature_key","in":"path","required":true,"schema":{"type":"string","title":"Feature Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OverrideIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Set Tenant Override Admin Tenants  Tenant Id  Features  Feature Key  Put"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"delete":{"tags":["admin-features"],"summary":"Clear Tenant Override","description":"Remove an override so the plan and rollout layers decide again. Idempotent.","operationId":"clear_tenant_override_admin_tenants__tenant_id__features__feature_key__delete","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"feature_key","in":"path","required":true,"schema":{"type":"string","title":"Feature Key"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Clear Tenant Override Admin Tenants  Tenant Id  Features  Feature Key  Delete"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/email-config/by-subuser/{subuser}":{"get":{"tags":["internal-email"],"summary":"By Subuser","operationId":"by_subuser_internal_email_config_by_subuser__subuser__get","parameters":[{"name":"subuser","in":"path","required":true,"schema":{"type":"string","title":"Subuser"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response By Subuser Internal Email Config By Subuser  Subuser  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/email-config/{tenant_id}":{"get":{"tags":["internal-email"],"summary":"By Tenant","operationId":"by_tenant_internal_email_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response By Tenant Internal Email Config  Tenant Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/email-config-by-webhook-token/{token}":{"get":{"tags":["internal-email"],"summary":"By Webhook Token","description":"Resolve a per-tenant webhook URL token to its config row.\n\nPlan 2026-05-03 sendgrid-managed-byo Task 13 — the BYO ingestor\n(``POST /webhooks/sendgrid/{token}`` in the MCP) calls this to\nattribute incoming events. Returns the same response shape as the\nby-tenant-id endpoint above so the MCP-side caller can share its\ndeserialization path.\n\nThe by-webhook result is cross-indexed under the tenant via\nalso_index_under so invalidate(tenant_id) clears this key too.","operationId":"by_webhook_token_internal_email_config_by_webhook_token__token__get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response By Webhook Token Internal Email Config By Webhook Token  Token  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-config/{tenant_id}":{"get":{"tags":["internal-sms"],"summary":"Sms Config For Tenant","operationId":"sms_config_for_tenant_internal_sms_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Sms Config For Tenant Internal Sms Config  Tenant Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-config-by-webhook-token/{token}":{"get":{"tags":["internal-sms"],"summary":"Sms Config By Token","operationId":"sms_config_by_token_internal_sms_config_by_webhook_token__token__get","parameters":[{"name":"token","in":"path","required":true,"schema":{"type":"string","title":"Token"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Sms Config By Token Internal Sms Config By Webhook Token  Token  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-config/provision/{tenant_id}":{"post":{"tags":["internal-sms"],"summary":"Provision Sms","description":"Provision a managed Twilio subaccount for *tenant_id*.\n\nUsed by tenant-app's ``POST /api/sms-config/initialize`` which can only\npresent an ``X-Platform-Internal-Key`` header (no Clerk JWT). The admin\nrouter's ``/admin/tenants/{tenant_id}/sms-config/provision`` requires a\nClerk admin JWT, which tenant-app does not hold.","operationId":"provision_sms_internal_sms_config_provision__tenant_id__post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"x-platform-internal-key","in":"header","required":false,"schema":{"type":"string","default":"","title":"X-Platform-Internal-Key"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Provision Sms Internal Sms Config Provision  Tenant Id  Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-compliance-bundles":{"post":{"tags":["internal-sms"],"summary":"Create Bundle","operationId":"create_bundle_internal_sms_compliance_bundles_post","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/_BundleCreate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Create Bundle Internal Sms Compliance Bundles Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"get":{"tags":["internal-sms"],"summary":"List Bundles","operationId":"list_bundles_internal_sms_compliance_bundles_get","parameters":[{"name":"tenant_id","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"}},{"name":"country","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Country"}},{"name":"kind","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Kind"}},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"}},{"name":"submitted_before","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Submitted Before"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","additionalProperties":true},"title":"Response List Bundles Internal Sms Compliance Bundles Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-compliance-bundles/by-twilio-sid/{twilio_sid}":{"get":{"tags":["internal-sms"],"summary":"Get Bundle By Twilio Sid","operationId":"get_bundle_by_twilio_sid_internal_sms_compliance_bundles_by_twilio_sid__twilio_sid__get","parameters":[{"name":"twilio_sid","in":"path","required":true,"schema":{"type":"string","title":"Twilio Sid"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Bundle By Twilio Sid Internal Sms Compliance Bundles By Twilio Sid  Twilio Sid  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-compliance-bundles/{bundle_id}":{"get":{"tags":["internal-sms"],"summary":"Get Bundle","operationId":"get_bundle_internal_sms_compliance_bundles__bundle_id__get","parameters":[{"name":"bundle_id","in":"path","required":true,"schema":{"type":"string","title":"Bundle Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Bundle Internal Sms Compliance Bundles  Bundle Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/sms-compliance-bundles/{bundle_id}/status":{"post":{"tags":["internal-sms"],"summary":"Update Bundle Status","operationId":"update_bundle_status_internal_sms_compliance_bundles__bundle_id__status_post","parameters":[{"name":"bundle_id","in":"path","required":true,"schema":{"type":"string","title":"Bundle Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/_StatusUpdate"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Update Bundle Status Internal Sms Compliance Bundles  Bundle Id  Status Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/m2m-credentials/refresh":{"get":{"tags":["internal-m2m"],"summary":"Refresh","description":"Return the active {machine_id, secret_key} for the JWT's tenant.","operationId":"refresh_internal_m2m_credentials_refresh_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Refresh Internal M2M Credentials Refresh Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/nats-credentials/{tenant_id}":{"get":{"tags":["internal-nats"],"summary":"Get Nats Credentials","description":"Return the NATS subscriber credential bundle for ``tenant_id``.\n\nReturns 200 with ``{user_jwt, user_seed, account_pubkey,\nexpires_at}`` on success, 403 if a tenant caller's ``tenant_id``\ndoesn't match the URL's, 404 if no row exists for the tenant, and\n409 if the row exists but isn't yet ``active``.","operationId":"get_nats_credentials_internal_nats_credentials__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Nats Credentials Internal Nats Credentials  Tenant Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenant-platform-id":{"get":{"tags":["internal-tenant"],"summary":"Get Tenant Platform Id","description":"Return the platform tenant_id for the bearer's Clerk JWT.\n\nResponse: {\"platform_tenant_id\": \"tnt_...\"}","operationId":"get_tenant_platform_id_internal_tenant_platform_id_get","parameters":[{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant Platform Id Internal Tenant Platform Id Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/langfuse-config/{tenant_id}":{"get":{"tags":["internal-langfuse"],"summary":"Get Langfuse Config","description":"Return the decrypted Langfuse config for ``tenant_id``, or 204.\n\n204 covers all \"not available\" cases: no row, soft-disabled row, or a\nmanaged tenant that never had a row.  The caller (tenant-app) should\nfall back to the fleet key in all 204 cases.\n\nThe row's ciphertext snapshot is served from Redis when hot; decryption\nhappens here (never in the cache), so no plaintext secret touches Redis.","operationId":"get_langfuse_config_internal_langfuse_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/tavily/search":{"post":{"tags":["tavily-proxy"],"summary":"Search","operationId":"search_internal_tenants__tenant_id__tavily_search_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/tavily/extract":{"post":{"tags":["tavily-proxy"],"summary":"Extract","operationId":"extract_internal_tenants__tenant_id__tavily_extract_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ExtractIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/serp/ai_answer":{"post":{"tags":["serp-proxy"],"summary":"Ai Answer","operationId":"ai_answer_internal_tenants__tenant_id__serp_ai_answer_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SerpAnswerIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/blob-config/{tenant_id}":{"get":{"tags":["internal-blob-config"],"summary":"Get Blob Config","description":"Return decrypted blob config for ``tenant_id``, or 204.\n\nLayer-2 access check: only the screenshot-service system caller is\nallowed. Tenant callers and other system callers are always rejected.\nAuth checks run BEFORE cache access so unauthorised callers never\npopulate or read from Redis.\n\nThe row's column snapshot is served from Redis when hot; get_secret()\nis always called per request (never cached in Redis).","operationId":"get_blob_config_internal_blob_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/identity-config/{tenant_id}":{"get":{"tags":["internal-identity"],"summary":"Get Identity Config","description":"Return ``{\"identity_root\": \"<base64>\"}`` for ``tenant_id``.\n\nTenant-scoped: the caller must be the tenant itself. This is the path\ntenant-app uses (it holds a per-tenant M2M identity).","operationId":"get_identity_config_internal_identity_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/identity-config/by-tenant/{tenant_id}":{"get":{"tags":["internal-identity"],"summary":"Get Identity Config By Tenant","description":"System-caller variant of the above, for SHARED fleet services.\n\nThe tracking-gateway serves every tenant from one process, so it cannot\npresent a per-tenant token the way tenant-app does — yet it needs the same\n``tenant_identity_root`` to verify ``tstr_id`` tokens and compute the\nidentity hashes that must MATCH the ones tenant-app derives, or contact\nmatching and email-click identification break across the two services.\n\n``require_system_caller`` restricts this to allow-listed fleet machines\n(see config.expected_*_outbound_sub); a tenant-scoped token is rejected.\nThe root still travels plaintext over the authenticated M2M channel, the\nsame trust model documented for the tenant-scoped route above — it simply\nadmits a second first-party consumer that legitimately needs it.","operationId":"get_identity_config_by_tenant_internal_identity_config_by_tenant__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/usage":{"get":{"tags":["internal-usage"],"summary":"Get Usage Rollups","description":"Return LLM usage rollups for *tenant_id* within [period_start, period_end].\n\nThe tenant is in the URL path so ``validate_internal_caller`` cross-checks a\ntenant-scoped token against it (and its H1 guard, which rejects tenant\ncallers on tenant-less paths, does not fire). System callers may read any\ntenant; a tenant caller may only read its own.","operationId":"get_usage_rollups_internal_tenants__tenant_id__usage_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"period_start","in":"query","required":true,"schema":{"type":"string","title":"Period Start"}},{"name":"period_end","in":"query","required":true,"schema":{"type":"string","title":"Period End"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Usage Rollups Internal Tenants  Tenant Id  Usage Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/usage-channels":{"get":{"tags":["internal-usage"],"summary":"Get Channel Usage Rollups","description":"Return channel usage rollups for *tenant_id* within [period_start, period_end].\n\nThe tenant is in the URL path so ``validate_internal_caller`` cross-checks a\ntenant-scoped token against it (and its H1 guard, which rejects tenant\ncallers on tenant-less paths, does not fire). System callers may read any\ntenant; a tenant caller may only read its own.","operationId":"get_channel_usage_rollups_internal_tenants__tenant_id__usage_channels_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"period_start","in":"query","required":true,"schema":{"type":"string","title":"Period Start"}},{"name":"period_end","in":"query","required":true,"schema":{"type":"string","title":"Period End"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Channel Usage Rollups Internal Tenants  Tenant Id  Usage Channels Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/usage-series":{"get":{"tags":["internal-usage"],"summary":"Get Usage Series","description":"Return all-metric daily rollups aggregated to *grain* for *tenant_id*.\n\nThe tenant is in the URL path so ``validate_internal_caller`` can cross-check\na tenant-scoped token against it (and so its H1 guard, which rejects tenant\ncallers on tenant-less paths, does not fire). System callers may read any\ntenant; a tenant caller may only read its own.\n\ngrain ∈ {day, week, month, year}. 'hour' is intentionally unsupported —\nonly daily buckets are metered. No USD is returned.","operationId":"get_usage_series_internal_tenants__tenant_id__usage_series_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"grain","in":"query","required":true,"schema":{"type":"string","title":"Grain"}},{"name":"start","in":"query","required":true,"schema":{"type":"string","title":"Start"}},{"name":"end","in":"query","required":true,"schema":{"type":"string","title":"End"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Usage Series Internal Tenants  Tenant Id  Usage Series Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/cap-state":{"get":{"tags":["internal-cap-state"],"summary":"Get Cap State","description":"Return all metric cap state rows for a tenant, plus the effective\n``subscription_status`` (active/grace/expired/canceled/none) so the\ntenant-app can distinguish a no-subscription/expired block from an\nover-quota block.\n\nTenant-scoped M2M callers may only read their own state.\nSystem callers (platform services) may read any tenant.\n\nIf the cap state table is empty but an active subscription exists,\nevaluation is triggered inline so the first request always returns\ncurrent data rather than an empty list.","operationId":"get_cap_state_internal_tenants__tenant_id__cap_state_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Cap State Internal Tenants  Tenant Id  Cap State Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/features":{"get":{"tags":["internal-features"],"summary":"Get Features","description":"Tenant-scoped callers read only their own tenant; system callers read any.\n\nNever 404: tenant-app reads a 404 as a platform-cloud older than this route and turns\nevery feature on (A13); an unknown tenant answers 200 with the default-resolved set.","operationId":"get_features_internal_tenants__tenant_id__features_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Features Internal Tenants  Tenant Id  Features Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/registered-api-client":{"get":{"tags":["internal-registered-api-clients"],"summary":"Get Registered Api Client","operationId":"get_registered_api_client_internal_tenants__tenant_id__registered_api_client_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"client_id","in":"query","required":true,"schema":{"type":"string","minLength":1,"maxLength":255,"title":"Client Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Registered Api Client Internal Tenants  Tenant Id  Registered Api Client Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/app-base-url":{"get":{"tags":["internal"],"summary":"Get Tenant App Base Url","description":"Resolve ``tenant_id``'s server-side tenant-app base URL.\n\nReturns ``{\"base_url\": <url>|None}``. Safe to cache per tenant for\nminutes: it changes only when an operator edits the deployment wizard.","operationId":"get_tenant_app_base_url_internal_tenants__tenant_id__app_base_url_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Tenant App Base Url Internal Tenants  Tenant Id  App Base Url Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/entitlement-summary":{"get":{"tags":["internal-entitlements"],"summary":"Get Entitlement Summary","description":"Return plan metadata + LLM credit position + storage object count.\n\nTenant-scoped callers may only read their own summary; the per-tenant URL\ncross-tenant check in validate_internal_caller already enforces this, plus\nan explicit guard for system callers passing a foreign id.\n\n``include_pending_change`` adds the scheduled change this tenant has at\nStripe (spec 2026-10-05 §C4) — the Plan tab's line and its cancel control.\nFrom the same Stripe read it also adds ``ending_at`` (the ISO day the\nsubscription stops, ``null`` if it is not ending) and, on each ``addons``\nline, ``purchased_at``, ``lookup_key`` and ``renews_at`` (plan 2026-10-07,\nTask 5). All of them are absent unless asked for, and a Stripe outage omits\nthem too: absent means \"nobody asked\", never \"not ending\".\nOpt-in because it is the one thing in this payload that costs a Stripe\ncall, and this payload is also what the Usage tab polls every 30 s; see\n``build_entitlement_summary``. A plain ``bool`` default, like tenant-app's\nown ``refresh`` on the proxy in front of this one, so a direct call that\nomits it gets a real ``False`` rather than a truthy ``Query`` sentinel.","operationId":"get_entitlement_summary_internal_tenants__tenant_id__entitlement_summary_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"include_pending_change","in":"query","required":false,"schema":{"type":"boolean","default":false,"title":"Include Pending Change"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Entitlement Summary Internal Tenants  Tenant Id  Entitlement Summary Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing-session":{"post":{"tags":["internal-billing"],"summary":"Create Billing Session","operationId":"create_billing_session_internal_tenants__tenant_id__billing_session_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingSessionIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Create Billing Session Internal Tenants  Tenant Id  Billing Session Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/catalog":{"get":{"tags":["internal-billing"],"summary":"Get Billing Catalog","description":"Which plans and add-ons this tenant may see — filtered by the guard.","operationId":"get_billing_catalog_internal_tenants__tenant_id__billing_catalog_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Billing Catalog Internal Tenants  Tenant Id  Billing Catalog Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/preview":{"post":{"tags":["internal-billing"],"summary":"Preview Billing Change","description":"Proration preview for a proposed add-on purchase or plan change.","operationId":"preview_billing_change_internal_tenants__tenant_id__billing_preview_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingChangeIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Preview Billing Change Internal Tenants  Tenant Id  Billing Preview Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/apply":{"post":{"tags":["internal-billing"],"summary":"Apply Billing Change","description":"Perform a proposed add-on purchase or plan change.","operationId":"apply_billing_change_internal_tenants__tenant_id__billing_apply_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/BillingApplyIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Apply Billing Change Internal Tenants  Tenant Id  Billing Apply Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/pending-change/cancel":{"post":{"tags":["internal-billing"],"summary":"Cancel Pending Billing Change","description":"Release the schedule holding this tenant's pending change, leaving the\nsubscription exactly as it is (spec 2026-10-05 §C3).\n\n``{\"cancelled\": True, \"effective_at\": <the date it would have started>}``,\nor ``{\"cancelled\": False}`` when there was nothing to cancel — a second\nclick, or one racing the renewal that already applied the change. That is\n§C3's own \"says so rather than appearing to do nothing\", in the other\ndirection, and it is why the cache bust below is conditional: a cancel that\nundid nothing must not throw away a summary that is still correct.\n\nThe SAME guard chain the apply route takes, and for the same reasons:\n`_cross_tenant_guard` first, because it is pure and a wrong-tenant caller\nmust never pay for a lock its always-coming 403 makes pointless; then the\nper-tenant advisory lock, because a cancel racing an apply is precisely\nwhat that lock exists for (the apply recomputes from a schedule this would\nrelease underneath it); then Stripe configured, a linked subscription, and\n`may_self_serve` inside the mutation.\n\nNo `require_offered` and no `_guard_inputs` customer read: nothing is being\nbought, so there is no catalogue membership to check, and `may_self_serve`\nneeds only what the subscription row already carries — `has_custom_price`\nis passed False rather than read from Stripe, which is safe here and ONLY\nhere: a custom-priced tenant is refused by this route's own account rules\nonly if they are also comped or invoiced, and letting one undo a change\nthey can see takes nothing away. Every other route pays for that read\nbecause it is about to CHARGE.\n\nWrites ONE local row, as the cancellation's undo does: ``billing.pending_change_cancelled`` in\n``audit_log`` (`_stage_pending_cancel_audit`), staged and flushed BEFORE the Stripe call and\ncommitted only AFTER it has answered, in the transaction that holds the per-tenant lock. Before,\nso that a row the database refuses fails the request while nothing has changed at Stripe; after,\nso that a refused, failed or unconfirmed cancel leaves no row (the exception rolls the session\nback) and nothing commits while the lock is still needed. Without it the trail has a\n``billing.plan_changed`` with a start date still ahead of it for a change the customer has since\ntaken back, and support reading it tells them their plan moves on that date.","operationId":"cancel_pending_billing_change_internal_tenants__tenant_id__billing_pending_change_cancel_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CancelPendingChangeIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Cancel Pending Billing Change Internal Tenants  Tenant Id  Billing Pending Change Cancel Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/resume":{"post":{"tags":["internal-billing"],"summary":"Resume Billing Subscription","description":"Undo a cancellation — \"Keep my subscription\" (spec 2026-10-07 §E).\n\n``{\"resumed\": True, \"effective_at\": <the date it would have stopped>}``, or\n``{\"resumed\": False}`` when the subscription was not stopping — a second click, or one racing\nthe undo that already landed, which must not read as having undone something. That is also why\nthe cache bust below is conditional: an undo that undid nothing must not throw away a summary\nthat is still correct.\n\nIts own small route, mirroring `/billing/pending-change/cancel`: it confirms no figures, so it\nneeds none of the preview guards, and giving it the `/apply` shape would force a meaningless\npreview round trip on a customer who is trying to stay. It takes the SAME guard chain that\nroute takes, for the same reasons — `_cross_tenant_guard` first, then the per-tenant advisory\nlock (an undo racing an apply is what it exists for: the apply recomputes from a schedule this\nwould write to), then Stripe configured, a linked subscription, and `may_self_serve` inside\nthe mutation.\n\nNo `require_offered` and no `_guard_inputs` customer read, for `cancel_pending_billing_change`'s\nreasons: nothing is bought, and `has_custom_price` is passed False — which is safe here and\nONLY here, because it exists to keep a negotiated customer away from list prices, and keeping a\nsubscription they already hold takes nothing from them. The comped and invoiced refusals still\nbite, as they come off the subscription ROW read locally.\n\nWrites ONE local row, as the cancellation it undoes did: ``billing.cancellation_withdrawn`` in\n``audit_log`` (`_stage_withdrawal_audit`), staged and flushed BEFORE the Stripe call and\ncommitted only AFTER it has answered — in the transaction that holds the per-tenant lock — so\nthat a refused, failed or unconfirmed undo leaves no row, and the trail never shows a\ncancellation as withdrawn that is still in force. Without it the trail has a\n``billing.cancellation_requested`` for a subscription that is still running, and support\nreading it concludes the customer left. And the subscription row's `cancel_at` mirror is\ncleared in the same commit (`sync_cancel_at`, §I-RESULTS 14). Nothing else is written\nlocally: Stripe is the record of the subscription, and the webhook converges the rest.","operationId":"resume_billing_subscription_internal_tenants__tenant_id__billing_resume_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ResumeSubscriptionIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Resume Billing Subscription Internal Tenants  Tenant Id  Billing Resume Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/billing/checkout":{"post":{"tags":["internal-billing"],"summary":"Start Billing Checkout","description":"First purchase for a tenant with no subscription, checked against its offers.\n\nEvery refusal that needs no Stripe call comes first — no row, a comped or\nwire account, a plan or Price outside the offer set — and only then the\nchecks that may ask Stripe: whether the linked subscription is alive, and\nthe customer read behind the full account guard. Last, inside\n`start_checkout`, one open checkout per tenant: a session still open for\nthe same Price is handed back instead of a second one\n(`billing/checkout_sessions.py`). Its 409 text is the same neutral\n`CHECKOUT_ALREADY_SUBSCRIBED`.\n\nWrites ONE local row, and only once Stripe has handed back a link: ``billing.checkout_started``\n(`_record_checkout_started`). It records an INTENT. This route changes no subscription, so the\nrow says a checkout was begun and never that anything was bought; the purchase arrives later by\nwebhook. A checkout that could not be started, whether refused or failed at Stripe, writes\nnothing.","operationId":"start_billing_checkout_internal_tenants__tenant_id__billing_checkout_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CheckoutIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Start Billing Checkout Internal Tenants  Tenant Id  Billing Checkout Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/support/config":{"get":{"tags":["support"],"summary":"Support Config","description":"What the panel needs before it makes any call that could fail.\n\n``enabled`` is whether a client can be built, by the same function the other\nroutes call, so it can never say yes to a credential they will refuse.","operationId":"support_config_internal_tenants__tenant_id__support_config_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Support Config Internal Tenants  Tenant Id  Support Config Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/support/tickets":{"get":{"tags":["support"],"summary":"List Tickets","operationId":"list_tickets_internal_tenants__tenant_id__support_tickets_get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"cursor","in":"query","required":false,"schema":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cursor"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response List Tickets Internal Tenants  Tenant Id  Support Tickets Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}},"post":{"tags":["support"],"summary":"Create Ticket","operationId":"create_ticket_internal_tenants__tenant_id__support_tickets_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CreateTicketIn"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Create Ticket Internal Tenants  Tenant Id  Support Tickets Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/support/tickets/{ticket_id}":{"get":{"tags":["support"],"summary":"Get Ticket","operationId":"get_ticket_internal_tenants__tenant_id__support_tickets__ticket_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"ticket_id","in":"path","required":true,"schema":{"type":"integer","title":"Ticket Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Ticket Internal Tenants  Tenant Id  Support Tickets  Ticket Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/tenants/{tenant_id}/support/uploads":{"post":{"tags":["support"],"summary":"Upload","operationId":"upload_internal_tenants__tenant_id__support_uploads_post","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"$ref":"#/components/schemas/Body_upload_internal_tenants__tenant_id__support_uploads_post"}}}},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Upload Internal Tenants  Tenant Id  Support Uploads Post"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/service-endpoints/{tenant_id}":{"get":{"tags":["internal"],"summary":"Get Service Endpoints","operationId":"get_service_endpoints_internal_service_endpoints__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Service Endpoints Internal Service Endpoints  Tenant Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/internal/model-config/{tenant_id}":{"get":{"tags":["model-config"],"summary":"Get Model Config","description":"Return the resolved model configuration for ``tenant_id``.\n\nThe ``{tenant_id}`` path segment is required: ``validate_internal_caller``\ncross-checks a tenant-scoped token against the URL tenant (CrossTenantError\notherwise), and its H1 guard (2026-06-10) rejects any URL-tenant-less route\nwith \"system caller required\". Without the segment the tenant-app's own\ntenant-scoped token was 403'd and the caller fell back to a direct\nOPENAI_API_KEY it must not need.\n\nOnly tenant-scoped M2M tokens are accepted (matching ``{tenant_id}``); the\nconfig carries the tenant's gateway virtual key, so system tokens are 403'd.","operationId":"get_model_config_internal_model_config__tenant_id__get","parameters":[{"name":"tenant_id","in":"path","required":true,"schema":{"type":"string","title":"Tenant Id"}},{"name":"authorization","in":"header","required":false,"schema":{"type":"string","default":"","title":"Authorization"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"object","additionalProperties":true,"title":"Response Get Model Config Internal Model Config  Tenant Id  Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/public/demo-access":{"post":{"tags":["demo"],"summary":"Demo Access","operationId":"demo_access_public_demo_access_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DemoAccessIn"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DemoAccessOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/.well-known/oauth-protected-resource":{"get":{"tags":["connect"],"summary":"Connect Protected Resource Metadata","description":"RFC 9728 metadata for the platform resource. Unauthenticated.","operationId":"connect_protected_resource_metadata__well_known_oauth_protected_resource_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":true,"type":"object","title":"Response Connect Protected Resource Metadata  Well Known Oauth Protected Resource Get"}}}}}}},"/v1/workspace":{"get":{"tags":["connect"],"summary":"Get Workspace","description":"The workspace of the organization this token is bound to, and nothing else.\n\nOrder: a usable bearer, Clerk says active, the platform audience, an\norganization, the per-organization limit, then the lookup. Every \"no\nworkspace\" is one 404, so the route says nothing about any organization\nbut the caller's own.","operationId":"get_workspace_v1_workspace_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/WorkspaceOut"}}}}}}}},"components":{"schemas":{"AddMembershipIn":{"properties":{"user_id":{"type":"string","title":"User Id"},"role":{"type":"string","title":"Role"}},"type":"object","required":["user_id","role"],"title":"AddMembershipIn"},"AddonCatalogFinding":{"properties":{"reason":{"type":"string","title":"Reason"},"price_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Price Id"},"lookup_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lookup Key"},"product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"interval":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Interval"},"interval_count":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Interval Count"}},"type":"object","required":["reason","price_id","lookup_key","product_id","name","interval","interval_count"],"title":"AddonCatalogFinding","description":"An add-on Price Stripe carries that `_split_catalog` will not sell, and why.\n\nMirrors `platform-cloud/console/lib/types.ts::AddonCatalogFinding`; keep the two in sync by\nhand, as `AddonCatalogItem` and its console twin are."},"AddonCatalogItem":{"properties":{"lookup_key":{"type":"string","title":"Lookup Key"},"name":{"type":"string","title":"Name"},"unit_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unit Amount"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency"},"metric_type":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Metric Type"},"quota_per_unit":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Quota Per Unit"}},"type":"object","required":["lookup_key","name","unit_amount","currency","metric_type","quota_per_unit"],"title":"AddonCatalogItem","description":"Mirrors `platform-cloud/console/lib/types.ts::AddonCatalogItem`\nexactly — this IS that console type's backend contract, not a\nlookalike; keep the two in sync by hand since nothing generates either\nfrom the other."},"AddonCatalogList":{"properties":{"addons":{"items":{"$ref":"#/components/schemas/AddonCatalogItem"},"type":"array","title":"Addons"},"findings":{"items":{"$ref":"#/components/schemas/AddonCatalogFinding"},"type":"array","title":"Findings","default":[]}},"type":"object","required":["addons"],"title":"AddonCatalogList"},"AddonCreate":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"title":"Name"},"description":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Description"},"lookup_key":{"type":"string","maxLength":128,"minLength":1,"pattern":"^[a-z0-9][a-z0-9_-]*$","title":"Lookup Key"},"metric_type":{"type":"string","title":"Metric Type"},"quota_per_unit":{"type":"integer","maximum":9007199254740991.0,"minimum":1.0,"title":"Quota Per Unit"},"unit_amount":{"type":"integer","maximum":99999999.0,"minimum":0.0,"title":"Unit Amount"},"currency":{"type":"string","title":"Currency"},"offered_by_default":{"type":"boolean","title":"Offered By Default","default":true}},"additionalProperties":false,"type":"object","required":["name","lookup_key","metric_type","quota_per_unit","unit_amount","currency"],"title":"AddonCreate","description":"What an operator gives to create an add-on. Every field is something the add-on IS, and\na body that names anything else is REFUSED (422, naming the field) rather than ignored, which\nis pydantic's default: an `interval` would be dropped, answered 201, and leave the operator\nbelieving they had made a yearly add-on. The platform bills every add-on monthly, so there is\nno interval to ask for (see `StripeClient.create_addon`)."},"AddonCreated":{"properties":{"lookup_key":{"type":"string","title":"Lookup Key"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"metric_type":{"type":"string","title":"Metric Type"},"quota_per_unit":{"type":"integer","title":"Quota Per Unit"},"unit_amount":{"type":"integer","title":"Unit Amount"},"currency":{"type":"string","title":"Currency"},"offered_by_default":{"type":"boolean","title":"Offered By Default"}},"type":"object","required":["lookup_key","name","description","metric_type","quota_per_unit","unit_amount","currency","offered_by_default"],"title":"AddonCreated"},"AddonDetail":{"properties":{"lookup_key":{"type":"string","title":"Lookup Key"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"metric_type":{"type":"string","title":"Metric Type"},"quota_per_unit":{"type":"integer","title":"Quota Per Unit"},"unit_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unit Amount"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency"}},"type":"object","required":["lookup_key","name","description","metric_type","quota_per_unit","unit_amount","currency"],"title":"AddonDetail","description":"An add-on as its edit screen needs it: what it IS and cannot be changed to (the key, the\nmetric, the pack, the price) and what the operator may change (the name and the description,\nwhich are the Stripe Product's, and which `AddonCatalogItem` leaves out on purpose: product\ncopy never reaches the catalogue list)."},"AddonEdit":{"properties":{"name":{"anyOf":[{"type":"string","maxLength":128,"minLength":1},{"type":"null"}],"title":"Name"},"description":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Description"}},"additionalProperties":false,"type":"object","title":"AddonEdit","description":"The only things a PATCH changes: the Product's name and description. A body that names\nanything else is REFUSED (422, naming the field) and not half honoured: pydantic's default is\nto ignore an unknown field, so `{\"name\": \"x\", \"quota_per_unit\": 20000}` would answer 200 and\nquietly NOT do the second thing, which is exactly the answer that makes an operator believe a\npack was resized. The pack is fixed at creation (see the module docstring), and the price is\nchanged by its own route, which mints a new Price."},"AddonEditView":{"properties":{"lookup_key":{"type":"string","title":"Lookup Key"},"name":{"type":"string","title":"Name"},"description":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Description"},"metric_type":{"type":"string","title":"Metric Type"},"quota_per_unit":{"type":"integer","title":"Quota Per Unit"},"unit_amount":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Unit Amount"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency"},"holders":{"type":"integer","title":"Holders"}},"type":"object","required":["lookup_key","name","description","metric_type","quota_per_unit","unit_amount","currency","holders"],"title":"AddonEditView","description":"`AddonDetail` as the edit dialog opens on it: plus how many subscriptions hold the Price\nthis add-on is sold at today. That number is what a repricing grandfathers (\"47 existing\nholders keep $12/mo\"), and it is counted from Stripe each time it is asked, never remembered\nor assumed."},"AddonIn":{"properties":{"metric_type":{"type":"string","title":"Metric Type"},"amount":{"type":"integer","title":"Amount","description":"Granted in every allowance month from effective_from until the row is removed: an amount per month, not per billing term."},"effective_from":{"type":"string","format":"date","title":"Effective From"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"},"actor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Actor"}},"type":"object","required":["metric_type","amount","effective_from"],"title":"AddonIn"},"AddonOut":{"properties":{"id":{"type":"integer","title":"Id"},"tenant_id":{"type":"string","title":"Tenant Id"},"metric_type":{"type":"string","title":"Metric Type"},"amount":{"type":"integer","title":"Amount"},"kind":{"type":"string","title":"Kind"},"effective_from":{"type":"string","format":"date","title":"Effective From"},"source":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Source"}},"type":"object","required":["id","tenant_id","metric_type","amount","kind","effective_from","source"],"title":"AddonOut"},"AddonReprice":{"properties":{"unit_amount":{"type":"integer","maximum":99999999.0,"minimum":0.0,"title":"Unit Amount"},"expected_unit_amount":{"type":"integer","maximum":99999999.0,"minimum":0.0,"title":"Expected Unit Amount"}},"additionalProperties":false,"type":"object","required":["unit_amount","expected_unit_amount"],"title":"AddonReprice","description":"What a price change takes: the new amount, and the amount the operator was SHOWN as the\ncurrent one. Nothing else: the pack, the currency and the interval of the new Price are the old\nPrice's own, and a body that says otherwise (or asks to migrate the existing holders, which is\ndeliberately not offered) is REFUSED with a 422 naming the field, not ignored."},"AddonRepriced":{"properties":{"lookup_key":{"type":"string","title":"Lookup Key"},"currency":{"type":"string","title":"Currency"},"previous_unit_amount":{"type":"integer","title":"Previous Unit Amount"},"unit_amount":{"type":"integer","title":"Unit Amount"},"holders":{"type":"integer","title":"Holders"}},"type":"object","required":["lookup_key","currency","previous_unit_amount","unit_amount","holders"],"title":"AddonRepriced"},"AddonsListOut":{"properties":{"addons":{"items":{"$ref":"#/components/schemas/AddonOut"},"type":"array","title":"Addons"}},"type":"object","required":["addons"],"title":"AddonsListOut"},"AdminInviteSummary":{"properties":{"present":{"type":"boolean","title":"Present","default":false},"invitation_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Invitation Id"},"minted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Minted At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"},"accepted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Accepted At"}},"type":"object","title":"AdminInviteSummary","description":"Non-secret view of the stored first-admin invitation.\n\nDeliberately has NO url field: the link is an admin-escalation bearer\ntoken and is readable only through\nPOST /admin/tenants/{id}/reveal-admin-invite-link, which audits each read."},"AdoptTenantRequest":{"properties":{"clerk_org_id":{"type":"string","maxLength":128,"minLength":1,"title":"Clerk Org Id"},"name":{"anyOf":[{"type":"string","maxLength":256},{"type":"null"}],"title":"Name"}},"type":"object","required":["clerk_org_id"],"title":"AdoptTenantRequest"},"AdoptTenantResponse":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"name":{"type":"string","title":"Name"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"}},"type":"object","required":["tenant_id","clerk_org_id","name","slug"],"title":"AdoptTenantResponse"},"AggregateUsage":{"properties":{"as_of":{"type":"string","title":"As Of"},"months":{"type":"integer","title":"Months"},"indicators":{"items":{"$ref":"#/components/schemas/IndicatorSeries"},"type":"array","title":"Indicators"}},"type":"object","required":["as_of","months","indicators"],"title":"AggregateUsage"},"AllotmentIn":{"properties":{"metric_type":{"type":"string","title":"Metric Type"},"amount":{"type":"integer","title":"Amount"}},"type":"object","required":["metric_type","amount"],"title":"AllotmentIn"},"AllotmentOut":{"properties":{"metric_type":{"type":"string","title":"Metric Type"},"amount":{"type":"integer","title":"Amount"}},"type":"object","required":["metric_type","amount"],"title":"AllotmentOut"},"AllotmentsIn":{"properties":{"allotments":{"items":{"$ref":"#/components/schemas/AllotmentIn"},"type":"array","title":"Allotments"}},"type":"object","required":["allotments"],"title":"AllotmentsIn"},"AllotmentsOut":{"properties":{"allotments":{"items":{"$ref":"#/components/schemas/AllotmentOut"},"type":"array","title":"Allotments"}},"type":"object","required":["allotments"],"title":"AllotmentsOut"},"BillingApplyIn":{"properties":{"kind":{"type":"string","enum":["addon","plan_change","cancel"],"title":"Kind"},"lookup_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lookup Key"},"quantity":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Quantity"},"target_quantity":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Target Quantity"},"remove_lookup_keys":{"anyOf":[{"items":{"type":"string","minLength":1},"type":"array","minItems":1},{"type":"null"}],"title":"Remove Lookup Keys"},"plan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Id"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency"},"reason":{"anyOf":[{"type":"string","enum":["too_expensive","missing_features","switched_service","unused","customer_service","too_complex","low_quality","other"]},{"type":"null"}],"title":"Reason"},"comment":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Comment"},"promotion_code":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Promotion Code"},"request_id":{"type":"string","maxLength":64,"minLength":8,"pattern":"^[A-Za-z0-9_-]+$","title":"Request Id"},"proration_date":{"type":"integer","exclusiveMinimum":0.0,"title":"Proration Date"},"billed_now":{"type":"boolean","title":"Billed Now"},"cycle_restarts":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Cycle Restarts"},"change_kind":{"anyOf":[{"$ref":"#/components/schemas/ChangeKind"},{"type":"null"}]},"effective_at":{"anyOf":[{"type":"integer","exclusiveMinimum":0.0},{"type":"null"}],"title":"Effective At"},"replace_discount":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Replace Discount"},"expected_promotion_code":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Promotion Code"}},"additionalProperties":false,"type":"object","required":["kind","request_id","proration_date","billed_now"],"title":"BillingApplyIn","description":"An APPLY: the change, plus the id of the one confirmed action it is.\n\nRequired here and absent from `BillingChangeIn`: a preview is read-only\nand keyless, so only an apply names an action. See\n`mutations._action_intent` for why the key needs it."},"BillingChangeIn":{"properties":{"kind":{"type":"string","enum":["addon","plan_change","cancel"],"title":"Kind"},"lookup_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lookup Key"},"quantity":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Quantity"},"target_quantity":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Target Quantity"},"remove_lookup_keys":{"anyOf":[{"items":{"type":"string","minLength":1},"type":"array","minItems":1},{"type":"null"}],"title":"Remove Lookup Keys"},"plan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Id"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"currency":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Currency"},"reason":{"anyOf":[{"type":"string","enum":["too_expensive","missing_features","switched_service","unused","customer_service","too_complex","low_quality","other"]},{"type":"null"}],"title":"Reason"},"comment":{"anyOf":[{"type":"string","maxLength":500},{"type":"null"}],"title":"Comment"},"promotion_code":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Promotion Code"}},"additionalProperties":false,"type":"object","required":["kind"],"title":"BillingChangeIn","description":"One proposed change: an add-on purchase, a plan change or a cancellation,\ndiscriminated by ``kind`` — the shapes ``billing/mutations.py`` exposes as\n``*_addon``/``*_plan_change``/``*_cancel``. Validated here so a malformed body\n422s before ever reaching the guard, rather than failing inside\n``mutations.py`` on a ``None`` ``lookup_key``/``plan_id``.\n\nAn add-on change names exactly ONE of two amounts, and they move capacity\nin opposite directions only (spec 2026-10-05 §D2/§D3, Task 13):\n\n- ``quantity`` is a positive DELTA — buy this many MORE. Its ``ge=1`` keeps\n  a malformed body from ever reaching the guard, and\n  ``mutations._require_positive_quantity`` floors the same rule for callers\n  that never build this model. A purchase only ever increases held\n  quantity: ``_addon_change`` raises a held item's quantity or adds a new\n  item (D7) — true only because ``_billing_change`` SERIALIZES concurrent\n  applies for one tenant with a per-tenant Postgres advisory lock (I1,\n  quality review 2026-09-28), taken before any Stripe call; unserialized,\n  two overlapping applies for the same Price could each compute from the\n  same stale holdings and the second's write could drop or partly revert\n  the first's purchase.\n- ``target_quantity`` is an absolute TARGET — hold this many from the end\n  of the current month, zero meaning remove it. ``ge=0``, floored for\n  non-HTTP callers by ``mutations._require_target_quantity``; that it is\n  actually BELOW what is held is checked where the holding is read\n  (``mutations._addon_change``). ``mutations.InvalidQuantity``'s docstring\n  has why the reduce path is a target and not a negative delta.\n\n- ``remove_lookup_keys`` is the THIRD shape, and the only one that names\n  more than one add-on (spec 2026-10-15): remove each of these entirely,\n  from the end of the current month, as ONE change. \"Remove these three\" is\n  one intent with one outcome, so it is one request, one schedule and one\n  audit row, written at one date. It is a field of its own and not a list\n  in ``lookup_key`` for two reasons: the single-add-on request is what the\n  reduce stepper sends and must stay exactly what it was, and the NAME\n  carries the direction. It can only ever remove, so \"remove A and also buy\n  B\" is not a sentence this model can hold -- naming the batch beside\n  ``lookup_key``, ``quantity`` or ``target_quantity`` is a 422, as is naming\n  an add-on twice or none, and so is carrying it on any kind but an add-on\n  change. Keeping SOME packs of several add-ons would need an amount per\n  add-on; that is out of scope, and the reduce stepper stays one add-on at a\n  time. ``mutations._require_one_addon_request`` floors the same rules for\n  callers that never build this model.\n\nMembership is required on EVERY add-on change whatever the tenant holds\n(``mutations.preview_addon``'s docstring has why), on every add-on a batch\nnames.\n\nNeither amount is read for a ``plan_change``, which ignores both exactly as\nit has always ignored ``quantity``.\n\nA ``cancel`` names nothing: it ends the subscription at the end of the period\nalready paid for, whatever the subscription holds (spec 2026-10-07 §E), so it\nrequires no field, and ignores the plan and add-on ones. ``reason`` and\n``comment`` are the customer's own account of why — optional, never blocking —\nand are read by a cancel's APPLY only; they are stored locally and not sent to\nStripe (``_stage_cancellation_audit``).\n\n``promotion_code`` is the code a customer typed into the review step (spec\n2026-10-07 §A), carried on BOTH round trips — unlike every other optional\nfield here, because Stripe prices the code you PASS rather than the one\nattached (§G-RESULTS 3), so a preview made without it quotes a total the\napply will not charge. A ``plan_change`` alone may carry one; see\n``_check_fields_for_kind``.\n\n``extra=\"forbid\"`` (spec §E.3). Until this task the model declared no\n``model_config`` at all, so pydantic's default ``extra=\"ignore\"`` ACCEPTED\nand discarded a field it did not know: a ``coupon`` or ``promotion_code``\nposted before today was a 200 at full price with no error anywhere, which\nis the exact failure this feature exists to remove — and a typo\n(``promo_code``) would reintroduce it one character at a time. It lands on\nthe PREVIEW too, since this is that route's body as well, and on\n``BillingApplyIn`` by inheritance; the one production caller\n(``tenant-app/app/platform_client/client.py``) builds its body from a fixed\nkey set that ``tests/api/test_billing_promotion_codes.py`` pins against\nthese fields, so the 422 is reachable only by a caller that talks to\nplatform-cloud directly."},"BillingModeIn":{"properties":{"billing_mode":{"type":"string","title":"Billing Mode"},"trial_end":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trial End"}},"additionalProperties":false,"type":"object","required":["billing_mode"],"title":"BillingModeIn","description":"Set a tenant's billing mode, and optionally its trial end (spec 2026-10-07 §C4).\n\n``trial_end`` has THREE meanings, and they must never be confused (this is the footgun this\nmodel exists to close: an absent field was read as ``None`` and written to the column, so an\noperator extending a trial without re-sending the date silently set it to NULL, which is a\ntrial with no end: counted as misconfigured, and rendering the tenant no banner at all):\n\n* ABSENT: leave the stored value alone. The default.\n* a date (``YYYY-MM-DD``): set it. Extending a trial is this.\n* an explicit ``null``: clear it. Refused when ``billing_mode`` is ``trial``, because a trial\n  with no end is the misconfigured state.\n\nWhether a field was SENT is read from ``model_fields_set`` (``trial_end_given``), never from\nits value, because ``None`` is both the default and a meaningful statement. A key the model\ndoes not know is refused rather than ignored: a misspelt ``trialEnd`` would otherwise be an\nabsent ``trial_end``, i.e. \"leave alone\", a 200 that quietly did not extend anything."},"BillingSessionIn":{"properties":{"return_url":{"type":"string","maxLength":2048,"minLength":1,"title":"Return Url"},"capped_metric":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Capped Metric"},"flow":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Flow"}},"type":"object","required":["return_url"],"title":"BillingSessionIn"},"BlobConfigIn":{"properties":{"provider":{"type":"string","enum":["s3","azure","gcs"],"title":"Provider"},"bucket":{"type":"string","maxLength":256,"minLength":1,"title":"Bucket"},"public_bucket":{"anyOf":[{"type":"string","maxLength":256},{"type":"null"}],"title":"Public Bucket"},"prefix":{"type":"string","maxLength":512,"minLength":1,"title":"Prefix"},"region":{"anyOf":[{"type":"string","maxLength":64},{"type":"null"}],"title":"Region"},"secret_ref":{"type":"string","maxLength":256,"minLength":1,"title":"Secret Ref"},"extras":{"additionalProperties":true,"type":"object","title":"Extras"}},"type":"object","required":["provider","bucket","prefix","secret_ref"],"title":"BlobConfigIn","description":"Editable blob config shape — what the admin form submits."},"BlobConfigOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"is_override":{"type":"boolean","title":"Is Override"},"provider":{"type":"string","title":"Provider"},"bucket":{"type":"string","title":"Bucket"},"public_bucket":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Public Bucket"},"prefix":{"type":"string","title":"Prefix"},"region":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Region"},"secret_ref":{"type":"string","title":"Secret Ref"},"extras":{"additionalProperties":true,"type":"object","title":"Extras"}},"type":"object","required":["tenant_id","is_override","provider","bucket","prefix","region","secret_ref","extras"],"title":"BlobConfigOut","description":"Effective blob config — override OR resolved-from-defaults."},"Body_upload_internal_tenants__tenant_id__support_uploads_post":{"properties":{"file":{"type":"string","format":"binary","contentMediaType":"application/octet-stream","title":"File"}},"type":"object","required":["file"],"title":"Body_upload_internal_tenants__tenant_id__support_uploads_post"},"CancelPendingChangeIn":{"properties":{"request_id":{"type":"string","minLength":1,"title":"Request Id"}},"additionalProperties":false,"type":"object","required":["request_id"],"title":"CancelPendingChangeIn","description":"Undo whatever this tenant has scheduled (spec 2026-10-05 §C3). The\npending change is named by nothing here: §C1 makes the schedule attached to\nthe subscription the single source of truth, so the server finds it itself\nand the browser never handles a Stripe schedule id.\n\n``request_id`` is required and non-empty for the same reason\n``BillingApplyIn``'s is (D4): it keys Stripe's idempotency, so a second\nclick retries the SAME release instead of becoming a second one."},"CapOverrideIn":{"properties":{"metric_type":{"type":"string","title":"Metric Type"},"new_state":{"type":"string","title":"New State"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"},"actor":{"type":"string","title":"Actor"}},"type":"object","required":["metric_type","new_state","actor"],"title":"CapOverrideIn"},"ChangeKind":{"type":"string","enum":["increase","reduction"],"title":"ChangeKind","description":"When a requested change lands: one of the two moments of spec 2026-10-05\n§B. Two members and no third, on purpose: a change `classify_change` cannot\njudge is a REDUCTION, so the one unsafe fall-through a caller could write —\n\"not a reduction, so apply it now\" — never meets a change nobody could judge.\nWhether a REDUCTION is a verdict or that default is `ChangeVerdict.judged`'s\nto say, so the enum itself stays two-valued.\n\nA `str` enum, like `ResizeAction` and `SubscriptionState`, so a verdict\ncrosses HTTP as its word. `.value` is that word; `str(kind)` and an f-string\ngive the member's name (\"ChangeKind.REDUCTION\")."},"CheckoutIn":{"properties":{"plan_id":{"type":"string","minLength":1,"title":"Plan Id"},"cadence":{"type":"string","minLength":1,"title":"Cadence"},"currency":{"type":"string","minLength":1,"title":"Currency"},"return_url":{"type":"string","maxLength":2048,"minLength":1,"title":"Return Url"}},"additionalProperties":false,"type":"object","required":["plan_id","cadence","currency","return_url"],"title":"CheckoutIn","description":"A first purchase: one plan Price, named the way `plan_change` names it."},"ClerkStatusResponse":{"properties":{"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"member_count":{"type":"integer","title":"Member Count"},"max_allowed_memberships":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Allowed Memberships"},"pending_invitations_count":{"type":"integer","title":"Pending Invitations Count"}},"type":"object","required":["clerk_org_id","member_count","max_allowed_memberships","pending_invitations_count"],"title":"ClerkStatusResponse"},"CollectionIn":{"properties":{"collection_method":{"type":"string","title":"Collection Method"},"days_until_due":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Days Until Due","default":30}},"type":"object","required":["collection_method"],"title":"CollectionIn"},"ConsoleConfig":{"properties":{"clerk_host":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Clerk Host"}},"type":"object","required":["clerk_host"],"title":"ConsoleConfig"},"ConsumerLive":{"properties":{"stream":{"type":"string","title":"Stream"},"durable_name":{"type":"string","title":"Durable Name"},"last_active":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Active"},"num_pending":{"type":"integer","title":"Num Pending"},"num_ack_pending":{"type":"integer","title":"Num Ack Pending"},"num_redelivered":{"type":"integer","title":"Num Redelivered"}},"type":"object","required":["stream","durable_name","last_active","num_pending","num_ack_pending","num_redelivered"],"title":"ConsumerLive"},"CreateTenantBody":{"properties":{"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"admin_email":{"type":"string","format":"email","title":"Admin Email"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"},"url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Url"},"deployment_kind":{"type":"string","title":"Deployment Kind","default":"managed"},"usage_plan":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usage Plan"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"period_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period Start"},"period_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period End"},"trial_days":{"anyOf":[{"type":"integer","maximum":365.0,"minimum":1.0},{"type":"null"}],"title":"Trial Days"},"start_trial":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Start Trial"}},"type":"object","required":["name","admin_email"],"title":"CreateTenantBody","description":"What an operator gives to create a tenant.\n\n``start_trial`` is the operator's INTENT, carried on the wire instead of being inferred from\n``usage_plan`` (plan 2026-10-12). A blank ``usage_plan`` used to *mean* \"start a trial\" and a\nnamed one \"no trial\", which cannot say \"this plan, on a trial\". Three-valued on purpose:\n\n* ``None`` (absent): the old reading, so a caller that has never heard of the field is\n  unchanged. A named plan is that plan, ``comped``, with the cadence and period given (or\n  derived), and no trial. A blank one goes through the default-trial resolution\n  (``_resolve_start``): the plan the operator marked as the default trial plan, on a trial with\n  no card, or, when none is marked, the only plan offered as one.\n* ``True``: start a trial. On a named plan it is a trial ON that plan, which must be offered as\n  a trial (422 otherwise). With no plan named it is the default-trial resolution again.\n* ``False``: explicitly no trial: the named plan, or with none named the fallback plan.\n\n``trial_days`` is how long THIS tenant's trial runs, chosen per tenant and prefilled from the\ntrial plan's own length (§C2). It means something only when the outcome IS a trial, so it is\nREFUSED when the outcome is not one rather than quietly dropped: an operator who asked for a\n30-day trial must not be handed a ``comped`` tenant with none. Likewise ``period_start`` and\n``period_end`` are refused beside a trial, whose window is its length (``trial_days``),\nstarting today. Both are keyed on that outcome and not on whether ``usage_plan`` was blank."},"CreateTenantRequest":{"properties":{"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"admin_email":{"type":"string","format":"email","title":"Admin Email"},"slug":{"type":"string","maxLength":48,"minLength":1,"pattern":"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$","title":"Slug","description":"Subdomain label for this tenant (e.g. 'acme'). Must match the Clerk org slug and the managed-cloud DNS record (<slug>.app.domain.com). Lowercase alphanumeric and hyphens only; no leading or trailing hyphens. Immutable after provisioning."}},"type":"object","required":["name","admin_email","slug"],"title":"CreateTenantRequest"},"CreateTicketIn":{"properties":{"subject":{"type":"string","maxLength":150,"minLength":1,"title":"Subject"},"description":{"type":"string","maxLength":10000,"minLength":1,"title":"Description"},"category":{"type":"string","title":"Category","default":"question"},"priority":{"type":"string","title":"Priority","default":"normal"},"upload_tokens":{"items":{"type":"string"},"type":"array","maxItems":5,"title":"Upload Tokens"},"user_ref":{"type":"string","minLength":1,"title":"User Ref"},"user_email":{"type":"string","minLength":1,"title":"User Email"},"user_name":{"type":"string","minLength":1,"title":"User Name"},"plan":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan"},"app_version":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"App Version"},"origin_page":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Origin Page"}},"type":"object","required":["subject","description","user_ref","user_email","user_name"],"title":"CreateTicketIn"},"CredentialHealth":{"properties":{"policy_ok":{"type":"boolean","title":"Policy Ok"},"missing_pub":{"items":{"type":"string"},"type":"array","title":"Missing Pub"},"missing_sub":{"items":{"type":"string"},"type":"array","title":"Missing Sub"},"missing_pub_deny":{"items":{"type":"string"},"type":"array","title":"Missing Pub Deny"}},"type":"object","required":["policy_ok","missing_pub","missing_sub","missing_pub_deny"],"title":"CredentialHealth"},"CreditBalanceOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"balance":{"type":"string","title":"Balance"},"grants":{"items":{"$ref":"#/components/schemas/CreditGrantOut"},"type":"array","title":"Grants"}},"type":"object","required":["tenant_id","balance","grants"],"title":"CreditBalanceOut"},"CreditGrantIn":{"properties":{"amount_credits":{"anyOf":[{"type":"number","exclusiveMinimum":0.0},{"type":"string"}],"title":"Amount Credits"},"source":{"type":"string","title":"Source"}},"type":"object","required":["amount_credits","source"],"title":"CreditGrantIn"},"CreditGrantOut":{"properties":{"grant_id":{"type":"string","title":"Grant Id"},"tenant_id":{"type":"string","title":"Tenant Id"},"amount_credits":{"type":"string","title":"Amount Credits"},"remaining_credits":{"type":"string","title":"Remaining Credits"},"source":{"type":"string","title":"Source"}},"type":"object","required":["grant_id","tenant_id","amount_credits","remaining_credits","source"],"title":"CreditGrantOut"},"DeleteBody":{"properties":{"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"}},"type":"object","title":"DeleteBody"},"DemoAccessIn":{"properties":{"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"email":{"type":"string","format":"email","title":"Email"},"passcode":{"type":"string","maxLength":200,"title":"Passcode","default":""},"token":{"type":"string","maxLength":200,"title":"Token","default":""}},"type":"object","required":["name","email"],"title":"DemoAccessIn"},"DemoAccessOut":{"properties":{"granted":{"type":"boolean","title":"Granted"}},"type":"object","required":["granted"],"title":"DemoAccessOut"},"DeploymentConfigIn":{"properties":{"kind":{"type":"string","title":"Kind","default":"managed"},"url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Url"}},"type":"object","title":"DeploymentConfigIn","description":"Operator-supplied deployment registration body.\n\n``kind`` is a descriptive label for where the tenant-app runs\n(platform-hosted vs. tenant-hosted). ``url`` is the address\nplatform-cloud calls over M2M to reach it, and is required\nregardless of ``kind`` — a deployment can live inside the\nplatform's own infrastructure, a different public location, or on\ncustomer premises, so there is no platform-wide default to assume."},"DriftSummary":{"properties":{"checked":{"type":"integer","title":"Checked"},"drifted":{"items":{"$ref":"#/components/schemas/DriftTenant"},"type":"array","title":"Drifted"}},"type":"object","required":["checked","drifted"],"title":"DriftSummary"},"DriftTenant":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Name"},"missing_pub":{"items":{"type":"string"},"type":"array","title":"Missing Pub"},"missing_sub":{"items":{"type":"string"},"type":"array","title":"Missing Sub"},"missing_pub_deny":{"items":{"type":"string"},"type":"array","title":"Missing Pub Deny"}},"type":"object","required":["tenant_id","name","missing_pub","missing_sub","missing_pub_deny"],"title":"DriftTenant"},"EmailConfigOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"sendgrid_subuser_username":{"type":"string","title":"Sendgrid Subuser Username"},"sending_domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Sending Domain"},"ip_pool":{"type":"string","title":"Ip Pool"},"status":{"type":"string","title":"Status"},"last_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Error"},"max_calls_per_minute":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Calls Per Minute"},"max_recipients_per_hour":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Recipients Per Hour"},"max_recipients_per_day":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Recipients Per Day"},"default_max_calls_per_minute":{"type":"integer","title":"Default Max Calls Per Minute","default":0},"default_max_recipients_per_hour":{"type":"integer","title":"Default Max Recipients Per Hour","default":0},"default_max_recipients_per_day":{"type":"integer","title":"Default Max Recipients Per Day","default":0},"mode":{"type":"string","title":"Mode","default":"managed"},"byo_api_key_present":{"type":"boolean","title":"Byo Api Key Present","default":false},"byo_webhook_pubkey":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Byo Webhook Pubkey"},"byo_scopes_json":{"anyOf":[{"items":{},"type":"array"},{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Byo Scopes Json"},"byo_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Byo Validated At"},"subuser_send_key_present":{"type":"boolean","title":"Subuser Send Key Present","default":false},"subuser_send_key_minted_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Subuser Send Key Minted At"},"trial_domain":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trial Domain"},"trial_domain_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trial Domain Status"},"trial_domain_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trial Domain Error"},"trial_domain_attempts":{"type":"integer","title":"Trial Domain Attempts","default":0},"webhook_url":{"type":"string","title":"Webhook Url"}},"type":"object","required":["tenant_id","sendgrid_subuser_username","sending_domain","ip_pool","status","last_error","webhook_url"],"title":"EmailConfigOut"},"ExtendIn":{"properties":{"works_through":{"type":"string","format":"date","title":"Works Through"},"auto_renew_remaining":{"anyOf":[{"type":"integer","minimum":0.0},{"type":"null"}],"title":"Auto Renew Remaining"}},"additionalProperties":false,"type":"object","required":["works_through"],"title":"ExtendIn"},"ExtractIn":{"properties":{"urls":{"items":{"type":"string"},"type":"array","minItems":1,"title":"Urls"}},"type":"object","required":["urls"],"title":"ExtractIn"},"FindingOut":{"properties":{"signature":{"type":"string","title":"Signature"},"service":{"type":"string","title":"Service"},"category":{"type":"string","title":"Category"},"severity":{"type":"string","title":"Severity"},"status":{"type":"string","title":"Status"},"title":{"type":"string","title":"Title"},"evidence":{"additionalProperties":true,"type":"object","title":"Evidence"},"likely_cause":{"type":"string","title":"Likely Cause"},"suggested_fix":{"type":"string","title":"Suggested Fix"},"occurrences":{"type":"integer","title":"Occurrences","default":1}},"type":"object","required":["signature","service","category","severity","status","title","evidence","likely_cause","suggested_fix"],"title":"FindingOut"},"ForceReissueOut":{"properties":{"machine_id":{"type":"string","title":"Machine Id"},"secret_key":{"type":"string","title":"Secret Key"},"push_ok":{"type":"boolean","title":"Push Ok"},"push_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Push Error"}},"type":"object","required":["machine_id","secret_key","push_ok"],"title":"ForceReissueOut","description":"Response shape for force-reissue: credentials + push status."},"GlobalUsage":{"properties":{"tenants_active_24h":{"type":"integer","title":"Tenants Active 24H"},"events_24h":{"type":"integer","title":"Events 24H"}},"type":"object","required":["tenants_active_24h","events_24h"],"title":"GlobalUsage"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"HealthReport":{"properties":{"run":{"anyOf":[{"$ref":"#/components/schemas/RunOut"},{"type":"null"}]},"findings":{"items":{"$ref":"#/components/schemas/FindingOut"},"type":"array","title":"Findings"},"history":{"items":{"$ref":"#/components/schemas/RunOut"},"type":"array","title":"History","default":[]}},"type":"object","required":["run","findings"],"title":"HealthReport"},"IndicatorPoint":{"properties":{"month":{"type":"string","title":"Month"},"value":{"type":"number","title":"Value"}},"type":"object","required":["month","value"],"title":"IndicatorPoint"},"IndicatorSeries":{"properties":{"metric_type":{"type":"string","title":"Metric Type"},"label":{"type":"string","title":"Label"},"kind":{"type":"string","title":"Kind"},"unit":{"type":"string","title":"Unit"},"current_total":{"type":"number","title":"Current Total"},"series":{"items":{"$ref":"#/components/schemas/IndicatorPoint"},"type":"array","title":"Series"}},"type":"object","required":["metric_type","label","kind","unit","current_total","series"],"title":"IndicatorSeries"},"IngestPollerStatus":{"properties":{"source":{"type":"string","title":"Source"},"cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cursor"},"updated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Updated At"},"age_seconds":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Age Seconds"},"status":{"type":"string","title":"Status"}},"type":"object","required":["source","cursor","updated_at","age_seconds","status"],"title":"IngestPollerStatus"},"InviteIn":{"properties":{"email":{"type":"string","title":"Email"},"role":{"type":"string","title":"Role"},"redirect_url":{"type":"string","title":"Redirect Url"},"public_metadata":{"additionalProperties":true,"type":"object","title":"Public Metadata"}},"type":"object","required":["email","role","redirect_url"],"title":"InviteIn"},"JobDetailResponse":{"properties":{"job_id":{"type":"string","title":"Job Id"},"tenant_id":{"type":"string","title":"Tenant Id"},"job_type":{"type":"string","title":"Job Type"},"status":{"type":"string","title":"Status"},"created_by":{"type":"string","title":"Created By"},"created_at":{"type":"string","title":"Created At"},"completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed At"},"steps":{"items":{"$ref":"#/components/schemas/StepOut"},"type":"array","title":"Steps"}},"type":"object","required":["job_id","tenant_id","job_type","status","created_by","created_at","completed_at","steps"],"title":"JobDetailResponse"},"JobIdResponse":{"properties":{"job_id":{"type":"string","title":"Job Id"}},"type":"object","required":["job_id"],"title":"JobIdResponse"},"JobSummary":{"properties":{"job_id":{"type":"string","title":"Job Id"},"job_type":{"type":"string","title":"Job Type"},"status":{"type":"string","title":"Status"},"created_by":{"type":"string","title":"Created By"},"created_at":{"type":"string","title":"Created At"},"completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed At"}},"type":"object","required":["job_id","job_type","status","created_by","created_at","completed_at"],"title":"JobSummary"},"JobsListResponse":{"properties":{"jobs":{"items":{"$ref":"#/components/schemas/JobSummary"},"type":"array","title":"Jobs"}},"type":"object","required":["jobs"],"title":"JobsListResponse"},"LinkCustomerIn":{"properties":{"stripe_customer_id":{"type":"string","minLength":3,"title":"Stripe Customer Id"}},"type":"object","required":["stripe_customer_id"],"title":"LinkCustomerIn"},"M2MCredentialsOut":{"properties":{"machine_id":{"type":"string","title":"Machine Id"},"secret_key":{"type":"string","title":"Secret Key"}},"type":"object","required":["machine_id","secret_key"],"title":"M2MCredentialsOut","description":"Response shape for the admin reveal endpoint.\n\nSpec 2026-05-05 §5: field names changed from {client_id, client_secret}\nto {machine_id, secret_key} to match Clerk's actual primitives."},"ModelConfigBody":{"properties":{"model":{"type":"string","title":"Model"},"params":{"anyOf":[{"additionalProperties":true,"type":"object"},{"type":"null"}],"title":"Params"},"fallbacks":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Fallbacks"}},"type":"object","required":["model"],"title":"ModelConfigBody"},"MoveIn":{"properties":{"ips":{"items":{"type":"string"},"type":"array","minItems":1,"title":"Ips"}},"type":"object","required":["ips"],"title":"MoveIn"},"NatsConfigLiveOut":{"properties":{"fetched_at":{"type":"string","format":"date-time","title":"Fetched At"},"connections":{"additionalProperties":true,"type":"object","title":"Connections"},"streams":{"items":{"$ref":"#/components/schemas/StreamLive"},"type":"array","title":"Streams"},"consumers":{"items":{"$ref":"#/components/schemas/ConsumerLive"},"type":"array","title":"Consumers"}},"type":"object","required":["fetched_at","connections","streams","consumers"],"title":"NatsConfigLiveOut"},"NatsConfigOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"status":{"type":"string","title":"Status"},"account_pubkey":{"type":"string","title":"Account Pubkey"},"provisioned_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Provisioned At"},"streams":{"items":{"$ref":"#/components/schemas/StreamOut"},"type":"array","title":"Streams"},"account_limits":{"additionalProperties":true,"type":"object","title":"Account Limits"},"credential":{"$ref":"#/components/schemas/CredentialHealth"}},"type":"object","required":["tenant_id","status","account_pubkey","provisioned_at","streams","account_limits","credential"],"title":"NatsConfigOut"},"OffersIn":{"properties":{"plans":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","title":"Plans"},"addons":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","title":"Addons"}},"additionalProperties":false,"type":"object","required":["plans","addons"],"title":"OffersIn"},"OkOut":{"properties":{"ok":{"type":"boolean","title":"Ok","default":true}},"type":"object","title":"OkOut"},"OverrideIn":{"properties":{"state":{"type":"string","enum":["grant","revoke"],"title":"State"},"reason":{"type":"string","maxLength":1000,"minLength":1,"title":"Reason"}},"additionalProperties":false,"type":"object","required":["state","reason"],"title":"OverrideIn"},"PartnerCreate":{"properties":{"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"contact_email":{"type":"string","format":"email","title":"Contact Email"},"tenant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"}},"type":"object","required":["name","contact_email"],"title":"PartnerCreate"},"PartnerDetailOut":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"contact_email":{"type":"string","title":"Contact Email"},"tenant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"},"token_hint":{"type":"string","title":"Token Hint"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Revoked At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"sign_in_count":{"type":"integer","title":"Sign In Count"},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Seen At"},"link":{"type":"string","title":"Link"},"sign_ins":{"items":{"$ref":"#/components/schemas/SignInOut"},"type":"array","title":"Sign Ins"}},"type":"object","required":["id","name","contact_email","tenant_id","token_hint","revoked_at","created_at","sign_in_count","last_seen_at","link","sign_ins"],"title":"PartnerDetailOut"},"PartnerOut":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"contact_email":{"type":"string","title":"Contact Email"},"tenant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"},"token_hint":{"type":"string","title":"Token Hint"},"revoked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Revoked At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"sign_in_count":{"type":"integer","title":"Sign In Count"},"last_seen_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Seen At"}},"type":"object","required":["id","name","contact_email","tenant_id","token_hint","revoked_at","created_at","sign_in_count","last_seen_at"],"title":"PartnerOut"},"PartnerSecretOut":{"properties":{"id":{"type":"string","title":"Id"},"access_token":{"type":"string","title":"Access Token"},"link":{"type":"string","title":"Link"}},"type":"object","required":["id","access_token","link"],"title":"PartnerSecretOut","description":"What create and reissue answer with: the new link, ready to send."},"PartnersListOut":{"properties":{"partners":{"items":{"$ref":"#/components/schemas/PartnerOut"},"type":"array","title":"Partners"}},"type":"object","required":["partners"],"title":"PartnersListOut"},"PatchMembershipRoleIn":{"properties":{"role":{"type":"string","title":"Role"}},"type":"object","required":["role"],"title":"PatchMembershipRoleIn"},"PatchSubscriptionIn":{"properties":{"plan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Id"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"period_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period Start"},"period_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period End"}},"type":"object","title":"PatchSubscriptionIn"},"PauseBody":{"properties":{"services":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Services"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"}},"type":"object","title":"PauseBody"},"PlanCreate":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"title":"Name"},"features":{"items":{"type":"string"},"type":"array","title":"Features"},"billing_cadences":{"type":"string","title":"Billing Cadences","default":"[\"monthly\"]"},"currency":{"type":"string","title":"Currency","default":"usd"},"amounts":{"anyOf":[{"additionalProperties":{"type":"integer"},"type":"object"},{"type":"null"}],"title":"Amounts"}},"additionalProperties":false,"type":"object","required":["name","features"],"title":"PlanCreate","description":"What an operator gives to create a plan: a name, the cadences it is billed at, and what it\ncosts at each of them. There is NO `id` field, and a body that names one is REFUSED (422,\nnaming the field) rather than ignored, which is pydantic's default. The server mints the id\n(`_mint_plan_id`); one that was honoured is the bug this closes, and one that was silently\ndropped would leave an out-of-date console tab (which still sends the field) with a plan under\nan id it did not choose and an irreversible Stripe Product behind it.\n\n`amounts` is what makes the plan SELLABLE, and it is optional for one reason: a plan with no\nPrice is a real configuration (the trial plan, spec §C1, is provisioned onto and never\nbought), so a required amount would make the ordinary trial plan unconstructible. A plan\ncreated without one is born unsellable and the plans page says so (`no_price`) — which is the\n2026-10-12 defect's own symptom, now a choice rather than the only outcome.\n\n`features` is the opposite decision, and REQUIRED (owner decision 2026-10-24, \"pick at\ncreation\"): a new plan states which pilot features it grants, so a plan can never be born with\na quiet, unexamined default. An explicit `[]` is a real answer (\"no pilot features\") and is\naccepted; an OMITTED field is a 422, because the alternative is to read silence as `[]` and\nhand an out-of-date client a plan that grants nothing. Registry keys only, validated by the\nsame type `PUT /admin/plans/{id}/features` uses (`PlanFeatureKeys`)."},"PlanFeaturesIn":{"properties":{"features":{"items":{"type":"string"},"type":"array","title":"Features"}},"additionalProperties":false,"type":"object","required":["features"],"title":"PlanFeaturesIn"},"PlanOut":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"billing_cadences":{"type":"string","title":"Billing Cadences"},"active":{"type":"boolean","title":"Active"},"is_trial":{"type":"boolean","title":"Is Trial"},"is_default_trial":{"type":"boolean","title":"Is Default Trial"},"trial_days":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Trial Days"}},"type":"object","required":["id","name","billing_cadences","active","is_trial","is_default_trial","trial_days"],"title":"PlanOut"},"PlanRename":{"properties":{"name":{"type":"string","maxLength":128,"minLength":1,"title":"Name"}},"additionalProperties":false,"type":"object","required":["name"],"title":"PlanRename","description":"The only thing a PATCH changes. A body that names anything else is REFUSED (422, naming\nthe field) and not half honoured: pydantic's default is to ignore an unknown field, which\nwould answer 200 and quietly not do the other thing the caller asked for."},"PlanRepairIn":{"properties":{"reason":{"type":"string","title":"Reason"},"price_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Price Id"},"product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Id"},"transfer":{"type":"boolean","title":"Transfer","default":false},"confirm":{"type":"boolean","title":"Confirm","default":false}},"additionalProperties":false,"type":"object","required":["reason"],"title":"PlanRepairIn","description":"Which finding to fix, and on which Stripe object. Never the value to write.\n\n`extra=\"forbid\"` is load-bearing here and not a house style: a `lookup_key` field is EXACTLY\nthe failure this endpoint exists to remove — the key an operator retypes in the Stripe\ndashboard and must not get wrong — so a body carrying one is a 422 NAMING it, never a value to\ntrust. Every value written is re-derived server-side through the same helpers the diagnosis\nbuilds `expected_lookup_key` with (`price_lookup_key`), off the Price Stripe really holds.\n\n`price_id`/`product_id` are the finding's own fields, sent back so the server acts on the\nobject the operator was looking at rather than re-deriving which object that was from a\ncatalogue that may have changed underneath them. Both are OPTIONAL because the repairs have\ntwo different targets (`Repair.target`) — a Price for three of them, the plan's Product for\n`product_missing_plan_id` — and neither is trusted: the one the repair needs is required at\nthe gate, and must be proven to be this plan's before anything is written."},"PlanSellability":{"properties":{"plan_id":{"type":"string","title":"Plan Id"},"sellable":{"type":"boolean","title":"Sellable"},"sellable_cadences":{"items":{"type":"string"},"type":"array","title":"Sellable Cadences"},"findings":{"items":{"$ref":"#/components/schemas/PlanSellabilityFinding"},"type":"array","title":"Findings"}},"type":"object","required":["plan_id","sellable","sellable_cadences","findings"],"title":"PlanSellability","description":"Whether Stripe can sell one plan, and — when it cannot — why."},"PlanSellabilityFinding":{"properties":{"reason":{"type":"string","title":"Reason"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"price_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Price Id"},"lookup_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Lookup Key"},"product_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Product Id"},"expected_lookup_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Expected Lookup Key"}},"type":"object","required":["reason","cadence","price_id","lookup_key","product_id","expected_lookup_key"],"title":"PlanSellabilityFinding","description":"One reason a plan cannot be sold, and the Stripe object it is about.\n\nMirrors `platform-cloud/console/lib/types.ts::PlanSellabilityFinding`; keep the two in sync\nby hand, as `AddonCatalogItem` and its console twin are."},"PlanSellabilityList":{"properties":{"livemode":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Livemode"},"plans":{"items":{"$ref":"#/components/schemas/PlanSellability"},"type":"array","title":"Plans"}},"type":"object","required":["plans"],"title":"PlanSellabilityList"},"PlanTrialIn":{"properties":{"trial_days":{"anyOf":[{"type":"integer","maximum":365.0,"minimum":1.0},{"type":"null"}],"title":"Trial Days"}},"additionalProperties":false,"type":"object","title":"PlanTrialIn","description":"What marks a plan as the trial plan: optionally, how long its trials run. A body that names\nanything else is REFUSED (422, naming the field) and not ignored, the way `PlanRename` refuses\none.\n\n`trial_days` ABSENT (or null) means 'no length given', and the route then leaves the length\nthe plan already carries alone, or uses the 14-day default for a plan that is not the trial\nplan yet. It is never read as 'reset to the default': re-marking the trial plan from a client\nthat did not send the length must not quietly change it. A length is a whole number of days,\nat least one (a trial that has already ended is no trial) and at most `MAX_TRIAL_DAYS`."},"PlansListOut":{"properties":{"plans":{"items":{"$ref":"#/components/schemas/PlanOut"},"type":"array","title":"Plans"}},"type":"object","required":["plans"],"title":"PlansListOut"},"ProvisionIn":{"properties":{"clerk_org_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Clerk Org Id"}},"type":"object","title":"ProvisionIn"},"ProvisionOut":{"properties":{"account_pubkey":{"type":"string","title":"Account Pubkey"},"stream_name":{"type":"string","title":"Stream Name"},"status":{"type":"string","title":"Status"},"messages_lost":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Messages Lost"},"created":{"type":"boolean","title":"Created"}},"type":"object","required":["account_pubkey","stream_name","status","created"],"title":"ProvisionOut"},"PurgeOut":{"properties":{"stream":{"type":"string","title":"Stream"},"purged":{"type":"integer","title":"Purged"}},"type":"object","required":["stream","purged"],"title":"PurgeOut"},"QuotaReport":{"properties":{"captured_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Captured At"},"source":{"type":"string","title":"Source"},"rows":{"items":{"$ref":"#/components/schemas/QuotaRow"},"type":"array","title":"Rows"}},"type":"object","required":["captured_at","source","rows"],"title":"QuotaReport"},"QuotaRow":{"properties":{"service":{"type":"string","title":"Service"},"metric":{"type":"string","title":"Metric"},"used":{"type":"number","title":"Used"},"limit":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Limit"},"unit":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Unit"},"tier":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tier"},"pct":{"anyOf":[{"type":"number"},{"type":"null"}],"title":"Pct"},"status":{"type":"string","title":"Status"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["service","metric","used","status"],"title":"QuotaRow"},"RejectBody":{"properties":{"reason":{"type":"string","title":"Reason"}},"type":"object","required":["reason"],"title":"RejectBody"},"RemintOut":{"properties":{"credential":{"$ref":"#/components/schemas/CredentialHealth"},"pushed":{"type":"boolean","title":"Pushed"},"push_detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Push Detail","description":"Non-null only when the cache-invalidate push to tenant-app failed; carries the push error message."}},"type":"object","required":["credential","pushed"],"title":"RemintOut"},"RenameTenantBody":{"properties":{"name":{"type":"string","title":"Name"}},"type":"object","required":["name"],"title":"RenameTenantBody"},"RenameTenantResponse":{"properties":{"id":{"type":"string","title":"Id"},"slug":{"type":"string","title":"Slug"},"name":{"type":"string","title":"Name"}},"type":"object","required":["id","slug","name"],"title":"RenameTenantResponse"},"ReprovisionOut":{"properties":{"account_pubkey":{"type":"string","title":"Account Pubkey"},"stream_name":{"type":"string","title":"Stream Name"},"messages_lost":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Messages Lost"}},"type":"object","required":["account_pubkey","stream_name","messages_lost"],"title":"ReprovisionOut"},"ResendAdminInviteResponse":{"properties":{"status":{"type":"string","title":"Status"},"email":{"type":"string","title":"Email"},"url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Url"},"minted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Minted At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"}},"type":"object","required":["status","email"],"title":"ResendAdminInviteResponse"},"ResumeBody":{"properties":{"services":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Services"}},"type":"object","title":"ResumeBody"},"ResumeSubscriptionIn":{"properties":{"request_id":{"type":"string","maxLength":64,"minLength":8,"pattern":"^[A-Za-z0-9_-]+$","title":"Request Id"}},"additionalProperties":false,"type":"object","required":["request_id"],"title":"ResumeSubscriptionIn","description":"Undo a cancellation — \"Keep my subscription\" (spec 2026-10-07 §E). It names nothing: the\nserver finds what is ending from the subscription itself, so the browser never handles a\nStripe schedule id (§C1's rule, for the same reason as `CancelPendingChangeIn`).\n\n``request_id`` is required for the reason ``BillingApplyIn``'s is (D4): it keys Stripe's\nidempotency, so a second click retries the SAME undo instead of becoming a second one. It is\nheld to the same shape (`RequestId`) because it is written to logs."},"RetryResponse":{"properties":{"step_name":{"type":"string","title":"Step Name"},"status":{"type":"string","title":"Status"}},"type":"object","required":["step_name","status"],"title":"RetryResponse"},"RevealAdminInviteLinkResponse":{"properties":{"url":{"type":"string","title":"Url"},"minted_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Minted At"},"expires_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Expires At"}},"type":"object","required":["url"],"title":"RevealAdminInviteLinkResponse"},"RolloutIn":{"properties":{"state":{"type":"string","enum":["ga","beta","disabled"],"title":"State"}},"additionalProperties":false,"type":"object","required":["state"],"title":"RolloutIn"},"RotateServiceAuthSecretResponse":{"properties":{"service_auth_secret":{"type":"string","title":"Service Auth Secret","description":"Newly minted HMAC secret. Returned **once**; the operator must persist it on the tenant-app (replacing the previous value) before the tenant-app's next service-auth call. Cannot be recovered if lost — rotate again to mint a new one."}},"type":"object","required":["service_auth_secret"],"title":"RotateServiceAuthSecretResponse"},"RunOut":{"properties":{"id":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Id"},"status":{"type":"string","title":"Status"},"started_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Started At"},"finished_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Finished At"},"window_hours":{"type":"integer","title":"Window Hours"},"model":{"type":"string","title":"Model"},"source_status":{"additionalProperties":true,"type":"object","title":"Source Status"},"finding_count":{"type":"integer","title":"Finding Count"},"critical_count":{"type":"integer","title":"Critical Count"}},"type":"object","required":["id","status","started_at","finished_at","window_hours","model","source_status","finding_count","critical_count"],"title":"RunOut"},"SearchIn":{"properties":{"query":{"type":"string","minLength":1,"title":"Query"},"max_results":{"type":"integer","maximum":20.0,"minimum":1.0,"title":"Max Results","default":5}},"type":"object","required":["query"],"title":"SearchIn"},"SerpAnswerIn":{"properties":{"engine":{"type":"string","enum":["google_ai_overview","copilot"],"title":"Engine"},"query":{"type":"string","minLength":1,"title":"Query"}},"type":"object","required":["engine","query"],"title":"SerpAnswerIn"},"ServiceStatus":{"properties":{"name":{"type":"string","title":"Name"},"status":{"type":"string","title":"Status"},"latency_ms":{"type":"number","title":"Latency Ms"},"checked_at":{"type":"string","title":"Checked At"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["name","status","latency_ms","checked_at"],"title":"ServiceStatus"},"SetDomainsIn":{"properties":{"allowed_domains":{"items":{"type":"string"},"type":"array","title":"Allowed Domains"},"allow_empty":{"type":"boolean","title":"Allow Empty","default":false}},"type":"object","title":"SetDomainsIn"},"SignInOut":{"properties":{"created_at":{"type":"string","format":"date-time","title":"Created At"},"name":{"type":"string","title":"Name"},"email":{"type":"string","title":"Email"},"granted":{"type":"boolean","title":"Granted"},"client_ip":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Client Ip"}},"type":"object","required":["created_at","name","email","granted","client_ip"],"title":"SignInOut"},"SlugAvailabilityOut":{"properties":{"slug":{"type":"string","title":"Slug"},"status":{"type":"string","enum":["available","taken_by_tenant","taken_by_open_request","reserved"],"title":"Status"},"detail":{"type":"string","title":"Detail"}},"type":"object","required":["slug","status","detail"],"title":"SlugAvailabilityOut"},"SmsConfigOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"status":{"type":"string","title":"Status"},"mode":{"type":"string","title":"Mode"},"last_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Error"},"twilio_subaccount_sid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Twilio Subaccount Sid"},"twilio_messaging_service_sid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Twilio Messaging Service Sid"},"byo_account_sid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Byo Account Sid"},"byo_messaging_service_sid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Byo Messaging Service Sid"},"byo_validated_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Byo Validated At"},"byo_credentials_present":{"type":"boolean","title":"Byo Credentials Present","default":false},"max_sends_per_minute":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Sends Per Minute"},"max_sends_per_hour":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Sends Per Hour"},"max_sends_per_day":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Max Sends Per Day"},"default_max_sends_per_minute":{"type":"integer","title":"Default Max Sends Per Minute"},"default_max_sends_per_hour":{"type":"integer","title":"Default Max Sends Per Hour"},"default_max_sends_per_day":{"type":"integer","title":"Default Max Sends Per Day"},"inbound_webhook_url":{"type":"string","title":"Inbound Webhook Url"},"status_webhook_url":{"type":"string","title":"Status Webhook Url"},"byo_warnings":{"anyOf":[{"items":{"type":"string"},"type":"array"},{"type":"null"}],"title":"Byo Warnings"}},"type":"object","required":["tenant_id","status","mode","default_max_sends_per_minute","default_max_sends_per_hour","default_max_sends_per_day","inbound_webhook_url","status_webhook_url"],"title":"SmsConfigOut"},"StepOut":{"properties":{"step_name":{"type":"string","title":"Step Name"},"status":{"type":"string","title":"Status"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"},"started_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Started At"},"completed_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Completed At"}},"type":"object","required":["step_name","status","detail","started_at","completed_at"],"title":"StepOut"},"StreamLive":{"properties":{"name":{"type":"string","title":"Name"},"messages":{"type":"integer","title":"Messages"},"bytes":{"type":"integer","title":"Bytes"},"first_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Ts"},"last_ts":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Ts"},"consumer_count":{"type":"integer","title":"Consumer Count"}},"type":"object","required":["name","messages","bytes","first_ts","last_ts","consumer_count"],"title":"StreamLive"},"StreamOut":{"properties":{"name":{"type":"string","title":"Name"},"max_bytes":{"type":"integer","title":"Max Bytes"},"max_age_seconds":{"type":"integer","title":"Max Age Seconds"}},"type":"object","required":["name","max_bytes","max_age_seconds"],"title":"StreamOut"},"SubscriptionIn":{"properties":{"plan_id":{"type":"string","title":"Plan Id"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"period_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period Start"},"period_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period End"}},"type":"object","required":["plan_id"],"title":"SubscriptionIn"},"SubscriptionListItem":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"tenant_name":{"type":"string","title":"Tenant Name"},"tenant_status":{"type":"string","title":"Tenant Status"},"has_subscription":{"type":"boolean","title":"Has Subscription"},"plan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Id"},"plan_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Name"},"status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Status"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"current_period_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Current Period Start"},"current_period_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Current Period End"},"auto_renew_remaining":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Auto Renew Remaining"},"grace_until":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Grace Until"},"cancel_at":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Cancel At"},"billing_mode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Billing Mode"},"trial_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Trial End"},"works_through":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Works Through"},"extend_kind":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Extend Kind"},"extend_note":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Extend Note"},"cancel_is_deferred":{"type":"boolean","title":"Cancel Is Deferred","default":false},"stripe_linked":{"type":"boolean","title":"Stripe Linked","default":false}},"type":"object","required":["tenant_id","tenant_name","tenant_status","has_subscription"],"title":"SubscriptionListItem"},"SubscriptionListOut":{"properties":{"items":{"items":{"$ref":"#/components/schemas/SubscriptionListItem"},"type":"array","title":"Items"},"count":{"type":"integer","title":"Count"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["items","count","total"],"title":"SubscriptionListOut"},"SubscriptionOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"plan_id":{"type":"string","title":"Plan Id"},"cadence":{"type":"string","title":"Cadence"},"status":{"type":"string","title":"Status"},"current_period_start":{"type":"string","format":"date","title":"Current Period Start"},"current_period_end":{"type":"string","format":"date","title":"Current Period End"},"auto_renew_remaining":{"type":"integer","title":"Auto Renew Remaining"},"grace_until":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Grace Until"},"cancel_at":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Cancel At"}},"type":"object","required":["tenant_id","plan_id","cadence","status","current_period_start","current_period_end","auto_renew_remaining","grace_until"],"title":"SubscriptionOut"},"SuspendBody":{"properties":{"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"}},"type":"object","title":"SuspendBody"},"TenantDetail":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"status":{"type":"string","title":"Status"},"created_at":{"type":"string","title":"Created At"},"usage_30d":{"additionalProperties":true,"type":"object","title":"Usage 30D"},"deployment_kind":{"type":"string","title":"Deployment Kind","default":"managed"},"deployment_url":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Deployment Url"},"admin_email":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Admin Email"},"admin_invite":{"$ref":"#/components/schemas/AdminInviteSummary","default":{"present":false}}},"type":"object","required":["id","name","clerk_org_id","status","created_at","usage_30d"],"title":"TenantDetail"},"TenantDetailsResponse":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"status":{"type":"string","title":"Status"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"}},"type":"object","required":["id","name","clerk_org_id","status","slug"],"title":"TenantDetailsResponse"},"TenantOffersIn":{"properties":{"mode":{"type":"string","enum":["inherit","custom"],"title":"Mode"},"plans":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","title":"Plans"},"addons":{"items":{"type":"string","maxLength":128,"minLength":1},"type":"array","title":"Addons"}},"additionalProperties":false,"type":"object","required":["mode"],"title":"TenantOffersIn"},"TenantRequestCreate":{"properties":{"name":{"type":"string","maxLength":200,"minLength":1,"title":"Name"},"admin_email":{"type":"string","format":"email","title":"Admin Email"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"},"deployment_kind":{"type":"string","title":"Deployment Kind","default":"managed"},"usage_plan":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usage Plan"},"start_trial":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Start Trial"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"period_start":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period Start"},"period_end":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Period End"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"}},"type":"object","required":["name","admin_email"],"title":"TenantRequestCreate"},"TenantRequestOut":{"properties":{"id":{"type":"string","title":"Id"},"status":{"type":"string","title":"Status"},"name":{"type":"string","title":"Name"},"slug":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Slug"},"admin_email":{"type":"string","title":"Admin Email"},"deployment_kind":{"type":"string","title":"Deployment Kind"},"usage_plan":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Usage Plan"},"start_trial":{"anyOf":[{"type":"boolean"},{"type":"null"}],"title":"Start Trial"},"cadence":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Cadence"},"period_start":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Period Start"},"period_end":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Period End"},"notes":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notes"},"requested_by":{"type":"string","title":"Requested By"},"reviewed_by":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reviewed By"},"rejection_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Rejection Reason"},"tenant_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Tenant Id"},"job_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Job Id"},"created_at":{"type":"string","title":"Created At"}},"type":"object","required":["id","status","name","slug","admin_email","deployment_kind","usage_plan","start_trial","cadence","period_start","period_end","notes","requested_by","reviewed_by","rejection_reason","tenant_id","job_id","created_at"],"title":"TenantRequestOut"},"TenantSummary":{"properties":{"id":{"type":"string","title":"Id"},"name":{"type":"string","title":"Name"},"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"status":{"type":"string","title":"Status"},"created_at":{"type":"string","title":"Created At"}},"type":"object","required":["id","name","clerk_org_id","status","created_at"],"title":"TenantSummary"},"TenantsListResponse":{"properties":{"tenants":{"items":{"$ref":"#/components/schemas/TenantSummary"},"type":"array","title":"Tenants"},"count":{"type":"integer","title":"Count"},"total":{"type":"integer","title":"Total"}},"type":"object","required":["tenants","count","total"],"title":"TenantsListResponse"},"TrackingConfigOut":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"site_key":{"type":"string","title":"Site Key"},"status":{"type":"string","title":"Status"},"allowed_domains":{"items":{"type":"string"},"type":"array","title":"Allowed Domains"},"usage_blocked_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Usage Blocked At"}},"type":"object","required":["tenant_id","site_key","status"],"title":"TrackingConfigOut","description":"Mirrors web-artifact-mcp's ``TrackingConfigOut``.\n\nRestated rather than imported: the MCP is a separate deployable and\nplatform-cloud does not depend on its package."},"UpdateStreamIn":{"properties":{"max_bytes":{"type":"integer","maximum":107374182400.0,"minimum":16777216.0,"title":"Max Bytes"},"max_age_seconds":{"type":"integer","maximum":7776000.0,"minimum":3600.0,"title":"Max Age Seconds"}},"type":"object","required":["max_bytes","max_age_seconds"],"title":"UpdateStreamIn"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"},"WorkspaceOut":{"properties":{"workspace_url":{"type":"string","title":"Workspace Url"},"api_base_url":{"type":"string","title":"Api Base Url"},"organization_id":{"type":"string","title":"Organization Id"},"name":{"type":"string","title":"Name"}},"type":"object","required":["workspace_url","api_base_url","organization_id","name"],"title":"WorkspaceOut","description":"The answer to \"which workspace did this sign-in pick?\"."},"_BundleCreate":{"properties":{"id":{"type":"string","title":"Id"},"tenant_id":{"type":"string","title":"Tenant Id"},"country":{"type":"string","title":"Country"},"kind":{"type":"string","title":"Kind"},"submission":{"additionalProperties":true,"type":"object","title":"Submission"},"twilio_sid":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Twilio Sid"},"parent_bundle_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Parent Bundle Id"}},"type":"object","required":["id","tenant_id","country","kind","submission"],"title":"_BundleCreate"},"_ByoBody":{"properties":{"api_key":{"type":"string","title":"Api Key"}},"type":"object","required":["api_key"],"title":"_ByoBody"},"_PostBody":{"properties":{"project_id":{"type":"string","title":"Project Id"},"public_key":{"type":"string","title":"Public Key"},"secret_key":{"type":"string","title":"Secret Key"},"host":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Host"}},"type":"object","required":["project_id","public_key","secret_key"],"title":"_PostBody"},"_StatusUpdate":{"properties":{"status":{"type":"string","title":"Status"},"decision_reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Decision Reason"}},"type":"object","required":["status"],"title":"_StatusUpdate"},"_TestConnectionResult":{"properties":{"status":{"type":"string","title":"Status"},"code":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Code"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["status"],"title":"_TestConnectionResult"},"_ThrottlePatch":{"properties":{"max_sends_per_minute":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Max Sends Per Minute"},"max_sends_per_hour":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Max Sends Per Hour"},"max_sends_per_day":{"anyOf":[{"type":"integer","minimum":1.0},{"type":"null"}],"title":"Max Sends Per Day"}},"type":"object","title":"_ThrottlePatch"},"platform_cloud__api__admin__email_config___SwitchModeBody":{"properties":{"target":{"type":"string","title":"Target"},"api_key":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Api Key"},"ack":{"type":"boolean","title":"Ack","default":false}},"type":"object","required":["target"],"title":"_SwitchModeBody"},"platform_cloud__api__admin__health__SlackSendResult":{"properties":{"sent":{"type":"boolean","title":"Sent"},"alerts":{"type":"integer","title":"Alerts"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["sent","alerts"],"title":"SlackSendResult"},"platform_cloud__api__admin__quotas__SlackSendResult":{"properties":{"sent":{"type":"boolean","title":"Sent"},"alerts":{"type":"integer","title":"Alerts"},"metrics":{"type":"integer","title":"Metrics"},"source":{"type":"string","title":"Source"},"captured_at":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Captured At"},"detail":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Detail"}},"type":"object","required":["sent","alerts","metrics","source"],"title":"SlackSendResult"},"platform_cloud__api__admin__sms_config___SwitchModeBody":{"properties":{"target":{"type":"string","title":"Target"},"ack":{"type":"boolean","title":"Ack"}},"type":"object","required":["target","ack"],"title":"_SwitchModeBody"},"platform_cloud__api__admin__tenant_lifecycle__CreateTenantResponse":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"job_id":{"type":"string","title":"Job Id"},"plan_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Plan Id"},"billing_mode":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Billing Mode"},"trial_end":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Trial End"},"notice":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Notice"}},"type":"object","required":["tenant_id","job_id"],"title":"CreateTenantResponse"},"platform_cloud__api__tenants__CreateTenantResponse":{"properties":{"tenant_id":{"type":"string","title":"Tenant Id"},"clerk_org_id":{"type":"string","title":"Clerk Org Id"},"slug":{"type":"string","title":"Slug"},"admin_invitation_id":{"type":"string","title":"Admin Invitation Id"},"service_auth_secret":{"type":"string","title":"Service Auth Secret","description":"HMAC secret for tenant-app → platform-cloud request authentication. Returned **once** at tenant-create time. The operator must persist this value on the tenant-app (e.g. as an environment variable) immediately. If lost, rotate via POST /admin/tenants/{tenant_id}/rotate-service-auth-secret."}},"type":"object","required":["tenant_id","clerk_org_id","slug","admin_invitation_id","service_auth_secret"],"title":"CreateTenantResponse"}}}}