{
  "openapi": "3.1.0",
  "info": {
    "title": "Auth API",
    "description": "Authentication and token endpoints for Clams, served from `https://auth.clams.tech`.\n\nSee [authentication.md](authentication.md) for an end-to-end walkthrough (browser login session -> token exchange -> refresh).",
    "license": {
      "name": ""
    },
    "version": "1.2.0"
  },
  "paths": {
    "/.well-known/jwks.json": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "operationId": "jwks_docs",
        "responses": {
          "200": {
            "description": "JWKS document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiJwksSet"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/.well-known/openid-configuration": {
      "get": {
        "tags": [
          "Discovery"
        ],
        "operationId": "discovery_docs",
        "responses": {
          "200": {
            "description": "OIDC discovery document",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DiscoveryDocument"
                }
              }
            }
          },
          "500": {
            "description": "Internal error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/account/notices/{notice_id}/receipts": {
      "post": {
        "tags": [
          "Account"
        ],
        "operationId": "record_account_notice_receipt_docs",
        "parameters": [
          {
            "name": "notice_id",
            "in": "path",
            "description": "Stable account-notice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AccountNoticeReceiptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "Receipt recorded"
          },
          "400": {
            "description": "Invalid request or unknown notice id",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/auth/instance-binding-challenges": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "operationId": "create_instance_binding_challenge_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCreateInstanceBindingChallengeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Instance binding challenge created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiInstanceBindingChallengeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized for the instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/auth/logout": {
      "post": {
        "tags": [
          "Account"
        ],
        "operationId": "logout_docs",
        "responses": {
          "204": {
            "description": "Logged out"
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/auth/logout/all": {
      "post": {
        "tags": [
          "Account"
        ],
        "operationId": "logout_all_docs",
        "responses": {
          "204": {
            "description": "Logged out everywhere"
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/auth/whoami": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "whoami_docs",
        "responses": {
          "200": {
            "description": "Authenticated subject",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WhoamiResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/cancel": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "billing_cancel_docs",
        "responses": {
          "200": {
            "description": "Browser payment-cancel page"
          }
        }
      }
    },
    "/v1/billing/checkout/{checkout_token}/status": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "phoenixd_checkout_status_docs",
        "parameters": [
          {
            "name": "checkout_token",
            "in": "path",
            "description": "Opaque Phoenixd checkout token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status of a previously issued Phoenixd invoice; no new checkout is offered",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiPhoenixdCheckoutStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unknown checkout token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Provider or quote service unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/existing-root-migrations": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "begin_existing_root_migration_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiBeginExistingRootMigrationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Existing-root binding challenge created without a license or profile limit",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiInstanceBindingChallengeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid migration evidence",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Migration policy or proof eligibility denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/existing-root-migrations/complete": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "complete_existing_root_migration_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCompleteExistingRootMigrationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Existing-root binding completed without a capacity assignment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiExistingRootMigrationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or expired migration proof",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Migration policy denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instance-binding-challenges": {
      "post": {
        "tags": [
          "Billing Compatibility"
        ],
        "operationId": "create_legacy_instance_binding_challenge_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCreateInstanceBindingChallengeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Legacy instance binding challenge created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiInstanceBindingChallengeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized for the instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instances/{instance_id}/owner": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "billing_instance_owner_docs",
        "parameters": [
          {
            "name": "instance_id",
            "in": "path",
            "description": "Backend instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Billing owner status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingInstanceOwnerResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not the active billing owner",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instances/{instance_id}/owner/transfer": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "transfer_billing_instance_owner_docs",
        "parameters": [
          {
            "name": "instance_id",
            "in": "path",
            "description": "Backend instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiTransferBillingInstanceOwnerRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Billing owner transferred",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiTransferBillingInstanceOwnerResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or proof",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not the active billing owner",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instances/{target_instance_id}/replacement": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "discover_billing_instance_replacement_docs",
        "parameters": [
          {
            "name": "target_instance_id",
            "in": "path",
            "description": "Owner-authorized target instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Movable capacity allocations",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingInstanceReplacementDiscoveryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or conflicting replacement state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Target-bound SVC token or owner authorization required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instances/{target_instance_id}/replacement/complete": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "complete_billing_instance_replacement_docs",
        "parameters": [
          {
            "name": "target_instance_id",
            "in": "path",
            "description": "Owner-authorized target instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCompleteBillingInstanceReplacementRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Capacity allocation assigned to the target instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingInstanceReplacementResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request, proof, or replacement state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized to place the allocation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/instances/{target_instance_id}/replacement/prepare": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "prepare_billing_instance_replacement_docs",
        "parameters": [
          {
            "name": "target_instance_id",
            "in": "path",
            "description": "Owner-authorized target instance id",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiPrepareBillingInstanceReplacementRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Signing challenge or completed replacement",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiPrepareBillingInstanceReplacementResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid replacement state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized to replace the assignment",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/invoices": {
      "get": {
        "tags": [
          "Billing History"
        ],
        "operationId": "list_historical_invoices_docs",
        "parameters": [
          {
            "name": "offset",
            "in": "query",
            "description": "Zero-based offset; defaults to 0",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          },
          {
            "name": "limit",
            "in": "query",
            "description": "Page size from 1 to 100; defaults to 50",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Retained invoices for the authenticated subject, newest first; payment URLs and payable Lightning invoices are omitted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiHistoricalInvoicePageResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid page size",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Historical invoice storage unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/invoices/{invoice_id}": {
      "get": {
        "tags": [
          "Billing History"
        ],
        "operationId": "get_billing_invoice_docs",
        "parameters": [
          {
            "name": "invoice_id",
            "in": "path",
            "description": "Internal billing invoice id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Retained invoice status without a payment URL or payable Lightning invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingInvoiceResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Invoice not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/license": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "billing_license_docs",
        "responses": {
          "200": {
            "description": "Free compatibility status and optional latest historical invoice",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingLicenseResponse"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/profile-capacity/reservations": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "create_profile_capacity_reservation_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCreateProfileCapacityReservationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "Proof-checked free compatibility lease created; no paid capacity consumed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiProfileCapacityReservationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or instance proof",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized for the instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/profile-capacity/reservations/{reservation_id}/commit": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "commit_profile_capacity_reservation_docs",
        "parameters": [
          {
            "name": "reservation_id",
            "in": "path",
            "description": "Profile-capacity reservation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiUpdateProfileCapacityReservationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Free compatibility lease commit acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiProfileCapacityReservationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized for the instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/profile-capacity/reservations/{reservation_id}/release": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "release_profile_capacity_reservation_docs",
        "parameters": [
          {
            "name": "reservation_id",
            "in": "path",
            "description": "Profile-capacity reservation id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiUpdateProfileCapacityReservationRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Free compatibility lease release acknowledged",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiProfileCapacityReservationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or transition",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Subject is not authorized for the instance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/profile-capacity/revisions/validate": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "validate_profile_capacity_revision_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiValidateProfileCapacityRevisionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Free compatibility revision validation result",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiValidateProfileCapacityRevisionResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unusable token claim",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "503": {
            "description": "Instance binding unavailable",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/billing/return": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "billing_return_docs",
        "responses": {
          "200": {
            "description": "Browser payment-return page"
          }
        }
      }
    },
    "/v1/billing/webhooks/phoenixd": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "phoenixd_billing_webhook_docs",
        "responses": {
          "200": {
            "description": "Phoenixd webhook accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingWebhookResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid signature or payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/billing/webhooks/stripe": {
      "post": {
        "tags": [
          "Billing"
        ],
        "operationId": "stripe_billing_webhook_docs",
        "responses": {
          "200": {
            "description": "Stripe webhook accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiBillingWebhookResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid signature or payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "413": {
            "description": "Payload too large",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "500": {
            "description": "Server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/connections/oauth/credentials/access-token": {
      "post": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_access_token_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiConnectionOAuthAccessTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Short-lived provider access token",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthAccessTokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported OAuth provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/connections/oauth/credentials/{credential_ref}/cleanup": {
      "post": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_cleanup_docs",
        "parameters": [
          {
            "name": "credential_ref",
            "in": "path",
            "description": "Opaque hosted credential reference",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiConnectionOAuthCleanupRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Hosted credential disconnected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthCredentialStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Cleanup proof denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Hosted credential already absent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/connections/oauth/credentials/{credential_ref}/cleanup-challenge": {
      "post": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_cleanup_challenge_docs",
        "parameters": [
          {
            "name": "credential_ref",
            "in": "path",
            "description": "Opaque hosted credential reference",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiConnectionOAuthCleanupChallengeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Instance-bound cleanup challenge",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthCleanupChallengeResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "403": {
            "description": "Cleanup authority denied",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Hosted credential already absent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/connections/oauth/credentials/{credential_ref}/disconnect": {
      "post": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_disconnect_docs",
        "parameters": [
          {
            "name": "credential_ref",
            "in": "path",
            "description": "Opaque hosted credential reference",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hosted credential disconnected and deleted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthCredentialStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported OAuth provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "404": {
            "description": "Hosted credential already absent",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/connections/oauth/credentials/{credential_ref}/status": {
      "get": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_status_docs",
        "parameters": [
          {
            "name": "credential_ref",
            "in": "path",
            "description": "Opaque hosted credential reference",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Non-secret hosted credential status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthCredentialStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported OAuth provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/connections/oauth/{provider_key}/callback": {
      "get": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_callback_docs",
        "parameters": [
          {
            "name": "provider_key",
            "in": "path",
            "description": "Connection OAuth provider key",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "state",
            "in": "query",
            "description": "Provider callback state",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code",
            "in": "query",
            "description": "Provider authorization code; required when error is absent",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error",
            "in": "query",
            "description": "Provider authorization error code; required when code is absent",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error_description",
            "in": "query",
            "description": "Provider authorization error description",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "error_uri",
            "in": "query",
            "description": "Provider authorization error reference URI",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Hosted provider callback accepted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthCredentialStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported OAuth provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/connections/oauth/{provider_key}/start": {
      "post": {
        "tags": [
          "Connection OAuth"
        ],
        "operationId": "connection_oauth_start_docs",
        "parameters": [
          {
            "name": "provider_key",
            "in": "path",
            "description": "Connection OAuth provider key",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiConnectionOAuthStartRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Hosted provider authorization started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiConnectionOAuthStartResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request or unsupported OAuth provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/oauth-clients": {
      "post": {
        "tags": [
          "OAuth Clients"
        ],
        "operationId": "create_oauth_client_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiCreateOAuthClientRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "description": "OAuth client created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiCreateOAuthClientResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    },
    "/v1/token": {
      "post": {
        "tags": [
          "Tokens"
        ],
        "operationId": "token_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenApiTokenRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Tokens issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Auth failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/token/exchange": {
      "post": {
        "tags": [
          "Tokens"
        ],
        "operationId": "token_exchange_docs",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TokenExchangeRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Tokens issued",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefreshGrantResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Subject token invalid/expired/revoked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/web/login/session/start": {
      "post": {
        "tags": [
          "Login"
        ],
        "operationId": "login_session_start_docs",
        "parameters": [
          {
            "name": "x-clams-login-session-protocol",
            "in": "header",
            "description": "Login session protocol; current clients send 2",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginSessionStartRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Login session created",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginSessionStartResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "426": {
            "description": "Legacy login protocol disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    },
    "/v1/web/login/session/{login_session_id}": {
      "get": {
        "tags": [
          "Login"
        ],
        "operationId": "login_session_status_docs",
        "parameters": [
          {
            "name": "login_session_id",
            "in": "path",
            "description": "Login session id (UUID v7)",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "x-clams-login-session-poll-secret",
            "in": "header",
            "description": "Client-held polling proof returned by session start",
            "required": false,
            "schema": {
              "type": [
                "string",
                "null"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Login session status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LoginSessionStatusResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "401": {
            "description": "Invalid polling proof",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          },
          "426": {
            "description": "Legacy login protocol disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OpenApiErrorEnvelope"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AccountNoticeId": {
        "type": "string",
        "description": "Stable account notice identifier.",
        "enum": [
          "beta_2026_remaining_year_grant_v1"
        ]
      },
      "AccountNoticeReceiptEvent": {
        "type": "string",
        "description": "Receipt event submitted by a notice-capable client.",
        "enum": [
          "displayed",
          "acknowledged"
        ]
      },
      "AccountNoticeReceiptRequest": {
        "type": "object",
        "description": "Request body for recording an account-notice receipt.",
        "required": [
          "surface",
          "event"
        ],
        "properties": {
          "event": {
            "$ref": "#/components/schemas/AccountNoticeReceiptEvent",
            "description": "Receipt event being recorded."
          },
          "surface": {
            "$ref": "#/components/schemas/AccountNoticeSurface",
            "description": "Surface that displayed or acknowledged the notice."
          }
        }
      },
      "AccountNoticeResponse": {
        "type": "object",
        "description": "Notice payload returned to authenticated clients.",
        "required": [
          "notice_id",
          "surface",
          "title",
          "body",
          "expires_at_epoch"
        ],
        "properties": {
          "body": {
            "type": "string",
            "description": "Human-readable notice body."
          },
          "expires_at_epoch": {
            "type": "integer",
            "format": "int64",
            "description": "Epoch seconds after which clients should not display the notice.",
            "minimum": 0
          },
          "notice_id": {
            "$ref": "#/components/schemas/AccountNoticeId",
            "description": "Stable notice id used for receipts."
          },
          "surface": {
            "$ref": "#/components/schemas/AccountNoticeSurface",
            "description": "Surface this response is intended for."
          },
          "title": {
            "type": "string",
            "description": "Human-readable notice title."
          }
        }
      },
      "AccountNoticeSurface": {
        "type": "string",
        "description": "Authenticated surface where an account notice can be displayed.",
        "enum": [
          "login_success",
          "cli"
        ]
      },
      "ClientCredentialsGrantResponse": {
        "type": "object",
        "description": "Response payload for client credentials grant requests.",
        "required": [
          "access_token",
          "token_type",
          "expires_in",
          "audience"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "example": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJmZWVkYmFjayIsImV4cCI6MTcwMDAwMDAwMCwiaWF0IjoxNzAwMDAwMDAwLCJzZXNzaW9uX2lkIjoiMDE4OTBiOGMtNWNmZC03ZDVmLThmOTAtM2M3ZjRmNjJkODAxIiwic3ViIjoiODYyZmQ1ZWQtYWM5YS01YmZlLTk2ZjItYWIxZjUwMWEyYzk5IiwidXNlcl9pZCI6ImNsaWVudDpjbGlfMTIzIn0.signature"
          },
          "audience": {
            "$ref": "#/components/schemas/RefreshGrantAudience"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "example": 300,
            "minimum": 1
          },
          "token_type": {
            "type": "string",
            "example": "bearer"
          }
        }
      },
      "CodeChallengeMethod": {
        "type": "string",
        "description": "@impl(R-012) @s(S-012)\nEnum describing supported PKCE code challenge methods.",
        "enum": [
          "S256"
        ]
      },
      "DiscoveryDocument": {
        "type": "object",
        "description": "@impl(R-012) @s(S-012)\nSerializable OIDC discovery document that mirrors the HTTP response body.",
        "required": [
          "issuer",
          "jwks_uri",
          "authorization_endpoint",
          "token_endpoint",
          "device_authorization_endpoint",
          "code_challenge_methods_supported",
          "grant_types_supported"
        ],
        "properties": {
          "authorization_endpoint": {
            "type": "string",
            "format": "uri",
            "example": "https://auth.clams.tech/v1/web/pkce/start"
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CodeChallengeMethod"
            }
          },
          "device_authorization_endpoint": {
            "type": "string",
            "format": "uri",
            "example": "https://auth.clams.tech/v1/device/start"
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "issuer": {
            "type": "string",
            "format": "uri",
            "example": "https://auth.clams.tech"
          },
          "jwks_uri": {
            "type": "string",
            "format": "uri",
            "example": "https://auth.clams.tech/.well-known/jwks.json"
          },
          "token_endpoint": {
            "type": "string",
            "format": "uri",
            "example": "https://auth.clams.tech/v1/token"
          }
        }
      },
      "LoginResponse": {
        "type": "object",
        "description": "@impl(R-001) @s(S-001) @contract(C-001)\nResponse payload emitted after successful authentication, including the derived subject id.\n\n# Examples\n```\nuse clams_authd::LoginResponse;\nuse clams_identity::{AccessToken, AuthSuccess, Provider, SessionId, UserId};\nuse clams_identity::SubjectId;\n\nlet response = LoginResponse::from(AuthSuccess {\n    user_id: UserId::new(\"user-123\"),\n    session_id: SessionId::new(\"session-456\"),\n    access_token: AccessToken::new(\"token-abc\"),\n    subject_id: SubjectId::from_namespaced(&uuid::Uuid::NAMESPACE_URL, b\"user-123\"),\n    provider: Provider::Google,\n    email: Some(\"user@example.com\".to_owned()),\n    email_verified: Some(true),\n});\nassert_eq!(response.session_id(), \"session-456\");\nassert_eq!(response.email(), Some(\"user@example.com\"));\n```",
        "required": [
          "user_id",
          "session_id",
          "access_token",
          "subject_id"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "example": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJzdmMiLCJleHAiOjE3MDAwMDAwMDAsImlhdCI6MTcwMDAwMDAwMCwic2Vzc2lvbl9pZCI6IjAxODkwYjhjLTVjZmQtN2Q1Zi04ZjkwLTNjN2Y0ZjYyZDgwMSIsInN1YiI6Ijg2MmZkNWVkLWFjOWEtNWJmZS05NmYyLWFiMWY1MDFhMmM5OSIsInVzZXJfaWQiOiJ1c2VyLTEyMyJ9.signature"
          },
          "email": {
            "type": [
              "string",
              "null"
            ],
            "example": "user@example.com"
          },
          "email_verified": {
            "type": [
              "boolean",
              "null"
            ],
            "example": true
          },
          "session_id": {
            "type": "string",
            "format": "uuid",
            "example": "01890b8c-5cfd-7d5f-8f90-3c7f4f62d801"
          },
          "subject_id": {
            "type": "string",
            "format": "uuid",
            "example": "862fd5ed-ac9a-5bfe-96f2-ab1f501a2c99"
          },
          "user_id": {
            "type": "string",
            "example": "user-123"
          }
        }
      },
      "LoginSessionStartRequest": {
        "type": "object",
        "description": "Request payload for `POST /v1/web/login/session/start`.",
        "properties": {
          "redirect_to": {
            "type": [
              "string",
              "null"
            ],
            "format": "uri",
            "description": "Optional redirect URL to be surfaced back to the web or desktop app after login.",
            "example": "clams://callback"
          }
        }
      },
      "LoginSessionStartResponse": {
        "type": "object",
        "description": "Payload returned by `POST /v1/web/login/session/start`.",
        "required": [
          "login_session_id",
          "browser_url",
          "expires_in"
        ],
        "properties": {
          "browser_url": {
            "type": "string",
            "format": "uri",
            "description": "Browser URL to open for the user.",
            "example": "https://auth.clams.tech/?login_session=0191c0ff-7a5b-7d43-8a0e-75c1a4d7c123"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "description": "TTL in seconds for the login session.",
            "example": 600,
            "minimum": 1
          },
          "login_session_id": {
            "type": "string",
            "format": "uuid",
            "description": "Generated login session identifier.",
            "example": "0191c0ff-7a5b-7d43-8a0e-75c1a4d7c123"
          },
          "poll_secret": {
            "type": [
              "string",
              "null"
            ],
            "description": "Client-held proof required when polling the session status.",
            "example": "qvBdycWQEHzMAwV8V1oxTxb2HAkDsWrZZe-zZmbbFhc",
            "maxLength": 43,
            "minLength": 43
          }
        }
      },
      "LoginSessionStatusResponse": {
        "oneOf": [
          {
            "type": "object",
            "description": "Session exists but is still pending.",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "pending"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Session completed successfully and exposes the login response.",
            "required": [
              "login",
              "status"
            ],
            "properties": {
              "login": {
                "$ref": "#/components/schemas/LoginResponse"
              },
              "notice": {
                "oneOf": [
                  {
                    "type": "null"
                  },
                  {
                    "$ref": "#/components/schemas/AccountNoticeResponse"
                  }
                ]
              },
              "status": {
                "type": "string",
                "enum": [
                  "completed"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Session failed terminally.",
            "required": [
              "reason",
              "status"
            ],
            "properties": {
              "reason": {
                "type": "string"
              },
              "status": {
                "type": "string",
                "enum": [
                  "failed"
                ]
              }
            }
          },
          {
            "type": "object",
            "description": "Session is expired or unknown.",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "expired"
                ]
              }
            }
          }
        ],
        "description": "Serializable status payload for `/v1/web/login/session/{id}`."
      },
      "OpenApiBeginExistingRootMigrationRequest": {
        "type": "object",
        "description": "Request to create a signed automatic existing-root migration challenge.",
        "required": [
          "evidence",
          "legacy_feedback_bearer"
        ],
        "properties": {
          "evidence": {
            "$ref": "#/components/schemas/OpenApiExistingRootEnrollmentEvidence"
          },
          "legacy_feedback_bearer": {
            "type": "string",
            "example": "feedback-access-token",
            "writeOnly": true
          }
        }
      },
      "OpenApiBillingFractionalCentsResponse": {
        "type": "object",
        "description": "Fractional-cent trace returned by flexible invoice responses.",
        "required": [
          "numerator",
          "denominator"
        ],
        "properties": {
          "denominator": {
            "type": "integer",
            "format": "int64",
            "example": 1,
            "minimum": 1
          },
          "numerator": {
            "type": "integer",
            "format": "int64",
            "example": 0,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingInactiveReason": {
        "type": "string",
        "description": "Reasons a billing license can be inactive.",
        "enum": [
          "missing",
          "payment_pending",
          "expired",
          "revoked"
        ]
      },
      "OpenApiBillingInstanceOwnerResponse": {
        "type": "object",
        "description": "Owner authorization and free capacity compatibility status for one backend instance.",
        "required": [
          "instance_id",
          "owner_subject_id",
          "owner_authorization_revision",
          "active_key_id",
          "authorized_at_epoch"
        ],
        "properties": {
          "active_key_id": {
            "type": "string",
            "example": "isk_abc123"
          },
          "authorized_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "default_capacity_assignment_revision": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 253402300799,
            "minimum": 1
          },
          "default_capacity_owner_subject_id": {
            "type": [
              "string",
              "null"
            ],
            "example": "cfd2e45c-182a-5f77-9f6f-0c87516376b5"
          },
          "default_profile_limit": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "The compatibility limit uses the full unsigned 32-bit range on the wire.",
            "example": 4294967295,
            "maximum": 4294967295,
            "minimum": 1
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "owner_authorization_revision": {
            "type": "integer",
            "format": "int64",
            "example": 3,
            "minimum": 1
          },
          "owner_subject_id": {
            "type": "string",
            "example": "cfd2e45c-182a-5f77-9f6f-0c87516376b5"
          }
        }
      },
      "OpenApiBillingInstanceReplacementDiscoveryResponse": {
        "type": "object",
        "description": "Read-only movable-allocation discovery response.",
        "required": [
          "allocations"
        ],
        "properties": {
          "allocations": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiBillingReplacementAllocationPreview"
            }
          }
        }
      },
      "OpenApiBillingInstanceReplacementResponse": {
        "type": "object",
        "description": "Result body for a completed instance replacement.",
        "required": [
          "allocation_id",
          "instance_id",
          "total_capacity",
          "allocation_revision",
          "assigned_at_epoch"
        ],
        "properties": {
          "allocation_id": {
            "type": "string",
            "format": "uuid"
          },
          "allocation_revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "assigned_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-2222-7000-8000-000000000001"
          },
          "total_capacity": {
            "type": "integer",
            "format": "int32",
            "example": 12,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingInvoiceDiscountKind": {
        "type": "string",
        "description": "Discount calculation kind returned by flexible invoice responses.",
        "enum": [
          "percent",
          "fixed_amount",
          "override_price"
        ]
      },
      "OpenApiBillingInvoiceDiscountResponse": {
        "type": "object",
        "description": "Public discount snapshot returned by flexible v2 invoice responses.",
        "required": [
          "discount_id",
          "kind",
          "amount_before_cents",
          "discount_cents",
          "amount_after_cents",
          "dropped_fractional_cent"
        ],
        "properties": {
          "amount_after_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9950,
            "minimum": 0
          },
          "amount_before_cents": {
            "type": "integer",
            "format": "int64",
            "example": 19900,
            "minimum": 0
          },
          "code": {
            "type": [
              "string",
              "null"
            ],
            "example": "BETA50"
          },
          "discount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9950,
            "minimum": 0
          },
          "discount_id": {
            "type": "string",
            "example": "beta_50_once_v1"
          },
          "dropped_fractional_cent": {
            "$ref": "#/components/schemas/OpenApiBillingFractionalCentsResponse"
          },
          "kind": {
            "$ref": "#/components/schemas/OpenApiBillingInvoiceDiscountKind"
          }
        }
      },
      "OpenApiBillingInvoiceLightningResponse": {
        "type": "object",
        "description": "Legacy Phoenixd invoice shape; historical invoice routes return `lightning: null`.",
        "required": [
          "bolt11_invoice",
          "lightning_uri",
          "payment_hash",
          "requested_sats",
          "received_sats"
        ],
        "properties": {
          "bolt11_invoice": {
            "type": "string",
            "example": "lnbc1990n1p..."
          },
          "lightning_uri": {
            "type": "string",
            "example": "lightning:lnbc1990n1p..."
          },
          "payment_hash": {
            "type": "string",
            "example": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
          },
          "quote_expires_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1780438800,
            "minimum": 0
          },
          "received_sats": {
            "type": "integer",
            "format": "int64",
            "example": 0,
            "minimum": 0
          },
          "requested_sats": {
            "type": "integer",
            "format": "int64",
            "example": 663334,
            "minimum": 1
          }
        }
      },
      "OpenApiBillingInvoiceLineKind": {
        "type": "string",
        "description": "Line kind returned by flexible invoice responses.",
        "enum": [
          "subject_license",
          "profile_capacity",
          "rounding_adjustment",
          "manual_adjustment"
        ]
      },
      "OpenApiBillingInvoiceLineResponse": {
        "type": "object",
        "description": "Public invoice line snapshot returned by flexible v2 invoice responses.",
        "required": [
          "line_id",
          "kind",
          "billing_scope",
          "plan_id",
          "offer_id",
          "price_id",
          "currency",
          "quantity",
          "subtotal_cents",
          "discount_cents",
          "tax_cents",
          "total_cents"
        ],
        "properties": {
          "billing_scope": {
            "type": "string",
            "example": "subject:018f7b0b-1111-7000-8000-000000000001"
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "discount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9950,
            "minimum": 0
          },
          "kind": {
            "$ref": "#/components/schemas/OpenApiBillingInvoiceLineKind"
          },
          "line_id": {
            "type": "string",
            "example": "line_1"
          },
          "offer_id": {
            "type": "string",
            "example": "individual_annual_usd_199_v1"
          },
          "plan_id": {
            "type": "string",
            "example": "individual_annual_usd_199"
          },
          "price_id": {
            "type": "string",
            "example": "individual_annual_usd_199_v1"
          },
          "proration": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingProrationResponse"
              }
            ]
          },
          "quantity": {
            "type": "integer",
            "format": "int32",
            "example": 1,
            "minimum": 1
          },
          "subtotal_cents": {
            "type": "integer",
            "format": "int64",
            "example": 19900,
            "minimum": 0
          },
          "tax_cents": {
            "type": "integer",
            "format": "int64",
            "example": 0,
            "minimum": 0
          },
          "total_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9900,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingInvoiceResponse": {
        "type": "object",
        "description": "Retained invoice facts returned by historical billing endpoints.",
        "required": [
          "invoice_id",
          "settlement_source",
          "status",
          "plan_id",
          "amount_cents",
          "currency",
          "subtotal_cents",
          "discount_total_cents",
          "pre_round_total_cents",
          "rounding_adjustment_cents",
          "invoice_lines",
          "discounts",
          "created_at_epoch",
          "updated_at_epoch"
        ],
        "properties": {
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 19900,
            "minimum": 0
          },
          "checkout_acceptance": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiCheckoutAcceptanceSnapshot"
              }
            ]
          },
          "created_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435100,
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "discount_total_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9950,
            "minimum": 0
          },
          "discounts": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiBillingInvoiceDiscountResponse"
            }
          },
          "invoice_id": {
            "type": "string",
            "example": "019728cc-e88b-7d6e-86dd-5f2b2cb179d4"
          },
          "invoice_lines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiBillingInvoiceLineResponse"
            }
          },
          "license_valid_from_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "license_valid_until_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1811971200,
            "minimum": 0
          },
          "lightning": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingInvoiceLightningResponse",
                "description": "Always null on historical invoice routes; no payable BOLT11 is exposed."
              }
            ]
          },
          "paid_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "payment_method": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingPaymentMethod",
                "description": "Present for externally settled provider invoices."
              }
            ]
          },
          "payment_url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Always null on historical invoice routes; never a payable checkout link."
          },
          "plan_id": {
            "type": "string",
            "example": "individual_annual_usd_199"
          },
          "pre_round_total_cents": {
            "type": "integer",
            "format": "int64",
            "example": 9950,
            "minimum": 0
          },
          "provider_checkout_expires_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1790812800,
            "minimum": 0
          },
          "rounding_adjustment_cents": {
            "type": "integer",
            "format": "int64",
            "example": 50,
            "minimum": 0
          },
          "settlement_source": {
            "$ref": "#/components/schemas/OpenApiBillingInvoiceSettlementSource"
          },
          "status": {
            "$ref": "#/components/schemas/OpenApiBillingInvoiceStatus"
          },
          "subtotal_cents": {
            "type": "integer",
            "format": "int64",
            "example": 19900,
            "minimum": 0
          },
          "updated_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingInvoiceSettlementSource": {
        "type": "string",
        "description": "Settlement path expected for a billing invoice.",
        "enum": [
          "provider",
          "internal"
        ]
      },
      "OpenApiBillingInvoiceStatus": {
        "type": "string",
        "description": "Internal invoice status exposed by billing endpoints.",
        "enum": [
          "created",
          "provider_created",
          "open",
          "processing",
          "underpaid",
          "paid",
          "expired",
          "failed",
          "refunded",
          "webhook_rejected"
        ]
      },
      "OpenApiBillingLicenseProfileCapacityResponse": {
        "type": "object",
        "description": "Profile-capacity status for an instance-bound license response.",
        "required": [
          "allocation_id",
          "instance_id",
          "profile_capacity_limit",
          "entitlement_revision",
          "valid_until_epoch"
        ],
        "properties": {
          "active_profile_reservation_count": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "example": 0,
            "minimum": 0
          },
          "allocation_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-3333-7000-8000-000000000001"
          },
          "coverage_periods": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiProfileCapacityCoveragePeriod"
            },
            "description": "Current and future paid capacity periods when the covered limit changes."
          },
          "coverage_valid_until_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Furthest continuous paid coverage for the current capacity limit.",
            "example": 1843507200,
            "minimum": 0
          },
          "entitlement_revision": {
            "type": "integer",
            "format": "int64",
            "example": 253402300799,
            "minimum": 0
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "profile_capacity_limit": {
            "type": "integer",
            "format": "int32",
            "example": 4294967295,
            "minimum": 0
          },
          "valid_until_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 253402300799,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingLicenseResponse": {
        "type": "object",
        "description": "Free compatibility status and optional latest historical invoice.",
        "required": [
          "state",
          "plan_id",
          "amount_cents",
          "currency"
        ],
        "properties": {
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 0,
            "minimum": 0
          },
          "coverage_valid_until_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Final end of current and future paid license coverage.",
            "example": 1843507200,
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "inactive_reason": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingInactiveReason"
              }
            ]
          },
          "latest_invoice": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingInvoiceResponse",
                "description": "Latest provider invoice for the subject; may be license or profile-capacity billing."
              }
            ]
          },
          "plan_id": {
            "type": "string",
            "example": "individual_annual_usd_199"
          },
          "profile_capacity": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiBillingLicenseProfileCapacityResponse"
              }
            ]
          },
          "state": {
            "$ref": "#/components/schemas/OpenApiBillingLicenseState"
          },
          "valid_until_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Far-future compatibility expiry; this is not a paid license term.",
            "example": 253402300799,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingLicenseState": {
        "type": "string",
        "description": "License states exposed to clients.",
        "enum": [
          "active",
          "license_required",
          "payment_pending",
          "license_expired"
        ]
      },
      "OpenApiBillingPaymentMethod": {
        "type": "string",
        "description": "Payment method recorded on a retained provider invoice.",
        "enum": [
          "card",
          "lightning"
        ]
      },
      "OpenApiBillingProrationResponse": {
        "type": "object",
        "description": "Proration trace retained on historical invoice lines.",
        "required": [
          "full_amount_cents",
          "remaining_seconds",
          "full_period_seconds",
          "amount_cents",
          "dropped_fractional_cent"
        ],
        "properties": {
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 2450,
            "minimum": 0
          },
          "dropped_fractional_cent": {
            "$ref": "#/components/schemas/OpenApiBillingFractionalCentsResponse"
          },
          "full_amount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 4900,
            "minimum": 0
          },
          "full_period_seconds": {
            "type": "integer",
            "format": "int64",
            "example": 31536000,
            "minimum": 1
          },
          "remaining_seconds": {
            "type": "integer",
            "format": "int64",
            "example": 15768000,
            "minimum": 0
          }
        }
      },
      "OpenApiBillingReplacementAllocationPreview": {
        "type": "object",
        "description": "One movable allocation shown when selection is required.",
        "required": [
          "allocation_id",
          "source_instance_id",
          "total_capacity",
          "allocation_revision"
        ],
        "properties": {
          "allocation_id": {
            "type": "string",
            "format": "uuid"
          },
          "allocation_revision": {
            "type": "integer",
            "format": "int64",
            "minimum": 1
          },
          "source_instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "total_capacity": {
            "type": "integer",
            "format": "int32",
            "minimum": 0
          }
        }
      },
      "OpenApiBillingWebhookResponse": {
        "type": "object",
        "description": "Webhook processing response.",
        "required": [
          "accepted_events"
        ],
        "properties": {
          "accepted_events": {
            "type": "integer",
            "example": 1,
            "minimum": 0
          }
        }
      },
      "OpenApiCheckoutAcceptanceSnapshot": {
        "type": "object",
        "description": "Durable checkout acceptance facts returned with invoices.",
        "required": [
          "accepted",
          "accepted_at_epoch",
          "manifest_revision",
          "manifest_published_at",
          "checkout_policy_id",
          "acceptance_text",
          "renewal_policy",
          "auto_renewal_consent",
          "terms",
          "privacy"
        ],
        "properties": {
          "acceptance_text": {
            "type": "string"
          },
          "accepted": {
            "type": "boolean"
          },
          "accepted_at_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "account_company": {
            "type": [
              "string",
              "null"
            ]
          },
          "auto_renewal_consent": {
            "type": "boolean"
          },
          "checkout_policy_id": {
            "type": "string",
            "example": "checkout_policy_example"
          },
          "client_ip": {
            "type": [
              "string",
              "null"
            ]
          },
          "manifest_published_at": {
            "type": "string",
            "example": "2026-07-15T18:00:00Z"
          },
          "manifest_revision": {
            "type": "integer",
            "format": "int64",
            "example": 12,
            "minimum": 1
          },
          "privacy": {
            "$ref": "#/components/schemas/OpenApiLegalDocumentSnapshot"
          },
          "renewal_policy": {
            "$ref": "#/components/schemas/OpenApiCheckoutRenewalPolicy"
          },
          "terms": {
            "$ref": "#/components/schemas/OpenApiLegalDocumentSnapshot"
          },
          "user_agent": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "OpenApiCheckoutRenewalPolicy": {
        "type": "string",
        "description": "Renewal policy selected by the verified manifest.",
        "enum": [
          "manual_renewal",
          "one_time_annual_license",
          "auto_renewing_subscription"
        ]
      },
      "OpenApiCompleteBillingInstanceReplacementRequest": {
        "type": "object",
        "description": "Request body for placing one allocation on a new instance.",
        "required": [
          "target_binding_challenge_id",
          "target_binding_proof"
        ],
        "properties": {
          "target_binding_challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "target_binding_proof": {
            "type": "string",
            "example": "{\"challenge_id\":\"ibc_018f7b0b\",\"signature\":\"base64url\"}"
          }
        }
      },
      "OpenApiCompleteExistingRootMigrationRequest": {
        "type": "object",
        "description": "Request to complete an automatic existing-root migration challenge.",
        "required": [
          "evidence",
          "challenge_id",
          "instance_binding_proof"
        ],
        "properties": {
          "challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "evidence": {
            "$ref": "#/components/schemas/OpenApiExistingRootEnrollmentEvidence"
          },
          "instance_binding_proof": {
            "type": "string",
            "example": "{\"challenge_id\":\"ibc_018f7b0b\",\"signature\":\"base64url\"}"
          }
        }
      },
      "OpenApiConnectionOAuthAccessTokenRequest": {
        "type": "object",
        "description": "Request body for obtaining a short-lived access token from a hosted broker credential ref.",
        "required": [
          "provider_key",
          "credential_ref"
        ],
        "properties": {
          "credential_ref": {
            "type": "string",
            "example": "cred_abc123"
          },
          "provider_key": {
            "type": "string",
            "example": "mercury"
          }
        }
      },
      "OpenApiConnectionOAuthAccessTokenResponse": {
        "type": "object",
        "description": "Response body containing a short-lived provider access token.",
        "required": [
          "token_type",
          "access_token",
          "expires_in"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "format": "password",
            "example": "provider-access-token"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "example": 300,
            "minimum": 1
          },
          "granted_scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "resource_server_url": {
            "type": [
              "string",
              "null"
            ],
            "example": "https://api.example/api/v1/"
          },
          "token_type": {
            "type": "string",
            "example": "Bearer"
          }
        }
      },
      "OpenApiConnectionOAuthCleanupChallengeRequest": {
        "type": "object",
        "description": "Request body for a proof-bound hosted credential cleanup challenge.",
        "required": [
          "provider_key"
        ],
        "properties": {
          "provider_key": {
            "type": "string",
            "example": "mercury"
          }
        }
      },
      "OpenApiConnectionOAuthCleanupChallengeResponse": {
        "type": "object",
        "description": "One-time challenge for proof-bound hosted credential cleanup.",
        "required": [
          "challenge_id",
          "nonce",
          "subject_id",
          "instance_id",
          "expires_at_epoch",
          "request_fingerprint"
        ],
        "properties": {
          "challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "expires_at_epoch": {
            "type": "integer",
            "format": "int64",
            "minimum": 0
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "nonce": {
            "type": "string",
            "example": "base64url-nonce"
          },
          "request_fingerprint": {
            "type": "string",
            "example": "sha256:base64url-digest"
          },
          "subject_id": {
            "type": "string",
            "example": "953e25eb-bd3f-5d84-bcb5-8941fcd66305"
          }
        }
      },
      "OpenApiConnectionOAuthCleanupRequest": {
        "type": "object",
        "description": "Instance proof authorizing hosted credential cleanup.",
        "required": [
          "provider_key",
          "instance_id",
          "instance_binding_challenge_id",
          "instance_binding_proof"
        ],
        "properties": {
          "instance_binding_challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "instance_binding_proof": {
            "type": "string",
            "example": "{\"action\":\"connection_oauth_cleanup\",...}"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid"
          },
          "provider_key": {
            "type": "string",
            "example": "mercury"
          }
        }
      },
      "OpenApiConnectionOAuthCredentialStatusResponse": {
        "type": "object",
        "description": "Non-secret hosted credential status.",
        "required": [
          "provider_key",
          "credential_ref",
          "status"
        ],
        "properties": {
          "access_token_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "example": "2026-07-01T00:00:00Z"
          },
          "credential_ref": {
            "type": "string",
            "example": "cred_abc123"
          },
          "granted_scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "provider_key": {
            "type": "string",
            "example": "mercury"
          },
          "refresh_token_expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "example": "2026-12-31T00:00:00Z"
          },
          "status": {
            "type": "string",
            "example": "connected"
          },
          "status_message": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "OpenApiConnectionOAuthStartRequest": {
        "type": "object",
        "description": "Request body for starting a hosted connection OAuth broker flow.",
        "required": [
          "connection_id"
        ],
        "properties": {
          "connection_id": {
            "type": "string",
            "example": "01890c10-0000-7000-8000-000000000701"
          },
          "requested_scopes": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "OpenApiConnectionOAuthStartResponse": {
        "type": "object",
        "description": "Response body for a hosted connection OAuth broker start.",
        "required": [
          "authorization_url",
          "state",
          "expires_in",
          "mode"
        ],
        "properties": {
          "authorization_url": {
            "type": "string",
            "format": "uri",
            "example": "https://provider.example/oauth/authorize?..."
          },
          "credential_ref": {
            "type": [
              "string",
              "null"
            ],
            "example": "cred_abc123"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "example": 600,
            "minimum": 1
          },
          "mode": {
            "type": "string",
            "example": "hosted_broker"
          },
          "state": {
            "type": "string",
            "example": "state_abc123"
          }
        }
      },
      "OpenApiCreateInstanceBindingChallengeRequest": {
        "type": "object",
        "description": "Request body for creating an instance-binding challenge.",
        "required": [
          "instance_id",
          "audience",
          "action"
        ],
        "properties": {
          "action": {
            "$ref": "#/components/schemas/OpenApiInstanceBindingChallengeAction"
          },
          "audience": {
            "type": "string",
            "example": "svc"
          },
          "bootstrap_key": {
            "oneOf": [
              {
                "type": "null"
              },
              {
                "$ref": "#/components/schemas/OpenApiInstanceBindingBootstrapKey"
              }
            ]
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "refresh_token": {
            "type": [
              "string",
              "null"
            ],
            "example": "svc-refresh-token",
            "writeOnly": true
          },
          "request_fingerprint": {
            "type": [
              "string",
              "null"
            ],
            "example": "sha256:canonical-request-fingerprint"
          }
        }
      },
      "OpenApiCreateOAuthClientRequest": {
        "type": "object",
        "description": "Request payload for `POST /v1/oauth-clients`.",
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/OpenApiMachineAudience",
            "description": "Requested audience for the created client (typically `rates` or `feedback`)."
          }
        }
      },
      "OpenApiCreateOAuthClientResponse": {
        "type": "object",
        "description": "Response payload for `POST /v1/oauth-clients`.",
        "required": [
          "client_id",
          "client_secret",
          "audience",
          "created_at"
        ],
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/OpenApiMachineAudience"
          },
          "client_id": {
            "type": "string",
            "example": "cli_123e4567-e89b-12d3-a456-426614174000"
          },
          "client_secret": {
            "type": "string",
            "example": "wkzmUl4MM3wWOlRmCaHsCq17ttD4xDXZiT5399qom9k",
            "maxLength": 43,
            "minLength": 43
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "description": "RFC 3339 timestamp for creation time.",
            "example": "2026-02-07T12:34:56Z"
          }
        }
      },
      "OpenApiCreateProfileCapacityReservationRequest": {
        "type": "object",
        "description": "Request body for creating an authd profile-capacity reservation.",
        "required": [
          "instance_id",
          "profile_id",
          "instance_binding_challenge_id",
          "instance_binding_proof"
        ],
        "properties": {
          "instance_binding_challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "instance_binding_proof": {
            "type": "string",
            "example": "{\"challenge_id\":\"ibc_018f7b0b\",\"signature\":\"base64url\"}"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "profile_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-2222-7000-8000-000000000001"
          }
        }
      },
      "OpenApiErrorEnvelope": {
        "type": "object",
        "description": "Error payload returned by authd routes.",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "Stable error code for programmatic handling.",
            "example": "E401-AUTH-FAILED"
          },
          "details": {
            "type": [
              "object",
              "null"
            ],
            "description": "Optional error details for debugging.",
            "additionalProperties": {},
            "propertyNames": {
              "type": "string"
            }
          },
          "message": {
            "type": "string",
            "description": "Human-readable error message.",
            "example": "not authorized"
          },
          "request_id": {
            "type": [
              "string",
              "null"
            ],
            "description": "Optional request identifier for support.",
            "example": "req_01HZX2Y6K5X8YH9WJ6QW6A7B8C"
          },
          "retry_after_seconds": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "description": "Optional retry hint in seconds.",
            "example": 10,
            "minimum": 1
          }
        }
      },
      "OpenApiExistingRootEnrollmentEvidence": {
        "type": "object",
        "description": "Sanitized evidence describing a beta-era local root.",
        "required": [
          "protocol_version",
          "instance_id",
          "workspace_count",
          "non_deleted_profile_count",
          "legacy_credentials_present",
          "imported_billing_history_present",
          "local_snapshot_hash",
          "key_id",
          "public_key",
          "public_key_digest",
          "key_revision",
          "key_created_at_epoch"
        ],
        "properties": {
          "imported_billing_history_present": {
            "type": "boolean"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "key_created_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "key_id": {
            "type": "string",
            "example": "isk_018f7b0b"
          },
          "key_revision": {
            "type": "integer",
            "format": "int64",
            "example": 1,
            "minimum": 1
          },
          "legacy_credentials_present": {
            "type": "boolean"
          },
          "local_snapshot_hash": {
            "type": "string",
            "example": "base64url-sha256-canonical-root-snapshot"
          },
          "non_deleted_profile_count": {
            "type": "integer",
            "format": "int32",
            "example": 4,
            "minimum": 1
          },
          "protocol_version": {
            "type": "integer",
            "format": "int32",
            "example": 1,
            "minimum": 1
          },
          "public_key": {
            "type": "string",
            "example": "base64url-ed25519-public-key"
          },
          "public_key_digest": {
            "type": "string",
            "example": "base64url-sha256-public-key-digest"
          },
          "workspace_count": {
            "type": "integer",
            "format": "int32",
            "example": 1,
            "minimum": 1
          }
        }
      },
      "OpenApiExistingRootMigrationResponse": {
        "type": "object",
        "description": "Approved automatic existing-root migration.",
        "required": [
          "instance_id",
          "subject_id",
          "migration_id",
          "grandfathered_profile_limit",
          "already_authorized"
        ],
        "properties": {
          "already_authorized": {
            "type": "boolean"
          },
          "grandfathered_profile_limit": {
            "type": "integer",
            "format": "int32",
            "example": 4294967295,
            "minimum": 1
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "migration_id": {
            "type": "string",
            "example": "migration_bf2d4b1e"
          },
          "subject_id": {
            "type": "string",
            "example": "cfd2e45c-182a-5f77-9f6f-0c87516376b5"
          }
        }
      },
      "OpenApiHistoricalInvoicePageResponse": {
        "type": "object",
        "description": "Bounded list of retained invoices for the authenticated subject.",
        "required": [
          "invoices",
          "total",
          "offset",
          "limit"
        ],
        "properties": {
          "invoices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiBillingInvoiceResponse"
            }
          },
          "limit": {
            "type": "integer",
            "example": 50,
            "maximum": 100,
            "minimum": 1
          },
          "next_offset": {
            "type": [
              "integer",
              "null"
            ],
            "example": 50,
            "minimum": 0
          },
          "offset": {
            "type": "integer",
            "example": 0,
            "minimum": 0
          },
          "total": {
            "type": "integer",
            "example": 12,
            "minimum": 0
          }
        }
      },
      "OpenApiInstanceBindingBootstrapKey": {
        "type": "object",
        "description": "Public key metadata for first local instance enrollment.",
        "required": [
          "key_id",
          "public_key",
          "public_key_digest",
          "key_revision",
          "created_at_epoch"
        ],
        "properties": {
          "created_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "key_id": {
            "type": "string",
            "example": "isk_abc123"
          },
          "key_revision": {
            "type": "integer",
            "format": "int64",
            "example": 1,
            "minimum": 0
          },
          "public_key": {
            "type": "string",
            "example": "base64url-ed25519-public-key"
          },
          "public_key_digest": {
            "type": "string",
            "example": "base64url-sha256-public-key-digest"
          }
        }
      },
      "OpenApiInstanceBindingChallengeAction": {
        "type": "string",
        "description": "Operation bound to an instance-binding challenge.",
        "enum": [
          "svc_exchange",
          "svc_refresh",
          "capacity_checkout",
          "capacity_reservation",
          "reservation_commit",
          "reservation_release",
          "owner_transfer",
          "connection_oauth_cleanup"
        ]
      },
      "OpenApiInstanceBindingChallengeResponse": {
        "type": "object",
        "description": "Response body for a newly issued instance-binding challenge.",
        "required": [
          "challenge_id",
          "nonce",
          "expires_at_epoch"
        ],
        "properties": {
          "challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b-1111-7000-8000-000000000001"
          },
          "expires_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435500,
            "minimum": 0
          },
          "nonce": {
            "type": "string",
            "example": "base64url-nonce"
          },
          "proof_authorization_token": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "OpenApiJwk": {
        "type": "object",
        "description": "Minimal JWK representation for Ed25519 keys used by authd.",
        "required": [
          "kty",
          "alg",
          "crv",
          "kid",
          "x"
        ],
        "properties": {
          "alg": {
            "type": "string",
            "example": "EdDSA"
          },
          "crv": {
            "type": "string",
            "example": "Ed25519"
          },
          "kid": {
            "type": "string"
          },
          "kty": {
            "type": "string",
            "example": "OKP"
          },
          "x": {
            "type": "string",
            "description": "Public key coordinate (`x`) encoded with base64url (no padding)."
          }
        }
      },
      "OpenApiJwksSet": {
        "type": "object",
        "description": "JWKS document returned by `GET /.well-known/jwks.json`.",
        "required": [
          "keys"
        ],
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/OpenApiJwk"
            }
          }
        }
      },
      "OpenApiLegalDocumentSnapshot": {
        "type": "object",
        "description": "Complete immutable legal document snapshot.",
        "required": [
          "document_id",
          "last_updated",
          "current_url",
          "archive_url",
          "canonical_body_url",
          "sha256"
        ],
        "properties": {
          "archive_url": {
            "type": "string",
            "format": "uri",
            "example": "https://clams.tech/legal/terms/2026-07-15/"
          },
          "canonical_body_url": {
            "type": "string",
            "format": "uri",
            "example": "https://clams.tech/legal/terms/2026-07-15/body.txt"
          },
          "current_url": {
            "type": "string",
            "format": "uri",
            "example": "https://clams.tech/terms/"
          },
          "document_id": {
            "type": "string",
            "example": "terms_of_use_example"
          },
          "effective_date": {
            "type": [
              "string",
              "null"
            ],
            "example": "2025-11-10"
          },
          "last_updated": {
            "type": "string",
            "example": "2026-07-15"
          },
          "sha256": {
            "type": "string",
            "example": "sha256:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
          }
        }
      },
      "OpenApiMachineAudience": {
        "type": "string",
        "description": "Token audiences supported for machine-to-machine credentials.",
        "enum": [
          "rates",
          "feedback"
        ]
      },
      "OpenApiPhoenixdCheckoutStatusResponse": {
        "type": "object",
        "description": "Status of a previously issued Phoenixd Lightning invoice.",
        "required": [
          "invoice_id",
          "status",
          "paid",
          "amount_cents",
          "currency",
          "requested_sats",
          "received_sats"
        ],
        "properties": {
          "amount_cents": {
            "type": "integer",
            "format": "int64",
            "example": 19900,
            "minimum": 0
          },
          "currency": {
            "type": "string",
            "example": "USD"
          },
          "expires_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1800000000,
            "minimum": 0
          },
          "invoice_id": {
            "type": "string",
            "example": "019728cc-e88b-7d6e-86dd-5f2b2cb179d4"
          },
          "paid": {
            "type": "boolean",
            "description": "Whether the retained invoice settled; product access no longer depends on it.",
            "example": false
          },
          "received_sats": {
            "type": "integer",
            "format": "int64",
            "example": 0,
            "minimum": 0
          },
          "requested_sats": {
            "type": "integer",
            "format": "int64",
            "example": 180000,
            "minimum": 1
          },
          "status": {
            "$ref": "#/components/schemas/OpenApiBillingInvoiceStatus"
          }
        }
      },
      "OpenApiPrepareBillingInstanceReplacementRequest": {
        "type": "object",
        "description": "Request body for preparing an allocation assignment.",
        "properties": {
          "allocation_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          }
        }
      },
      "OpenApiPrepareBillingInstanceReplacementResponse": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "status"
            ],
            "properties": {
              "status": {
                "type": "string",
                "enum": [
                  "unavailable"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "allocations",
              "status"
            ],
            "properties": {
              "allocations": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/OpenApiBillingReplacementAllocationPreview"
                }
              },
              "status": {
                "type": "string",
                "enum": [
                  "selection_required"
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "allocation_id",
              "source_instance_id",
              "total_capacity",
              "challenge",
              "request_fingerprint",
              "status"
            ],
            "properties": {
              "allocation_id": {
                "type": "string",
                "format": "uuid"
              },
              "challenge": {
                "$ref": "#/components/schemas/OpenApiInstanceBindingChallengeResponse"
              },
              "request_fingerprint": {
                "type": "string",
                "example": "sha256:0ed3c4..."
              },
              "source_instance_id": {
                "type": "string",
                "format": "uuid",
                "example": "018f7b0b-1111-7000-8000-000000000001"
              },
              "status": {
                "type": "string",
                "enum": [
                  "pending"
                ]
              },
              "total_capacity": {
                "type": "integer",
                "format": "int32",
                "example": 12,
                "minimum": 0
              }
            }
          },
          {
            "type": "object",
            "required": [
              "assignment",
              "status"
            ],
            "properties": {
              "assignment": {
                "$ref": "#/components/schemas/OpenApiBillingInstanceReplacementResponse"
              },
              "status": {
                "type": "string",
                "enum": [
                  "completed"
                ]
              }
            }
          }
        ],
        "description": "Server-prepared replacement operation."
      },
      "OpenApiProfileCapacityCoveragePeriod": {
        "type": "object",
        "description": "One continuous paid profile-capacity coverage period.",
        "required": [
          "valid_from_epoch",
          "valid_until_epoch",
          "profile_capacity_limit"
        ],
        "properties": {
          "profile_capacity_limit": {
            "type": "integer",
            "format": "int32",
            "example": 5,
            "minimum": 0
          },
          "valid_from_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1811971200,
            "minimum": 0
          },
          "valid_until_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1843507200,
            "minimum": 0
          }
        }
      },
      "OpenApiProfileCapacityReservationResponse": {
        "type": "object",
        "description": "Response body for a legacy capacity lease. New leases do not consume paid capacity.",
        "required": [
          "reservation_id",
          "allocation_id",
          "instance_id",
          "profile_id",
          "state",
          "expires_at_epoch",
          "active_capacity_limit",
          "active_reservation_count"
        ],
        "properties": {
          "active_capacity_limit": {
            "type": "integer",
            "format": "int32",
            "example": 4294967295,
            "minimum": 0
          },
          "active_reservation_count": {
            "type": "integer",
            "format": "int32",
            "example": 0,
            "minimum": 0
          },
          "allocation_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-3333-7000-8000-000000000001"
          },
          "committed_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          },
          "expires_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435500,
            "minimum": 0
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "profile_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-2222-7000-8000-000000000001"
          },
          "release_reason": {
            "type": [
              "string",
              "null"
            ],
            "example": "instance_replaced"
          },
          "released_at_epoch": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 1780435300,
            "minimum": 0
          },
          "reservation_id": {
            "type": "string",
            "example": "pcr_free_018f7b0b-1111-7000-8000-000000000001_018f7b0b-2222-7000-8000-000000000001"
          },
          "state": {
            "$ref": "#/components/schemas/OpenApiProfileCapacityReservationState"
          }
        }
      },
      "OpenApiProfileCapacityReservationState": {
        "type": "string",
        "description": "Authd profile-capacity reservation lifecycle state.",
        "enum": [
          "reserved",
          "committed",
          "released",
          "expired"
        ]
      },
      "OpenApiReportDisclaimerPolicy": {
        "type": "object",
        "description": "Complete report disclaimer policy.",
        "required": [
          "notice_id",
          "text",
          "document"
        ],
        "properties": {
          "document": {
            "$ref": "#/components/schemas/OpenApiLegalDocumentSnapshot"
          },
          "notice_id": {
            "type": "string",
            "example": "report_disclaimer_example"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "OpenApiTokenRequest": {
        "oneOf": [
          {
            "type": "object",
            "description": "Refresh token grant (rotating refresh token).",
            "required": [
              "refresh_token",
              "audience",
              "grant_type"
            ],
            "properties": {
              "audience": {
                "$ref": "#/components/schemas/RefreshGrantAudience",
                "description": "Requested audience for the returned access token."
              },
              "billing_capabilities": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Client-declared optional capabilities, such as `profile_capacity_enforced` or\n`account_notices_v1` for interactive `svc` refresh notices."
              },
              "billing_protocol_version": {
                "type": [
                  "integer",
                  "null"
                ],
                "format": "int32",
                "description": "Client-declared flexible billing protocol version.",
                "minimum": 0
              },
              "grant_type": {
                "type": "string",
                "enum": [
                  "refresh_token"
                ]
              },
              "instance_binding_challenge_id": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Server-issued instance binding challenge id."
              },
              "instance_binding_proof": {
                "type": [
                  "string",
                  "null"
                ],
                "description": "Serialized instance binding proof."
              },
              "instance_id": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "uuid",
                "description": "Backend instance id for future instance-bound SVC refresh."
              },
              "refresh_token": {
                "type": "string",
                "description": "Opaque refresh token string.",
                "example": "wkzmUl4MM3wWOlRmCaHsCq17ttD4xDXZiT5399qom9k",
                "maxLength": 43,
                "minLength": 43
              }
            }
          },
          {
            "type": "object",
            "description": "Client credentials grant (machine-to-machine).",
            "required": [
              "client_id",
              "client_secret",
              "audience",
              "grant_type"
            ],
            "properties": {
              "audience": {
                "$ref": "#/components/schemas/OpenApiMachineAudience"
              },
              "client_id": {
                "type": "string",
                "example": "cli_123e4567-e89b-12d3-a456-426614174000"
              },
              "client_secret": {
                "type": "string",
                "example": "wkzmUl4MM3wWOlRmCaHsCq17ttD4xDXZiT5399qom9k",
                "maxLength": 43,
                "minLength": 43
              },
              "grant_type": {
                "type": "string",
                "enum": [
                  "client_credentials"
                ]
              }
            }
          }
        ],
        "description": "Request payload for `POST /v1/token`.\n\nNote: the server internally parses these requests into richer types that also validate\n`grant_type` and enforce per-grant invariants."
      },
      "OpenApiTransferBillingInstanceOwnerRequest": {
        "type": "object",
        "description": "Request body for self-service billing owner transfer.",
        "required": [
          "new_owner_subject_id",
          "instance_binding_challenge_id",
          "instance_binding_proof",
          "request_fingerprint"
        ],
        "properties": {
          "instance_binding_challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "instance_binding_proof": {
            "type": "string",
            "example": "{\"challenge_id\":\"ibc_018f7b0b\",\"signature\":\"base64url\"}"
          },
          "new_owner_subject_id": {
            "type": "string",
            "example": "c6f4d9e1-b6e8-5a6d-9bb9-1f50644625db"
          },
          "request_fingerprint": {
            "type": "string",
            "example": "sha256:canonical-transfer-fingerprint"
          }
        }
      },
      "OpenApiTransferBillingInstanceOwnerResponse": {
        "type": "object",
        "description": "Response body for a completed billing owner transfer.",
        "required": [
          "instance_id",
          "previous_owner_subject_id",
          "owner_subject_id",
          "owner_authorization_revision",
          "transferred_at_epoch"
        ],
        "properties": {
          "default_capacity_assignment_revision": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int64",
            "example": 5,
            "minimum": 1
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "owner_authorization_revision": {
            "type": "integer",
            "format": "int64",
            "example": 1,
            "minimum": 1
          },
          "owner_subject_id": {
            "type": "string",
            "example": "c6f4d9e1-b6e8-5a6d-9bb9-1f50644625db"
          },
          "previous_owner_subject_id": {
            "type": "string",
            "example": "cfd2e45c-182a-5f77-9f6f-0c87516376b5"
          },
          "transferred_at_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435200,
            "minimum": 0
          }
        }
      },
      "OpenApiUpdateProfileCapacityReservationRequest": {
        "type": "object",
        "description": "Request body for committing or releasing an authd profile-capacity reservation.",
        "required": [
          "instance_id",
          "instance_binding_challenge_id",
          "instance_binding_proof"
        ],
        "properties": {
          "instance_binding_challenge_id": {
            "type": "string",
            "example": "ibc_018f7b0b"
          },
          "instance_binding_proof": {
            "type": "string",
            "example": "{\"challenge_id\":\"ibc_018f7b0b\",\"signature\":\"base64url\"}"
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          }
        }
      },
      "OpenApiValidateProfileCapacityRevisionRequest": {
        "type": "object",
        "description": "Request body for validating a token profile-capacity revision.",
        "required": [
          "instance_id",
          "entitlement_revision"
        ],
        "properties": {
          "entitlement_revision": {
            "type": "integer",
            "format": "int64",
            "example": 11,
            "minimum": 1
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          }
        }
      },
      "OpenApiValidateProfileCapacityRevisionResponse": {
        "type": "object",
        "description": "Response body for token profile-capacity revision validation.",
        "required": [
          "instance_id",
          "submitted_entitlement_revision",
          "current_entitlement_revision",
          "token_profile_limit",
          "active_capacity_limit",
          "is_current",
          "cache_valid_until_epoch"
        ],
        "properties": {
          "active_capacity_limit": {
            "type": "integer",
            "format": "int32",
            "example": 5,
            "minimum": 0
          },
          "cache_valid_until_epoch": {
            "type": "integer",
            "format": "int64",
            "example": 1780435500,
            "minimum": 0
          },
          "current_entitlement_revision": {
            "type": "integer",
            "format": "int64",
            "example": 11,
            "minimum": 0
          },
          "instance_id": {
            "type": "string",
            "format": "uuid",
            "example": "018f7b0b-1111-7000-8000-000000000001"
          },
          "is_current": {
            "type": "boolean"
          },
          "submitted_entitlement_revision": {
            "type": "integer",
            "format": "int64",
            "example": 11,
            "minimum": 1
          },
          "token_profile_limit": {
            "type": "integer",
            "format": "int32",
            "example": 5,
            "minimum": 0
          }
        }
      },
      "RefreshGrantAudience": {
        "type": "string",
        "description": "@impl(R-004) @s(S-004,S-010)\nSupported access token audiences for the refresh grant.\n\nNew variants must be appended to the end of this enum. Reordering variants or inserting a new\nvariant before the end breaks bincode decoding of persisted OAuth client records.",
        "enum": [
          "svc",
          "rates",
          "feedback"
        ]
      },
      "RefreshGrantResponse": {
        "type": "object",
        "description": "@impl(R-010) @s(S-010)\nSuccessful response payload emitted by the refresh grant.",
        "required": [
          "user_id",
          "session_id",
          "access_token",
          "refresh_token",
          "audience"
        ],
        "properties": {
          "access_token": {
            "type": "string",
            "example": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJyYXRlcyIsImV4cCI6MTcwMDAwMDAwMCwiaWF0IjoxNzAwMDAwMDAwLCJzZXNzaW9uX2lkIjoiMDE4OTBiOGMtNWNmZC03ZDVmLThmOTAtM2M3ZjRmNjJkODAxIiwic3ViIjoiODYyZmQ1ZWQtYWM5YS01YmZlLTk2ZjItYWIxZjUwMWEyYzk5IiwidXNlcl9pZCI6InVzZXItMTIzIn0.signature"
          },
          "audience": {
            "$ref": "#/components/schemas/RefreshGrantAudience"
          },
          "notices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/AccountNoticeResponse"
            }
          },
          "refresh_token": {
            "type": "string",
            "example": "wkzmUl4MM3wWOlRmCaHsCq17ttD4xDXZiT5399qom9k",
            "maxLength": 43,
            "minLength": 43
          },
          "session_id": {
            "type": "string",
            "format": "uuid",
            "example": "01890b8c-5cfd-7d5f-8f90-3c7f4f62d801"
          },
          "user_id": {
            "type": "string",
            "example": "user-123"
          }
        }
      },
      "TokenExchangeRequest": {
        "type": "object",
        "description": "@impl(S-015)\nRequest payload for `/v1/token/exchange`.\n\nThis type models the RFC 8693 token exchange request. It enforces that\nthe `subject_token` (<= 8,192 chars) and `subject_token_type` (<= 256 chars)\nfields are trimmed, non-empty, and below conservative upper bounds to guard\nagainst unbounded payloads.\n\n# Examples\n```\n# use clams_authd::token::{RefreshGrantAudience, TokenExchangeRequest};\nlet request = TokenExchangeRequest::new(\n    \"svc-access-token\",\n    \"urn:ietf:params:oauth:token-type:access_token\",\n    RefreshGrantAudience::Svc,\n    Some(\"profile email\".to_owned()),\n);\nassert_eq!(request.subject_token_type(), \"urn:ietf:params:oauth:token-type:access_token\");\nassert_eq!(request.audience(), RefreshGrantAudience::Svc);\nassert_eq!(request.scope(), Some(\"profile email\"));\n```",
        "required": [
          "subject_token",
          "subject_token_type",
          "audience"
        ],
        "properties": {
          "audience": {
            "$ref": "#/components/schemas/RefreshGrantAudience"
          },
          "billing_capabilities": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "default": []
          },
          "billing_protocol_version": {
            "type": [
              "integer",
              "null"
            ],
            "format": "int32",
            "minimum": 0
          },
          "instance_binding_challenge_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "instance_binding_proof": {
            "type": [
              "string",
              "null"
            ]
          },
          "instance_id": {
            "type": [
              "string",
              "null"
            ],
            "format": "uuid"
          },
          "scope": {
            "type": [
              "string",
              "null"
            ],
            "example": "profile email"
          },
          "subject_token": {
            "type": "string",
            "example": "eyJhbGciOiJFZERTQSIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJzdmMiLCJleHAiOjE3MDAwMDAwMDAsImlhdCI6MTcwMDAwMDAwMCwic2Vzc2lvbl9pZCI6IjAxODkwYjhjLTVjZmQtN2Q1Zi04ZjkwLTNjN2Y0ZjYyZDgwMSIsInN1YiI6Ijg2MmZkNWVkLWFjOWEtNWJmZS05NmYyLWFiMWY1MDFhMmM5OSIsInVzZXJfaWQiOiJ1c2VyLTEyMyJ9.signature",
            "maxLength": 8192
          },
          "subject_token_type": {
            "type": "string",
            "example": "urn:ietf:params:oauth:token-type:access_token",
            "maxLength": 256
          }
        }
      },
      "TokenResponse": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/RefreshGrantResponse"
          },
          {
            "$ref": "#/components/schemas/ClientCredentialsGrantResponse"
          }
        ],
        "description": "Union response emitted by `/v1/token`."
      },
      "WhoamiResponse": {
        "type": "object",
        "description": "@impl(R-001) @s(S-001) @contract(C-004)\nSerializable payload returned by `GET /v1/auth/whoami`.\n\nThe verified email is `null` unless the subject email store contains a record\nexplicitly marked as verified.",
        "required": [
          "user_id",
          "subject_id",
          "verified_email"
        ],
        "properties": {
          "subject_id": {
            "type": "string",
            "format": "uuid",
            "example": "862fd5ed-ac9a-5bfe-96f2-ab1f501a2c99"
          },
          "user_id": {
            "type": "string",
            "example": "user-123"
          },
          "verified_email": {
            "type": [
              "string",
              "null"
            ],
            "format": "email"
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
  },
  "tags": [
    {
      "name": "Login",
      "description": "Browser-based login session handshake for CLI/MCP flows"
    },
    {
      "name": "Tokens",
      "description": "Token exchange and refresh"
    },
    {
      "name": "OAuth Clients",
      "description": "Client credentials provisioning"
    },
    {
      "name": "Connection OAuth",
      "description": "Hosted broker endpoints for provider-backed connection authorization"
    },
    {
      "name": "Account",
      "description": "Authenticated account/session helpers"
    },
    {
      "name": "Billing",
      "description": "Legacy compatibility and payment closeout endpoints"
    },
    {
      "name": "Billing History",
      "description": "Authenticated historical invoice access"
    },
    {
      "name": "Discovery",
      "description": "JWKS and OIDC discovery documents"
    }
  ]
}
