{
  "components": {
    "parameters": {
      "PrivacyMode": {
        "description": "Which SUBSTITUTION STYLE your client applies to sensitive values before\nthe request leaves your user's device. Per-call; never persisted.\n\nBoth modes protect the same data — a mode selects style ONLY and can\nnever switch protection off. Both cost something, so choose knowing which:\n\n* `balanced` (default) — Realistic stand-ins: `John Mellows` becomes\n  `Henry Caulinger`. Cost: the model cannot tell the stand-ins are fake,\n  so it may reason about them as if they were real — drawing conclusions\n  from a substituted name, or treating a substituted address as a\n  genuine place.\n* `max` — Opaque placeholders: `John Mellows` becomes\n  `<<CLOAK:PERSON:1>>`. Cost: the model can see the value is hidden, so\n  it may write awkwardly around the placeholder, ask you for the real\n  value, or decline to continue.\n\nEither way, the same detail always maps to the same replacement for the\nwhole conversation, and the real values are restored in the reply on\nyour device. You do not need to ask for that and cannot turn it off.\n\nAn unrecognised value is REJECTED with `400 invalid_privacy_mode` rather\nthan reinterpreted — a header is code you just wrote, and silently\nresolving a typo is how an integration ships believing a privacy setting\nworks. `off` and `continuity` were retired on 2026-07-28: there is no\nunprotected posture, and cross-turn stability is now unconditional.\n",
        "examples": {
          "balanced": {
            "summary": "Realistic stand-ins (default)",
            "value": "balanced"
          },
          "max": {
            "summary": "Opaque placeholders",
            "value": "max"
          }
        },
        "in": "header",
        "name": "X-CloakAPI-Privacy-Tier",
        "required": false,
        "schema": {
          "$ref": "#/components/schemas/PrivacyMode"
        }
      }
    },
    "responses": {
      "IdempotencyConflict": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/IdempotencyError"
            }
          }
        },
        "description": "The Idempotency-Key cannot be used for this request because it conflicts with another request (idempotency_key_conflict), is still in progress (idempotency_request_in_progress), or its response was not retained (idempotency_response_not_retained)."
      },
      "Unauthorized": {
        "description": "Authentication is required or the supplied credentials are not accepted.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GenericError"
            }
          }
        }
      },
      "GatewayModelUnavailable": {
        "description": "The requested model is no longer available or is not a valid model ID for the selected provider.",
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": false,
              "properties": {
                "error": {
                  "additionalProperties": false,
                  "properties": {
                    "code": {
                      "enum": [
                        "model_retired",
                        "model_unavailable"
                      ],
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "param": {
                      "const": "model",
                      "type": "string"
                    },
                    "type": {
                      "const": "invalid_request_error",
                      "type": "string"
                    },
                    "suggested_model": {
                      "$ref": "#/components/schemas/SuggestedModelId"
                    }
                  },
                  "required": [
                    "type",
                    "code",
                    "message",
                    "param"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "error"
              ],
              "type": "object"
            }
          }
        }
      },
      "GatewayServiceUnavailable": {
        "description": "The gateway could not process the request because tokenisation is suspended for the account, a provider is unavailable, stream concurrency coordination is unavailable, or rate limiting is unavailable. `error.type` identifies the response category and `error.code` identifies the cause. `Retry-After` gives the applicable delay. `X-RateLimit-Error` is returned when rate limiting is unavailable.",
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying.",
            "schema": {
              "pattern": "^[1-9][0-9]*$",
              "type": "string"
            }
          },
          "X-RateLimit-Error": {
            "description": "Present when rate limiting is unavailable.",
            "schema": {
              "const": "backend-unavailable",
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": true,
              "properties": {
                "error": {
                  "additionalProperties": true,
                  "properties": {
                    "code": {
                      "enum": [
                        "internal_error",
                        "provider_error",
                        "rate_limiter_backend_unavailable",
                        "tokenisation_suspended",
                        "upstream_circuit_open"
                      ],
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "retry_after_s": {
                      "minimum": 1,
                      "type": "integer"
                    },
                    "type": {
                      "enum": [
                        "internal_error",
                        "provider_error",
                        "service_unavailable"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "code",
                    "message"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "error"
              ],
              "type": "object"
            }
          }
        }
      },
      "ApiKeyUnauthorized": {
        "description": "The API key is missing, invalid, expired, or paused for scheduled account deletion.",
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": false,
              "properties": {
                "error": {
                  "additionalProperties": false,
                  "properties": {
                    "type": {
                      "const": "authentication_error",
                      "type": "string"
                    },
                    "code": {
                      "enum": [
                        "missing_api_key",
                        "invalid_api_key",
                        "expired_api_key",
                        "account_not_found",
                        "account_deletion_scheduled"
                      ],
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "message",
                    "code"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "error"
              ],
              "type": "object"
            }
          }
        }
      },
      "InsufficientBalance": {
        "description": "The account balance is insufficient to continue the request.",
        "content": {
          "application/json": {
            "schema": {
              "additionalProperties": false,
              "properties": {
                "error": {
                  "additionalProperties": false,
                  "properties": {
                    "type": {
                      "const": "billing_error",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "const": "insufficient_balance",
                      "type": "string"
                    },
                    "action": {
                      "const": "topup",
                      "type": "string"
                    },
                    "top_up_url": {
                      "type": "string"
                    },
                    "grace_minutes": {
                      "type": "integer"
                    },
                    "wallet": {
                      "description": "Spendable prepaid balance after in-flight holds. empty means the spendable amount is less than or equal to zero. short means a positive remainder that does not cover this request's hold. unknown means the wallet row could not be read.",
                      "enum": [
                        "empty",
                        "short",
                        "unknown"
                      ],
                      "type": "string"
                    },
                    "cloakup_plan": {
                      "description": "Cloakup subscription state. It does not waive the wallet gate. active means the cloakup subscription is active. past_due means the subscription status is past_due, including inside a paid period. none means there is no cloakup subscription, the user is anonymous, or the subscription row could not be read.",
                      "enum": [
                        "active",
                        "past_due",
                        "none"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "message",
                    "code",
                    "action",
                    "top_up_url",
                    "grace_minutes",
                    "wallet",
                    "cloakup_plan"
                  ],
                  "type": "object"
                }
              },
              "required": [
                "error"
              ],
              "type": "object"
            }
          }
        }
      },
      "RateLimited": {
        "description": "The request was rate limited. API-generated responses are JSON; an edge rate limit may return an HTML error page.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GenericError"
            }
          },
          "text/html": {
            "schema": {
              "type": "string"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "description": "Seconds to wait before retrying, when provided.",
            "schema": {
              "type": "string",
              "pattern": "^[1-9][0-9]*$"
            }
          },
          "X-RateLimit-Scope": {
            "description": "Identifies the scope of the request limit, when provided.",
            "schema": {
              "type": "string"
            }
          }
        }
      },
      "GatewayModelSelectionError": {
        "description": "A chat model ID is unpriced, retired, or unavailable. HTTP 400. `error.suggested_model` gives an active alternative when available and may be null.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayModelSelectionError"
            }
          }
        }
      },
      "GatewayCatalogueStale": {
        "description": "A client-routed model is absent from the current catalogue. HTTP 409 preserves the stale-catalogue signal used by existing SDKs; refresh the catalogue and retry once. `error.suggested_model` may be null.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/GatewayCatalogueStaleError"
            }
          }
        }
      }
    },
    "schemas": {
      "ApiKeyResource": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "last_used_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "ApiKeyResourceC6b": {
        "properties": {
          "allowed_ips": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "expires_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "is_active": {
            "type": "boolean"
          },
          "is_default": {
            "type": "boolean"
          },
          "last_used_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "mirrors_account_settings": {
            "type": "boolean"
          },
          "name": {
            "type": "string"
          },
          "permissions": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "prefix": {
            "type": "string"
          },
          "privacy_tier_override": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/PrivacyMode"
              },
              {
                "type": "null"
              }
            ]
          },
          "rate_limit_rpm": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "name",
          "prefix",
          "permissions",
          "is_active",
          "is_default",
          "mirrors_account_settings",
          "created_at"
        ],
        "type": "object"
      },
      "ChatCompletionsRequest": {
        "additionalProperties": false,
        "properties": {
          "attachments": {
            "description": "Client-reviewed attachment text entries.",
            "items": {
              "additionalProperties": true,
              "properties": {
                "text": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "clipboard": {
            "description": "Optional client-reviewed clipboard text.",
            "type": "string"
          },
          "dimensions": {
            "minimum": 1,
            "type": "integer"
          },
          "encoding_format": {
            "enum": [
              "float",
              "base64"
            ],
            "type": "string"
          },
          "frequency_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "max_completion_tokens": {
            "maximum": 200000,
            "minimum": 1,
            "type": "integer"
          },
          "max_tokens": {
            "type": "integer"
          },
          "messages": {
            "description": "Only allowlisted message keys are accepted. annotations, audio metadata, url_citation, and other unknown message keys are rejected with 422 because they may contain text the client has not reviewed. Content parts also reject unknown keys and unsupported types. This gateway input subset is not measured against the upstream provider.",
            "items": {
              "additionalProperties": false,
              "description": "Only message keys with reviewed SDK channels or protocol identifiers are accepted. name, function_call, refusal, reasoning_content and other unreviewed message keys are rejected with 422. Content parts reject unknown keys and unsupported types. Message-level cache_control is accepted with type ephemeral and optional ttl 5m or 1h.",
              "properties": {
                "attachments": {
                  "description": "Client-reviewed attachment text entries.",
                  "items": {
                    "additionalProperties": true,
                    "properties": {
                      "text": {
                        "type": "string"
                      }
                    },
                    "type": "object"
                  },
                  "type": "array"
                },
                "cache_control": {
                  "additionalProperties": false,
                  "properties": {
                    "ttl": {
                      "enum": [
                        "5m",
                        "1h"
                      ],
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "ephemeral"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "type": "object"
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {
                        "oneOf": [
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "text": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "text",
                                  "input_text"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "text"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "input": {
                                "type": "object"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_use"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "input"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "content": {
                                "oneOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "items": {
                                      "type": "object"
                                    },
                                    "type": "array"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "is_error": {
                                "type": "boolean"
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_result"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "thinking": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "thinking"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "thinking"
                            ],
                            "type": "object"
                          }
                        ]
                      },
                      "type": "array"
                    }
                  ]
                },
                "metadata": {
                  "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
                  "type": "object"
                },
                "role": {
                  "enum": [
                    "system",
                    "developer",
                    "user",
                    "assistant"
                  ],
                  "type": "string"
                },
                "tool_call_id": {},
                "tool_calls": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "function": {
                        "additionalProperties": false,
                        "properties": {
                          "arguments": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "arguments"
                        ],
                        "type": "object"
                      },
                      "id": {
                        "type": "string"
                      },
                      "type": {
                        "enum": [
                          "function"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "function"
                    ],
                    "type": "object"
                  },
                  "type": "array"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "metadata": {
            "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
            "type": "object"
          },
          "model": {
            "maxLength": 64,
            "pattern": "^(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[A-Za-z0-9][A-Za-z0-9._:/@~+-]{0,63}(?![\\s\\S])",
            "type": "string"
          },
          "n": {
            "maximum": 128,
            "minimum": 1,
            "type": "integer"
          },
          "preprompt": {
            "description": "Optional client-reviewed prompt prefix.",
            "type": "string"
          },
          "presence_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "provider": {
            "description": "Provider identifier used for routing. Other values receive 422; inactive or unavailable providers receive 403.",
            "enum": [
              "openai",
              "anthropic",
              "google",
              "azure",
              "grok",
              "openrouter",
              "gemini",
              "deepseek",
              "perplexity",
              "mistral",
              "cohere",
              "groq",
              "together",
              "fireworks"
            ],
            "type": "string"
          },
          "reasoning_effort": {
            "description": "Reasoning effort hint.",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ],
            "type": "string"
          },
          "seed": {
            "maximum": 2147483647,
            "minimum": 0,
            "type": "integer"
          },
          "stop": {
            "description": "Operator configuration, not user text. One string or up to four strings, each at most 32 characters.",
            "oneOf": [
              {
                "maxLength": 32,
                "type": "string"
              },
              {
                "items": {
                  "maxLength": 32,
                  "type": "string"
                },
                "maxItems": 4,
                "type": "array"
              }
            ]
          },
          "stream": {
            "type": "boolean"
          },
          "stream_options": {
            "additionalProperties": false,
            "description": "Optional on streaming chat-completion requests to OpenAI-compatible providers. Only include_usage (boolean) is accepted; the gateway always requests usage on the provider stream. This field does not change the price.",
            "properties": {
              "include_usage": {
                "description": "Optional. The gateway always requests a usage frame on the provider stream.",
                "type": "boolean"
              }
            },
            "type": "object"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "cache_control": {
                      "additionalProperties": false,
                      "properties": {
                        "ttl": {
                          "enum": [
                            "5m",
                            "1h"
                          ],
                          "type": "string"
                        },
                        "type": {
                          "enum": [
                            "ephemeral"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "type": "object"
                    },
                    "text": {
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "text"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "type": "object"
                },
                "type": "array"
              }
            ]
          },
          "temperature": {
            "type": "number"
          },
          "tool_choice": {
            "oneOf": [
              {
                "enum": [
                  "auto",
                  "none",
                  "required"
                ],
                "type": "string"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "function": {
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "name"
                    ],
                    "type": "object"
                  },
                  "type": {
                    "enum": [
                      "function"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "function"
                ],
                "type": "object"
              }
            ]
          },
          "tools": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "function": {
                  "additionalProperties": true,
                  "description": "Optional strict flag for function tools must be a boolean; string values such as \"true\" are rejected.",
                  "properties": {
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "parameters": {
                      "$ref": "#/components/schemas/ReviewedToolJsonSchema"
                    },
                    "strict": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "description"
                  ],
                  "type": "object"
                },
                "type": {
                  "enum": [
                    "function"
                  ],
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "top_p": {
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "user": {
            "description": "Optional short identifier only. Arbitrary user strings are not supported yet and receive 422.",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$",
            "type": "string"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "ChatCompletionsResponse": {
        "properties": {
          "choices": {
            "items": {
              "properties": {
                "finish_reason": {
                  "type": "string"
                },
                "index": {
                  "type": "integer"
                },
                "message": {
                  "properties": {
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "role": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "created": {
            "type": "integer"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "example": "chat.completion",
            "type": "string"
          },
          "usage": {
            "properties": {
              "completion_tokens": {
                "type": "integer"
              },
              "prompt_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "ConsumerUserResource": {
        "description": "Consumer profile returned by the consumer-auth endpoints.",
        "properties": {
          "anonymous_balance_used": {
            "type": "boolean"
          },
          "balance_cents": {
            "type": "integer"
          },
          "balance_dollars": {
            "format": "double",
            "type": "number"
          },
          "created_at": {
            "format": "date-time",
            "nullable": true,
            "type": "string"
          },
          "email": {
            "format": "email",
            "type": "string"
          },
          "email_verified": {
            "type": "boolean"
          },
          "id": {
            "type": "integer"
          },
          "is_low_balance": {
            "type": "boolean"
          },
          "name": {
            "nullable": true,
            "type": "string"
          },
          "organisation_id": {
            "nullable": true,
            "type": "integer"
          },
          "balance_micros": {
            "description": "Exact wallet balance in USD micro-dollars.",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "EmbeddingsRequest": {
        "additionalProperties": false,
        "properties": {
          "attachments": {
            "description": "Client-reviewed attachment text entries.",
            "items": {
              "additionalProperties": true,
              "properties": {
                "text": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "clipboard": {
            "description": "Optional client-reviewed clipboard text.",
            "type": "string"
          },
          "dimensions": {
            "minimum": 1,
            "type": "integer"
          },
          "encoding_format": {
            "default": "float",
            "enum": [
              "float",
              "base64"
            ],
            "type": "string"
          },
          "frequency_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "input": {
            "description": "Integer token IDs only. The TypeScript request-body slot list has no reviewed text channel for raw embeddings input.",
            "oneOf": [
              {
                "items": {
                  "type": "integer"
                },
                "type": "array"
              },
              {
                "items": {
                  "items": {
                    "type": "integer"
                  },
                  "type": "array"
                },
                "type": "array"
              }
            ]
          },
          "max_completion_tokens": {
            "maximum": 200000,
            "minimum": 1,
            "type": "integer"
          },
          "max_tokens": {
            "type": "integer"
          },
          "messages": {
            "description": "Only allowlisted message keys are accepted. annotations, audio metadata, url_citation, and other unknown message keys are rejected with 422 because they may contain text the client has not reviewed. Content parts also reject unknown keys and unsupported types. This gateway input subset is not measured against the upstream provider.",
            "items": {
              "additionalProperties": false,
              "description": "Only message keys with reviewed SDK channels or protocol identifiers are accepted. name, function_call, refusal, reasoning_content and other unreviewed message keys are rejected with 422. Content parts reject unknown keys and unsupported types. Message-level cache_control is accepted with type ephemeral and optional ttl 5m or 1h.",
              "properties": {
                "cache_control": {
                  "additionalProperties": false,
                  "properties": {
                    "ttl": {
                      "enum": [
                        "5m",
                        "1h"
                      ],
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "ephemeral"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "type": "object"
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {
                        "oneOf": [
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "text": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "text",
                                  "input_text"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "text"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "input": {
                                "type": "object"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_use"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "input"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "content": {
                                "oneOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "items": {
                                      "type": "object"
                                    },
                                    "type": "array"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "is_error": {
                                "type": "boolean"
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_result"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "thinking": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "thinking"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "thinking"
                            ],
                            "type": "object"
                          }
                        ]
                      },
                      "type": "array"
                    }
                  ]
                },
                "metadata": {
                  "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
                  "type": "object"
                },
                "role": {
                  "enum": [
                    "system",
                    "developer",
                    "user",
                    "assistant"
                  ],
                  "type": "string"
                },
                "tool_call_id": {},
                "tool_calls": {
                  "items": {
                    "additionalProperties": false,
                    "properties": {
                      "function": {
                        "additionalProperties": false,
                        "properties": {
                          "arguments": {
                            "type": "string"
                          },
                          "name": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "arguments"
                        ],
                        "type": "object"
                      },
                      "id": {
                        "type": "string"
                      },
                      "type": {
                        "enum": [
                          "function"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "function"
                    ],
                    "type": "object"
                  },
                  "type": "array"
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "metadata": {
            "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
            "type": "object"
          },
          "model": {
            "maxLength": 64,
            "pattern": "^(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[A-Za-z0-9][A-Za-z0-9._:/@~+-]{0,63}(?![\\s\\S])",
            "type": "string"
          },
          "n": {
            "maximum": 128,
            "minimum": 1,
            "type": "integer"
          },
          "preprompt": {
            "description": "Optional client-reviewed prompt prefix.",
            "type": "string"
          },
          "presence_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "provider": {
            "description": "Provider identifier used for routing. Other values receive 422; inactive or unavailable providers receive 403.",
            "enum": [
              "openai",
              "anthropic",
              "google",
              "azure",
              "grok",
              "openrouter",
              "gemini",
              "deepseek",
              "perplexity",
              "mistral",
              "cohere",
              "groq",
              "together",
              "fireworks"
            ],
            "type": "string"
          },
          "reasoning_effort": {
            "description": "Reasoning effort hint.",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ],
            "type": "string"
          },
          "seed": {
            "maximum": 2147483647,
            "minimum": 0,
            "type": "integer"
          },
          "stop": {
            "description": "Operator configuration, not user text. One string or up to four strings, each at most 32 characters.",
            "oneOf": [
              {
                "maxLength": 32,
                "type": "string"
              },
              {
                "items": {
                  "maxLength": 32,
                  "type": "string"
                },
                "maxItems": 4,
                "type": "array"
              }
            ]
          },
          "stream": {
            "type": "boolean"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "cache_control": {
                      "additionalProperties": false,
                      "properties": {
                        "ttl": {
                          "enum": [
                            "5m",
                            "1h"
                          ],
                          "type": "string"
                        },
                        "type": {
                          "enum": [
                            "ephemeral"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "type": "object"
                    },
                    "text": {
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "text"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "type": "object"
                },
                "type": "array"
              }
            ]
          },
          "temperature": {
            "type": "number"
          },
          "tool_choice": {
            "oneOf": [
              {
                "enum": [
                  "auto",
                  "none",
                  "required"
                ],
                "type": "string"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "function": {
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "name"
                    ],
                    "type": "object"
                  },
                  "type": {
                    "enum": [
                      "function"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "function"
                ],
                "type": "object"
              }
            ]
          },
          "tools": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "function": {
                  "additionalProperties": true,
                  "properties": {
                    "description": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "parameters": {
                      "$ref": "#/components/schemas/ReviewedToolJsonSchema"
                    }
                  },
                  "required": [
                    "description"
                  ],
                  "type": "object"
                },
                "type": {
                  "enum": [
                    "function"
                  ],
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "top_p": {
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "user": {
            "description": "Optional short identifier only. Arbitrary user strings are not supported yet and receive 422.",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$",
            "type": "string"
          }
        },
        "required": [
          "input",
          "model"
        ],
        "type": "object"
      },
      "EmbeddingsResponse": {
        "properties": {
          "data": {
            "items": {
              "properties": {
                "embedding": {
                  "items": {
                    "type": "number"
                  },
                  "type": "array"
                },
                "index": {
                  "type": "integer"
                },
                "object": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          },
          "object": {
            "example": "list",
            "type": "string"
          },
          "usage": {
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "EntitlementsResponse": {
        "properties": {
          "billing_model": {
            "example": "prepaid",
            "type": "string"
          },
          "cache_ttl_seconds": {
            "type": "integer"
          },
          "entitlements": {
            "properties": {
              "code_execution": {
                "type": "boolean"
              },
              "compliance_packs": {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "federated_benchmarks": {
                "type": "boolean"
              },
              "named_engineer": {
                "type": "boolean"
              },
              "premium_catalogue": {
                "type": "boolean"
              },
              "priority_support": {
                "type": "boolean"
              },
              "rag": {
                "type": "boolean"
              },
              "scheduled_inference": {
                "type": "boolean"
              },
              "syncthing": {
                "type": "boolean"
              },
              "team_key_escrow": {
                "type": "boolean"
              },
              "unlimited_model_slots": {
                "type": "boolean"
              },
              "web_search_multi_provider": {
                "type": "boolean"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "Error": {
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ErrorWithCode": {
        "properties": {
          "error_code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "request_id": {
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "example": "error",
            "type": "string"
          }
        },
        "required": [
          "status",
          "error_code",
          "message"
        ],
        "type": "object"
      },
      "FilesProcessResponse": {
        "properties": {
          "file_attestation": {
            "type": "object"
          },
          "file_sha256": {
            "type": "string"
          },
          "mime": {
            "type": "string"
          },
          "mime_mismatch": {
            "type": "boolean"
          },
          "request_id": {
            "format": "uuid",
            "type": "string"
          },
          "status": {
            "example": "ok",
            "type": "string"
          },
          "total_latency_ms": {
            "type": "integer"
          }
        },
        "type": "object"
      },
      "HeartbeatResponse": {
        "properties": {
          "entitlements": {
            "type": "object"
          },
          "next_check_in_seconds": {
            "type": "integer"
          },
          "subscription_tier": {
            "type": "string"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "IdempotencyError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "enum": [
                  "idempotency_key_conflict",
                  "idempotency_request_in_progress",
                  "idempotency_response_not_retained"
                ],
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "type": {
                "const": "idempotency_error",
                "type": "string"
              }
            },
            "required": [
              "type",
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ImagesGenerationsRequest": {
        "properties": {
          "model": {
            "type": "string"
          },
          "n": {
            "default": 1,
            "type": "integer"
          },
          "prompt": {
            "type": "string"
          },
          "quality": {
            "enum": [
              "standard",
              "hd"
            ],
            "type": "string"
          },
          "response_format": {
            "enum": [
              "url",
              "b64_json"
            ],
            "type": "string"
          },
          "size": {
            "enum": [
              "256x256",
              "512x512",
              "1024x1024",
              "1792x1024",
              "1024x1792"
            ],
            "type": "string"
          }
        },
        "required": [
          "prompt"
        ],
        "type": "object"
      },
      "LegalOnboardingState": {
        "properties": {
          "privacy_policy_accepted_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "privacy_version": {
            "type": [
              "string",
              "null"
            ]
          },
          "terms_accepted_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "terms_version": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "terms_accepted_at",
          "privacy_policy_accepted_at",
          "terms_version",
          "privacy_version"
        ],
        "type": "object"
      },
      "LocalReceiptRequest": {
        "properties": {
          "gateway_lite_version": {
            "maxLength": 20,
            "type": [
              "string",
              "null"
            ]
          },
          "issued_at": {
            "example": "2026-04-23T10:00:00Z",
            "format": "date-time",
            "type": "string"
          },
          "local_ai_binary_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "local_ai_model": {
            "maxLength": 200,
            "type": "string"
          },
          "local_ai_runtime": {
            "maxLength": 100,
            "type": "string"
          },
          "local_ai_runtime_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "rag_chunk_hashes": {
            "items": {
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "rag_index": {
            "type": [
              "string",
              "null"
            ]
          },
          "receipt_id": {
            "format": "uuid",
            "type": "string"
          },
          "request_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "response_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "route": {
            "enum": [
              "local"
            ],
            "type": "string"
          },
          "scanner_verdict": {
            "enum": [
              "pass",
              "medium",
              "high",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "session_id": {
            "maxLength": 64,
            "type": "string"
          },
          "signature": {
            "maxLength": 200,
            "type": "string"
          },
          "tool_calls": {
            "items": {
              "properties": {
                "argument_hash": {
                  "type": "string"
                },
                "exit_code": {
                  "type": "integer"
                },
                "result_hash": {
                  "type": "string"
                },
                "tool_name": {
                  "type": "string"
                }
              },
              "required": [
                "tool_name",
                "argument_hash",
                "result_hash",
                "exit_code"
              ],
              "type": "object"
            },
            "maxItems": 20,
            "type": [
              "array",
              "null"
            ]
          },
          "web_search_enabled": {
            "type": "boolean"
          }
        },
        "required": [
          "receipt_id",
          "route",
          "session_id",
          "request_hash",
          "response_hash",
          "local_ai_model",
          "local_ai_binary_hash",
          "local_ai_runtime",
          "web_search_enabled",
          "signature",
          "issued_at"
        ],
        "type": "object"
      },
      "LocalReceiptResponse": {
        "properties": {
          "chain_index": {
            "type": "integer"
          },
          "receipt_id": {
            "type": "string"
          },
          "recorded": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "MessagesRequest": {
        "additionalProperties": false,
        "properties": {
          "attachments": {
            "description": "Client-reviewed attachment text entries.",
            "items": {
              "additionalProperties": true,
              "properties": {
                "text": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "clipboard": {
            "description": "Optional client-reviewed clipboard text.",
            "type": "string"
          },
          "dimensions": {
            "minimum": 1,
            "type": "integer"
          },
          "encoding_format": {
            "enum": [
              "float",
              "base64"
            ],
            "type": "string"
          },
          "frequency_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "max_completion_tokens": {
            "maximum": 200000,
            "minimum": 1,
            "type": "integer"
          },
          "max_tokens": {
            "minimum": 1,
            "type": "integer"
          },
          "messages": {
            "description": "Only allowlisted message keys are accepted. annotations, audio metadata, url_citation, and other unknown message keys are rejected with 422 because they may contain text the client has not reviewed. Content parts also reject unknown keys and unsupported types. This gateway input subset is not measured against the upstream provider.",
            "items": {
              "additionalProperties": false,
              "description": "Only message keys with reviewed SDK channels or protocol identifiers are accepted. name, function_call, refusal, reasoning_content and other unreviewed message keys are rejected with 422. Content parts reject unknown keys and unsupported types. Message-level cache_control is accepted with type ephemeral and optional ttl 5m or 1h.",
              "properties": {
                "attachments": {
                  "description": "Client-reviewed attachment text entries.",
                  "items": {
                    "additionalProperties": true,
                    "properties": {
                      "text": {
                        "type": "string"
                      }
                    },
                    "type": "object"
                  },
                  "type": "array"
                },
                "cache_control": {
                  "additionalProperties": false,
                  "properties": {
                    "ttl": {
                      "enum": [
                        "5m",
                        "1h"
                      ],
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "ephemeral"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type"
                  ],
                  "type": "object"
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "items": {
                        "oneOf": [
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "text": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "text",
                                  "input_text"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "text"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "id": {
                                "type": "string"
                              },
                              "input": {
                                "type": "object"
                              },
                              "name": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_use"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "input"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "cache_control": {
                                "additionalProperties": false,
                                "properties": {
                                  "ttl": {
                                    "enum": [
                                      "5m",
                                      "1h"
                                    ],
                                    "type": "string"
                                  },
                                  "type": {
                                    "enum": [
                                      "ephemeral"
                                    ],
                                    "type": "string"
                                  }
                                },
                                "required": [
                                  "type"
                                ],
                                "type": "object"
                              },
                              "content": {
                                "oneOf": [
                                  {
                                    "type": "string"
                                  },
                                  {
                                    "items": {
                                      "type": "object"
                                    },
                                    "type": "array"
                                  },
                                  {
                                    "type": "null"
                                  }
                                ]
                              },
                              "is_error": {
                                "type": "boolean"
                              },
                              "tool_use_id": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "tool_result"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type"
                            ],
                            "type": "object"
                          },
                          {
                            "additionalProperties": false,
                            "properties": {
                              "thinking": {
                                "type": "string"
                              },
                              "type": {
                                "enum": [
                                  "thinking"
                                ],
                                "type": "string"
                              }
                            },
                            "required": [
                              "type",
                              "thinking"
                            ],
                            "type": "object"
                          }
                        ]
                      },
                      "type": "array"
                    }
                  ]
                },
                "metadata": {
                  "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
                  "type": "object"
                },
                "role": {
                  "enum": [
                    "system",
                    "developer",
                    "user",
                    "assistant"
                  ],
                  "type": "string"
                },
                "tool_call_id": {},
                "tool_calls": {}
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "metadata": {
            "description": "messages[*].metadata is removed before the request is forwarded. Root metadata keys must match the key class [A-Za-z0-9_.-]{1,32} and are not tokenized. Root string values that match the string class [A-Za-z0-9_.:@+/-]{0,512} are forwarded unchanged, except e-mail-form identity values, which are removed. A key or string outside its class receives 422.",
            "type": "object"
          },
          "model": {
            "example": "claude-opus-4-6",
            "maxLength": 64,
            "pattern": "^(?!.*//)(?!.*(?:^|/)\\.{1,2}(?:/|$))(?!.*\\/$)[A-Za-z0-9][A-Za-z0-9._:/@~+-]{0,63}(?![\\s\\S])",
            "type": "string"
          },
          "n": {
            "maximum": 128,
            "minimum": 1,
            "type": "integer"
          },
          "preprompt": {
            "description": "Optional client-reviewed prompt prefix.",
            "type": "string"
          },
          "presence_penalty": {
            "maximum": 2,
            "minimum": -2,
            "type": "number"
          },
          "provider": {
            "description": "Provider identifier used for routing. Other values receive 422; inactive or unavailable providers receive 403.",
            "enum": [
              "openai",
              "anthropic",
              "google",
              "azure",
              "grok",
              "openrouter",
              "gemini",
              "deepseek",
              "perplexity",
              "mistral",
              "cohere",
              "groq",
              "together",
              "fireworks"
            ],
            "type": "string"
          },
          "reasoning_effort": {
            "description": "Reasoning effort hint.",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ],
            "type": "string"
          },
          "seed": {
            "maximum": 2147483647,
            "minimum": 0,
            "type": "integer"
          },
          "stop": {
            "description": "Operator configuration, not user text. One string or up to four strings, each at most 32 characters.",
            "oneOf": [
              {
                "maxLength": 32,
                "type": "string"
              },
              {
                "items": {
                  "maxLength": 32,
                  "type": "string"
                },
                "maxItems": 4,
                "type": "array"
              }
            ]
          },
          "stream": {
            "default": false,
            "type": "boolean"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "additionalProperties": false,
                  "properties": {
                    "cache_control": {
                      "additionalProperties": false,
                      "properties": {
                        "ttl": {
                          "enum": [
                            "5m",
                            "1h"
                          ],
                          "type": "string"
                        },
                        "type": {
                          "enum": [
                            "ephemeral"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "type"
                      ],
                      "type": "object"
                    },
                    "text": {
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "text"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ],
                  "type": "object"
                },
                "type": "array"
              }
            ]
          },
          "temperature": {
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "tool_choice": {
            "oneOf": [
              {
                "enum": [
                  "auto",
                  "none",
                  "required"
                ],
                "type": "string"
              },
              {
                "additionalProperties": false,
                "properties": {
                  "function": {
                    "additionalProperties": false,
                    "properties": {
                      "name": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "name"
                    ],
                    "type": "object"
                  },
                  "type": {
                    "enum": [
                      "function"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "type",
                  "function"
                ],
                "type": "object"
              }
            ]
          },
          "tools": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "description": {
                  "type": "string"
                },
                "input_schema": {
                  "$ref": "#/components/schemas/ReviewedToolJsonSchema"
                },
                "name": {
                  "type": "string"
                }
              },
              "type": "object"
            },
            "type": "array"
          },
          "top_p": {
            "maximum": 1,
            "minimum": 0,
            "type": "number"
          },
          "user": {
            "description": "Optional short identifier only. Arbitrary user strings are not supported yet and receive 422.",
            "pattern": "^[A-Za-z0-9_.:-]{1,64}$",
            "type": "string"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "MessagesResponse": {
        "properties": {
          "content": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "id": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "role": {
            "example": "assistant",
            "type": "string"
          },
          "stop_reason": {
            "type": "string"
          },
          "type": {
            "example": "message",
            "type": "string"
          },
          "usage": {
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "OpenReceiptEnvelope": {
        "properties": {
          "alg": {
            "description": "Signature algorithm (FIPS 186-5)",
            "enum": [
              "ecdsa-p256-sha256"
            ],
            "type": "string"
          },
          "chain": {
            "$ref": "#/components/schemas/ReceiptChain"
          },
          "claims": {
            "$ref": "#/components/schemas/ReceiptClaims"
          },
          "exp": {
            "description": "Expiry (optional)",
            "type": "integer"
          },
          "iat": {
            "description": "Issued-at (Unix seconds)",
            "type": "integer"
          },
          "iss": {
            "format": "uri",
            "type": "string",
            "description": "Issuer URL identifying the producer, e.g. `https://issuer.example` (reserved example domain)."
          },
          "jti": {
            "description": "Unique ULID identifier",
            "type": "string"
          },
          "kid": {
            "description": "Key identifier; resolves via /.well-known/cloakapi-receipt-pubkey.pem",
            "type": "string"
          },
          "nbf": {
            "description": "Not-before (defaults to iat)",
            "type": "integer"
          },
          "sig": {
            "description": "Base64url-encoded ECDSA P-256 signature (raw r||s)",
            "type": "string"
          },
          "sub": {
            "description": "Opaque request/session identifier; no PII",
            "type": "string"
          },
          "v": {
            "description": "Envelope version tag",
            "example": "v1",
            "type": "string"
          }
        },
        "required": [
          "v",
          "alg",
          "kid",
          "iss",
          "sub",
          "iat",
          "jti",
          "chain",
          "claims",
          "sig"
        ],
        "type": "object"
      },
      "OrggrcArbitrageReorder": {
        "example": {
          "ids": [
            12,
            13
          ]
        },
        "properties": {
          "ids": {
            "items": {
              "minimum": 1,
              "type": "integer"
            },
            "minItems": 1,
            "type": "array"
          }
        },
        "required": [
          "ids"
        ],
        "type": "object"
      },
      "OrggrcArbitrageRuleCreate": {
        "example": {
          "condition": {
            "expr": "prompt.tokens > 1000"
          },
          "name": "Large prompt route",
          "primary_provider": "anthropic/claude-haiku-4-5"
        },
        "properties": {
          "condition": {
            "additionalProperties": false,
            "description": "Supported keys are lang, role, length, region, and expr. The expr value is parsed as a condition with prompt.tokens, cost.cents_estimate, length, detector.<id>, task, tier, lang, role, region, or needs.reasoning fields; comparisons may be joined by AND or OR and grouped with parentheses. Expressions and model targets are validated when saved. These saved rules are not currently applied to inference requests. An empty condition is allowed only when is_catch_all is true.",
            "properties": {
              "expr": {
                "description": "A condition expression; see the supported fields and operators on condition.",
                "maxLength": 2048,
                "type": "string"
              },
              "lang": {},
              "length": {},
              "region": {},
              "role": {}
            },
            "type": "object"
          },
          "enabled": {
            "type": "boolean"
          },
          "fallback_provider": {
            "example": "openai/gpt-5.4-mini",
            "maxLength": 60,
            "nullable": true,
            "type": "string",
            "description": "A provider slug, provider/model pair, or model ID from the current provider catalogue. Display names without a matching catalogue ID are rejected."
          },
          "is_catch_all": {
            "type": "boolean"
          },
          "name": {
            "example": "Primary route",
            "maxLength": 120,
            "minLength": 1,
            "type": "string"
          },
          "position": {
            "maximum": 9999,
            "minimum": 0,
            "type": "integer"
          },
          "primary_provider": {
            "example": "anthropic/claude-haiku-4-5",
            "maxLength": 60,
            "minLength": 1,
            "type": "string",
            "description": "A provider slug, provider/model pair, or model ID from the current provider catalogue. Display names without a matching catalogue ID are rejected."
          },
          "weight": {
            "maximum": 100,
            "minimum": 1,
            "type": "integer"
          }
        },
        "required": [
          "name",
          "condition",
          "primary_provider"
        ],
        "type": "object"
      },
      "OrggrcArbitrageRuleUpdate": {
        "example": {
          "enabled": false
        },
        "properties": {
          "condition": {
            "additionalProperties": false,
            "description": "Supported keys are lang, role, length, region, and expr. The expr value is parsed as a condition with prompt.tokens, cost.cents_estimate, length, detector.<id>, task, tier, lang, role, region, or needs.reasoning fields; comparisons may be joined by AND or OR and grouped with parentheses. Expressions and model targets are validated when saved. These saved rules are not currently applied to inference requests. An empty condition is allowed only when is_catch_all is true.",
            "properties": {
              "expr": {
                "description": "A condition expression; see the supported fields and operators on condition.",
                "maxLength": 2048,
                "type": "string"
              },
              "lang": {},
              "length": {},
              "region": {},
              "role": {}
            },
            "type": "object"
          },
          "enabled": {
            "type": "boolean"
          },
          "fallback_provider": {
            "maxLength": 60,
            "nullable": true,
            "type": "string",
            "description": "A provider slug, provider/model pair, or model ID from the current provider catalogue. Display names without a matching catalogue ID are rejected.",
            "example": "openai/gpt-5.4-mini"
          },
          "is_catch_all": {
            "type": "boolean"
          },
          "name": {
            "maxLength": 120,
            "minLength": 1,
            "type": "string"
          },
          "position": {
            "maximum": 9999,
            "minimum": 0,
            "type": "integer"
          },
          "primary_provider": {
            "maxLength": 60,
            "type": "string",
            "description": "A provider slug, provider/model pair, or model ID from the current provider catalogue. Display names without a matching catalogue ID are rejected.",
            "example": "anthropic/claude-haiku-4-5"
          },
          "weight": {
            "maximum": 100,
            "minimum": 1,
            "type": "integer"
          }
        },
        "type": "object"
      },
      "OrggrcBuilderUserCreate": {
        "example": {
          "app_id": "sample-app",
          "email": "person@example.test"
        },
        "properties": {
          "app_id": {
            "example": "sample-app",
            "maxLength": 64,
            "minLength": 1,
            "pattern": "^[a-z0-9._-]+$",
            "type": "string"
          },
          "email": {
            "example": "person@example.test",
            "format": "email",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "name": {
            "example": "Sample User",
            "maxLength": 255,
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "email",
          "app_id"
        ],
        "type": "object"
      },
      "OrggrcComplianceCustomPack": {
        "example": {
          "controls": [],
          "name": "Sample controls",
          "regulations": [
            "Example Standard"
          ],
          "slug": "sample-pack"
        },
        "properties": {
          "audit_event_tags": {
            "items": {
              "maxLength": 120,
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "controls": {
            "items": {
              "additionalProperties": true,
              "description": "Each control entry may contain arbitrary JSON object fields. The API validates that controls is an array but does not validate or interpret the fields inside each entry.",
              "type": "object"
            },
            "type": "array"
          },
          "description": {
            "example": "Example compliance controls",
            "maxLength": 1024,
            "nullable": true,
            "type": "string"
          },
          "ingester_pills": {
            "items": {
              "maxLength": 60,
              "type": "string"
            },
            "nullable": true,
            "type": "array"
          },
          "name": {
            "example": "Sample controls",
            "maxLength": 120,
            "minLength": 1,
            "type": "string"
          },
          "regulations": {
            "items": {
              "maxLength": 200,
              "type": "string"
            },
            "minItems": 1,
            "type": "array"
          },
          "slug": {
            "example": "sample-pack",
            "maxLength": 60,
            "minLength": 1,
            "pattern": "^[a-z0-9][a-z0-9_-]*$",
            "type": "string"
          }
        },
        "required": [
          "slug",
          "name",
          "regulations",
          "controls"
        ],
        "type": "object"
      },
      "OrggrcComplianceEnableControl": {
        "example": {
          "pack_slug": "soc2-lite"
        },
        "properties": {
          "pack_slug": {
            "example": "soc2-lite",
            "maxLength": 80,
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrggrcComplianceOrgPackDisable": {
        "example": {
          "slug": "soc2"
        },
        "properties": {
          "reason": {
            "example": "Annual review",
            "maxLength": 512,
            "nullable": true,
            "type": "string"
          },
          "slug": {
            "example": "soc2",
            "maxLength": 60,
            "minLength": 1,
            "pattern": "^[a-z0-9][a-z0-9_.-]*$",
            "type": "string"
          }
        },
        "required": [
          "slug"
        ],
        "type": "object"
      },
      "OrggrcComplianceOrgPackEnable": {
        "example": {
          "slug": "soc2"
        },
        "properties": {
          "reason": {
            "example": "Annual review",
            "maxLength": 512,
            "nullable": true,
            "type": "string"
          },
          "slug": {
            "example": "soc2",
            "maxLength": 60,
            "minLength": 1,
            "pattern": "^[a-z0-9][a-z0-9_.-]*$",
            "type": "string"
          }
        },
        "required": [
          "slug"
        ],
        "type": "object"
      },
      "OrggrcGrcConnectorUpsert": {
        "example": {
          "enabled": true,
          "platform_target": "workspace-a"
        },
        "properties": {
          "api_token": {
            "example": "redacted-token-example",
            "maxLength": 2048,
            "nullable": true,
            "type": "string"
          },
          "enabled": {
            "type": "boolean"
          },
          "evidence_id": {
            "example": "control-1",
            "maxLength": 255,
            "nullable": true,
            "type": "string"
          },
          "platform_target": {
            "example": "workspace-a",
            "maxLength": 255,
            "nullable": true,
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrggrcOrganisationAcceptInvitation": {
        "example": {
          "token": "synthetic-invitation-token"
        },
        "properties": {
          "token": {
            "example": "synthetic-invitation-token",
            "maxLength": 128,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "token"
        ],
        "type": "object"
      },
      "OrggrcOrganisationInvite": {
        "example": {
          "email": "invitee@example.test",
          "role": "member"
        },
        "properties": {
          "email": {
            "example": "invitee@example.test",
            "format": "email",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "role": {
            "enum": [
              "admin",
              "developer",
              "security",
              "auditor",
              "billing",
              "support",
              "compliance-officer",
              "service",
              "member"
            ],
            "example": "member",
            "maxLength": 64,
            "nullable": true,
            "type": "string"
          }
        },
        "required": [
          "email"
        ],
        "type": "object"
      },
      "OrggrcOrganisationMemberRole": {
        "example": {
          "role": "member"
        },
        "properties": {
          "role": {
            "enum": [
              "owner",
              "admin",
              "developer",
              "security",
              "auditor",
              "billing",
              "support",
              "compliance-officer",
              "service",
              "member"
            ],
            "example": "member",
            "maxLength": 64,
            "minLength": 1,
            "type": "string"
          }
        },
        "required": [
          "role"
        ],
        "type": "object"
      },
      "OrggrcOrganisationNotifications": {
        "example": {
          "weekly_digest": true
        },
        "properties": {
          "slack_webhook": {
            "example": "https://hooks.slack.com/services/example",
            "maxLength": 512,
            "nullable": true,
            "pattern": "^https://hooks\\.slack\\.com/services/.+$",
            "type": "string"
          },
          "weekly_digest": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "OrggrcOrganisationSecurity": {
        "example": {
          "require_sso": false,
          "session_lifetime": "8h"
        },
        "properties": {
          "require_sso": {
            "type": "boolean"
          },
          "session_lifetime": {
            "enum": [
              "1h",
              "8h",
              "24h",
              "7d"
            ],
            "example": "8h",
            "type": "string"
          }
        },
        "type": "object"
      },
      "OrggrcOrganisationUpdate": {
        "example": {
          "name": "Example Organisation",
          "region": "eu-west-1",
          "timezone": "Europe/Berlin"
        },
        "properties": {
          "name": {
            "example": "Example Organisation",
            "maxLength": 255,
            "minLength": 1,
            "type": "string"
          },
          "region": {
            "enum": [
              "eu-west-1",
              "eu-central-1",
              "us-east-1",
              "us-west-2",
              "ap-se-1"
            ],
            "example": "eu-west-1",
            "type": "string"
          },
          "timezone": {
            "example": "Europe/Berlin",
            "maxLength": 64,
            "type": "string"
          }
        },
        "type": "object"
      },
      "PrivacyActiveTier": {
        "additionalProperties": false,
        "properties": {
          "base": {
            "enum": [
              "max",
              "balanced"
            ],
            "type": "string"
          },
          "custom_tier": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PrivacyTier"
              },
              {
                "type": "null"
              }
            ]
          },
          "custom_tier_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "header_override": {
            "type": "boolean"
          },
          "parent_fallback": {
            "type": "boolean"
          },
          "source": {
            "enum": [
              "preset",
              "custom"
            ],
            "type": "string"
          }
        },
        "required": [
          "base",
          "custom_tier_id",
          "custom_tier",
          "parent_fallback",
          "source",
          "header_override"
        ],
        "type": "object"
      },
      "PrivacyAuditDecode": {
        "additionalProperties": false,
        "properties": {
          "at": {
            "format": "date-time",
            "type": "string"
          },
          "audit_id": {
            "type": "integer"
          },
          "prev_sig": {
            "type": "string"
          },
          "recorded": {
            "type": "boolean"
          }
        },
        "required": [
          "recorded",
          "audit_id",
          "at",
          "prev_sig"
        ],
        "type": "object"
      },
      "PrivacyBaseTier": {
        "additionalProperties": false,
        "properties": {
          "display_name": {
            "type": "string"
          },
          "id": {
            "enum": [
              "max",
              "balanced"
            ],
            "type": "string"
          },
          "quality_pct": {
            "type": "number"
          },
          "requires_desktop": {
            "type": "boolean"
          },
          "summary": {
            "type": "string"
          },
          "tradeoff": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "display_name",
          "requires_desktop",
          "quality_pct",
          "summary",
          "tradeoff"
        ],
        "type": "object"
      },
      "PrivacyChatRotation": {
        "additionalProperties": false,
        "properties": {
          "chat_id": {
            "maxLength": 128,
            "type": "string"
          },
          "rotated": {
            "type": "boolean"
          },
          "scramble_seed_hmac": {
            "type": "string"
          }
        },
        "required": [
          "rotated",
          "chat_id",
          "scramble_seed_hmac"
        ],
        "type": "object"
      },
      "PrivacyCustomTierList": {
        "additionalProperties": false,
        "properties": {
          "max": {
            "minimum": 0,
            "type": "integer"
          },
          "tiers": {
            "items": {
              "$ref": "#/components/schemas/PrivacyTier"
            },
            "type": "array"
          }
        },
        "required": [
          "tiers",
          "max"
        ],
        "type": "object"
      },
      "PrivacyDeleteTier": {
        "additionalProperties": false,
        "properties": {
          "deleted": {
            "type": "boolean"
          },
          "id": {
            "type": "integer"
          }
        },
        "required": [
          "deleted",
          "id"
        ],
        "type": "object"
      },
      "PrivacyError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "kid": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "ref": {
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            },
            "type": "object"
          },
          "errors": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "PrivacyGeneric": {
        "additionalProperties": true,
        "properties": {},
        "type": "object"
      },
      "PrivacyMode": {
        "default": "balanced",
        "description": "Which substitution style the client selects for values it detects before sending. The two modes describe the replacement style; they do not control server-side detection or prove that a detector ran. Supported client paths attempt best-effort on-device detection and tokenisation. The gateway receives request bytes and cannot verify that client detection ran or that the text was reviewed.",
        "enum": [
          "balanced",
          "max"
        ],
        "example": "balanced",
        "title": "Surrogate mode",
        "type": "string"
      },
      "PrivacyOnboarding": {
        "additionalProperties": false,
        "properties": {
          "desktop_offered": {
            "type": "boolean"
          },
          "first_call_modal_seen_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "first_test_call_completed": {
            "type": "boolean"
          },
          "tier_pick_normalised": {
            "type": "boolean"
          },
          "tier_picked_during_onboarding": {
            "enum": [
              "max",
              "balanced",
              "custom",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "first_call_modal_seen_at",
          "tier_picked_during_onboarding",
          "desktop_offered",
          "first_test_call_completed"
        ],
        "type": "object"
      },
      "PrivacyPendingPreview": {
        "additionalProperties": false,
        "properties": {
          "previewed_at": {
            "format": "date-time",
            "type": "string"
          },
          "source": {
            "enum": [
              "preset",
              "custom"
            ],
            "type": "string"
          },
          "tier": {
            "enum": [
              "max",
              "balanced"
            ],
            "type": "string"
          }
        },
        "required": [
          "tier",
          "source",
          "previewed_at"
        ],
        "type": "object"
      },
      "PrivacyPersonaActive": {
        "additionalProperties": false,
        "properties": {
          "active": {
            "oneOf": [
              {
                "additionalProperties": false,
                "properties": {
                  "kid": {
                    "type": "string"
                  },
                  "not_after": {
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "threshold": {
                    "type": "integer"
                  },
                  "total_shares": {
                    "type": "integer"
                  },
                  "vault_provider": {
                    "type": "string"
                  },
                  "vault_url": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "version": {
                    "type": "integer"
                  }
                },
                "required": [
                  "kid",
                  "threshold",
                  "total_shares",
                  "vault_provider",
                  "version"
                ],
                "type": "object"
              },
              {
                "type": "null"
              }
            ]
          }
        },
        "required": [
          "active"
        ],
        "type": "object"
      },
      "PrivacyPersonaKey": {
        "additionalProperties": false,
        "properties": {
          "kid": {
            "type": "string"
          },
          "rotated": {
            "type": "boolean"
          },
          "share_1": {
            "type": "string"
          },
          "share_3": {
            "type": [
              "string",
              "null"
            ]
          },
          "threshold": {
            "enum": [
              2,
              3
            ],
            "type": "integer"
          },
          "vault_provider": {
            "type": "string"
          },
          "vault_url": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "kid",
          "share_1",
          "threshold",
          "vault_provider"
        ],
        "type": "object"
      },
      "PrivacyPersonaRotateAll": {
        "additionalProperties": false,
        "properties": {
          "rotated": {
            "type": "boolean"
          },
          "rows_cleared": {
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "rotated",
          "rows_cleared"
        ],
        "type": "object"
      },
      "PrivacyPersonaThreshold": {
        "additionalProperties": false,
        "properties": {
          "threshold": {
            "enum": [
              "3-of-3",
              "2-of-3"
            ],
            "type": "string"
          }
        },
        "required": [
          "threshold"
        ],
        "type": "object"
      },
      "PrivacyPersonaVaultEnrol": {
        "additionalProperties": false,
        "properties": {
          "enrolled": {
            "type": "boolean"
          },
          "provider": {
            "enum": [
              "proton-drive",
              "internxt",
              "tresorit",
              "self-host-nextcloud",
              "none"
            ],
            "type": "string"
          },
          "threshold": {
            "enum": [
              "3-of-3",
              "2-of-3"
            ],
            "type": "string"
          }
        },
        "required": [
          "provider",
          "threshold",
          "enrolled"
        ],
        "type": "object"
      },
      "PrivacyPersonaVaultProvider": {
        "additionalProperties": false,
        "properties": {
          "id": {
            "enum": [
              "proton-drive",
              "internxt",
              "tresorit",
              "self-host-nextcloud",
              "none"
            ],
            "type": "string"
          },
          "jurisdiction": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "jurisdiction",
          "notes"
        ],
        "type": "object"
      },
      "PrivacyPersonaVaultProviders": {
        "additionalProperties": false,
        "properties": {
          "providers": {
            "items": {
              "$ref": "#/components/schemas/PrivacyPersonaVaultProvider"
            },
            "type": "array"
          }
        },
        "required": [
          "providers"
        ],
        "type": "object"
      },
      "PrivacyPresetList": {
        "additionalProperties": false,
        "properties": {
          "quality_benchmark": {
            "$ref": "#/components/schemas/PrivacyQualityBenchmark"
          },
          "tiers": {
            "items": {
              "$ref": "#/components/schemas/PrivacyPresetTier"
            },
            "type": "array"
          }
        },
        "required": [
          "tiers",
          "quality_benchmark"
        ],
        "type": "object"
      },
      "PrivacyPresetTier": {
        "additionalProperties": false,
        "properties": {
          "default_for_desktop": {
            "type": "boolean"
          },
          "default_for_web": {
            "type": "boolean"
          },
          "id": {
            "enum": [
              "balanced",
              "max"
            ],
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "quality_pct": {
            "type": "number"
          },
          "requires_desktop": {
            "type": "boolean"
          },
          "tagline": {
            "type": "string"
          },
          "tradeoff": {
            "type": "string"
          }
        },
        "required": [
          "id",
          "name",
          "tagline",
          "tradeoff",
          "quality_pct",
          "requires_desktop",
          "default_for_web",
          "default_for_desktop"
        ],
        "type": "object"
      },
      "PrivacyPreviewChange": {
        "additionalProperties": false,
        "properties": {
          "disclosure_required": {
            "type": "boolean"
          },
          "from_tier": {
            "type": "string"
          },
          "requires_desktop": {
            "type": "boolean"
          },
          "shared_note": {
            "type": "string"
          },
          "to_tier": {
            "type": "string"
          },
          "what_changes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "what_stays": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "from_tier",
          "to_tier",
          "what_changes",
          "what_stays"
        ],
        "type": "object"
      },
      "PrivacyPrivacyState": {
        "additionalProperties": false,
        "properties": {
          "active_tier": {
            "enum": [
              "max",
              "balanced"
            ],
            "type": "string"
          },
          "active_tier_source": {
            "enum": [
              "preset",
              "custom"
            ],
            "type": "string"
          },
          "classifier_mode": {
            "enum": [
              "off",
              "standard",
              "power",
              "light"
            ],
            "type": "string"
          },
          "classifier_model_id": {
            "type": "string"
          },
          "committed": {
            "additionalProperties": false,
            "properties": {
              "source": {
                "enum": [
                  "preset",
                  "custom"
                ],
                "type": "string"
              },
              "tier": {
                "enum": [
                  "max",
                  "balanced"
                ],
                "type": "string"
              }
            },
            "required": [
              "tier",
              "source"
            ],
            "type": "object"
          },
          "hardware_backed": {
            "additionalProperties": false,
            "properties": {
              "authenticator_attachment": {
                "enum": [
                  "platform",
                  "cross-platform",
                  null
                ],
                "type": [
                  "string",
                  "null"
                ]
              },
              "available": {
                "type": "boolean"
              },
              "credential_id": {
                "maxLength": 1024,
                "type": [
                  "string",
                  "null"
                ]
              },
              "detected_platform": {
                "maxLength": 120,
                "type": [
                  "string",
                  "null"
                ]
              },
              "device_name": {
                "maxLength": 120,
                "type": [
                  "string",
                  "null"
                ]
              },
              "enabled": {
                "type": "boolean"
              },
              "enrolled_at": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "type": "object"
          },
          "preview": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/PrivacyPendingPreview"
              },
              {
                "type": "null"
              }
            ]
          },
          "recovery_vault": {
            "additionalProperties": false,
            "properties": {
              "enrolled": {
                "type": "boolean"
              },
              "enrolled_at": {
                "format": "date-time",
                "type": "string"
              },
              "provider": {
                "type": "string"
              },
              "threshold": {
                "enum": [
                  "3-of-3",
                  "2-of-3"
                ],
                "type": "string"
              }
            },
            "type": "object"
          },
          "rotation": {
            "additionalProperties": false,
            "properties": {
              "per_chat": {
                "type": "boolean"
              },
              "schedule": {
                "enum": [
                  "never",
                  "per_chat",
                  "daily",
                  "weekly",
                  "monthly",
                  "quarterly",
                  "manual"
                ],
                "type": "string"
              }
            },
            "type": "object"
          },
          "tier": {
            "type": "string"
          },
          "transparency_log": {
            "additionalProperties": false,
            "properties": {
              "enrolled": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "mutable": {
                "type": "boolean"
              },
              "mutable_reason": {
                "type": "string"
              },
              "publish_seed_hmac": {
                "type": [
                  "boolean",
                  "null"
                ]
              },
              "source": {
                "enum": [
                  "unknown",
                  "transparency_log_entries",
                  "unavailable"
                ],
                "type": "string"
              },
              "stored_preference": {
                "type": "boolean"
              }
            },
            "required": [
              "publish_seed_hmac",
              "enrolled",
              "stored_preference",
              "source",
              "mutable",
              "mutable_reason"
            ],
            "type": "object"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          }
        },
        "required": [
          "active_tier",
          "active_tier_source",
          "classifier_mode",
          "classifier_model_id",
          "hardware_backed",
          "rotation",
          "transparency_log",
          "recovery_vault",
          "committed",
          "preview"
        ],
        "type": "object"
      },
      "PrivacyQualityBenchmark": {
        "additionalProperties": false,
        "properties": {
          "benchmark": {
            "type": "string"
          },
          "categories": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "generated_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "judge_model": {
            "type": [
              "string",
              "null"
            ]
          },
          "limitations": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "methodology": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "n": {
            "minimum": 0,
            "type": "integer"
          },
          "prompt_count": {
            "minimum": 0,
            "type": "integer"
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "benchmark",
          "n",
          "prompt_count",
          "categories",
          "generated_at",
          "provider",
          "model",
          "judge_model",
          "methodology",
          "limitations"
        ],
        "type": "object"
      },
      "PrivacyScopes": {
        "additionalProperties": false,
        "properties": {
          "default": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "note": {
            "type": "string"
          },
          "scopes": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "description": {
                  "type": "string"
                },
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "name",
                "description"
              ],
              "type": "object"
            },
            "type": "array"
          }
        },
        "required": [
          "scopes",
          "default",
          "note"
        ],
        "type": "object"
      },
      "PrivacySelfServiceKey": {
        "additionalProperties": false,
        "properties": {
          "account": {
            "additionalProperties": false,
            "properties": {
              "anonymous": {
                "type": "boolean"
              },
              "claim": {
                "type": "string"
              },
              "email": {
                "format": "email",
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "anonymous",
              "email",
              "claim"
            ],
            "type": "object"
          },
          "api_key": {
            "type": "string"
          },
          "docs": {
            "format": "uri",
            "type": "string"
          },
          "key_prefix": {
            "type": "string"
          },
          "limits": {
            "additionalProperties": false,
            "properties": {
              "on_device": {
                "type": "string"
              },
              "rate_limit_rpm": {
                "minimum": 0,
                "type": "integer"
              },
              "relay": {
                "type": "string"
              }
            },
            "required": [
              "rate_limit_rpm",
              "on_device",
              "relay"
            ],
            "type": "object"
          },
          "tier": {
            "enum": [
              "free"
            ],
            "type": "string"
          },
          "usage": {
            "additionalProperties": false,
            "properties": {
              "api": {
                "type": "string"
              },
              "mcp": {
                "type": "string"
              },
              "sdk": {
                "type": "string"
              }
            },
            "required": [
              "sdk",
              "mcp",
              "api"
            ],
            "type": "object"
          },
          "warning": {
            "type": "string"
          }
        },
        "required": [
          "api_key",
          "key_prefix",
          "tier",
          "limits",
          "account",
          "usage",
          "docs",
          "warning"
        ],
        "type": "object"
      },
      "PrivacyShare": {
        "additionalProperties": false,
        "properties": {
          "share_2": {
            "contentEncoding": "base64",
            "type": "string"
          }
        },
        "required": [
          "share_2"
        ],
        "type": "object"
      },
      "PrivacySocialAuthorize": {
        "additionalProperties": false,
        "properties": {
          "authorize_url": {
            "format": "uri",
            "type": "string"
          }
        },
        "required": [
          "authorize_url"
        ],
        "type": "object"
      },
      "PrivacySocialExchange": {
        "additionalProperties": false,
        "properties": {
          "created": {
            "type": "boolean"
          },
          "token": {
            "type": "string"
          },
          "user": {
            "additionalProperties": false,
            "properties": {
              "balance_cents": {
                "type": "integer"
              },
              "balance_dollars": {
                "type": "number"
              },
              "company_name": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "created_at": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "email": {
                "format": "email",
                "type": "string"
              },
              "email_verified": {
                "type": "boolean"
              },
              "id": {
                "type": "integer"
              },
              "is_low_balance": {
                "type": "boolean"
              },
              "legal_accepted": {
                "type": "boolean"
              },
              "name": {
                "type": "string"
              },
              "onboarding_done": {
                "type": "boolean"
              },
              "organisation_id": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "role": {
                "enum": [
                  "owner",
                  "super-admin",
                  "admin",
                  "staff",
                  "compliance-officer",
                  "auditor",
                  "billing",
                  "support",
                  "developer",
                  "member"
                ],
                "type": "string"
              },
              "roles": {
                "items": {
                  "enum": [
                    "owner",
                    "super-admin",
                    "admin",
                    "staff",
                    "compliance-officer",
                    "auditor",
                    "billing",
                    "support",
                    "developer",
                    "member"
                  ],
                  "type": "string"
                },
                "type": "array"
              },
              "balance_micros": {
                "description": "Exact wallet balance in USD micro-dollars.",
                "type": "integer"
              }
            },
            "required": [
              "id",
              "name",
              "email",
              "email_verified",
              "company_name",
              "organisation_id",
              "balance_cents",
              "balance_dollars",
              "is_low_balance",
              "role",
              "roles",
              "created_at",
              "legal_accepted",
              "onboarding_done",
              "balance_micros"
            ],
            "type": "object"
          }
        },
        "required": [
          "token",
          "created",
          "user"
        ],
        "type": "object"
      },
      "PrivacySocialFailure": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "PrivacyTier": {
        "additionalProperties": false,
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "rules": {
            "additionalProperties": {
              "enum": [
                "max",
                "balanced"
              ],
              "type": "string"
            },
            "example": {
              "email": "balanced",
              "phone": "max"
            },
            "minProperties": 1,
            "propertyNames": {
              "pattern": "^[a-z0-9._\\-]{1,64}$",
              "type": "string"
            },
            "type": "object"
          },
          "updated_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "user_id": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "user_id",
          "name",
          "rules"
        ],
        "type": "object"
      },
      "PrivacyTierEnvelope": {
        "additionalProperties": false,
        "properties": {
          "tier": {
            "$ref": "#/components/schemas/PrivacyTier"
          }
        },
        "required": [
          "tier"
        ],
        "type": "object"
      },
      "PrivacyTierList": {
        "additionalProperties": false,
        "properties": {
          "base_tiers": {
            "items": {
              "$ref": "#/components/schemas/PrivacyBaseTier"
            },
            "type": "array"
          },
          "custom_tier_count": {
            "type": "integer"
          },
          "custom_tier_limit": {
            "type": "integer"
          },
          "custom_tiers": {
            "items": {
              "$ref": "#/components/schemas/PrivacyTier"
            },
            "type": "array"
          },
          "quality_benchmark": {
            "$ref": "#/components/schemas/PrivacyQualityBenchmark"
          }
        },
        "required": [
          "base_tiers",
          "custom_tiers",
          "custom_tier_count",
          "custom_tier_limit",
          "quality_benchmark"
        ],
        "type": "object"
      },
      "ReceiptChain": {
        "properties": {
          "chain_id": {
            "description": "ULID unique to the session/device",
            "type": "string"
          },
          "prev_hash": {
            "description": "SHA-256 hex of previous canonical receipt bytes; null for first in chain",
            "type": [
              "string",
              "null"
            ]
          },
          "seq": {
            "description": "Monotonically increasing sequence number starting at 0",
            "type": "integer"
          }
        },
        "required": [
          "prev_hash",
          "chain_id",
          "seq"
        ],
        "type": "object"
      },
      "ReceiptClaims": {
        "properties": {
          "egress_attestation": {
            "properties": {
              "attester": {
                "enum": [
                  "desktop",
                  "browser-extension",
                  "browser-portal",
                  "cli",
                  "sdk-embedded"
                ],
                "type": "string"
              },
              "attester_build_hash": {
                "type": "string"
              },
              "zero_payload_proof": {
                "type": "object"
              }
            },
            "type": "object"
          },
          "routing_decision": {
            "properties": {
              "model": {
                "type": "string"
              },
              "provider_id": {
                "type": "string"
              },
              "provider_region": {
                "type": "string"
              },
              "reason": {
                "enum": [
                  "user-selected",
                  "policy-cheapest",
                  "policy-fastest",
                  "policy-compliance-pack",
                  "fallback-after-failure"
                ],
                "type": "string"
              }
            },
            "type": "object"
          },
          "tokenisation": {
            "properties": {
              "detectors": {
                "items": {
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "fingerprint_hmac": {
                      "type": "string"
                    },
                    "id": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                },
                "type": "array"
              },
              "input_hash": {
                "description": "SHA-256 hex of pre-tokenisation input",
                "type": "string"
              },
              "level": {
                "description": "Client-side tokenisation tier applied by the local engine before any bytes leave the device. CloakAPI is client-side only (Level 1): there is no server-side off / detect-only / mask / tokenise mode.",
                "enum": [
                  "tokenise-reversible",
                  "tokenise-irreversible"
                ],
                "type": "string"
              },
              "output_hash": {
                "description": "SHA-256 hex of post-tokenisation output",
                "type": "string"
              },
              "tokeniser_binary_hash": {
                "description": "SHA-256 hex of tokeniser binary",
                "type": "string"
              }
            },
            "type": "object"
          },
          "x-cloakapi-detection": {
            "description": "Present only on the receipt of a declared rules-only send, where the request carried `X-CloakAPI-Tokenized` set to `true;coverage=rules_only` and no engine identity headers. It records what the client declared; the gateway did not measure it and did not read the body. On such a receipt `genuine_engine` is false and no `engine_version` or `engine_binary_hash` is recorded.",
            "properties": {
              "basis": {
                "enum": ["client_declared"],
                "type": "string"
              },
              "coverage": {
                "enum": ["rules_only"],
                "type": "string"
              },
              "engine_identity": {
                "enum": ["not_declared"],
                "type": "string"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "ReceiptJwk": {
        "properties": {
          "alg": {
            "enum": [
              "ES256",
              "EdDSA"
            ],
            "type": "string"
          },
          "crv": {
            "const": "P-256",
            "type": "string"
          },
          "key_ops": {
            "items": {
              "const": "verify",
              "type": "string"
            },
            "type": "array"
          },
          "kid": {
            "type": "string"
          },
          "kty": {
            "enum": [
              "EC",
              "OKP"
            ],
            "type": "string"
          },
          "use": {
            "const": "sig",
            "type": "string"
          },
          "x": {
            "type": "string"
          },
          "x-cloakapi-active": {
            "type": "boolean"
          },
          "x-cloakapi-pem": {
            "contentEncoding": "base64",
            "type": "string"
          },
          "x-cloakapi-slot": {
            "enum": [
              "active",
              "pending",
              "retired",
              "unknown"
            ],
            "type": "string"
          },
          "y": {
            "type": "string"
          }
        },
        "required": [
          "kty",
          "kid",
          "use",
          "alg",
          "key_ops",
          "x-cloakapi-active"
        ],
        "type": "object"
      },
      "ReceiptJwksResponse": {
        "properties": {
          "keys": {
            "items": {
              "$ref": "#/components/schemas/ReceiptJwk"
            },
            "type": "array"
          }
        },
        "required": [
          "keys"
        ],
        "type": "object"
      },
      "ReceiptsApiError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "example": "not_found",
                "type": "string"
              },
              "message": {
                "example": "The requested receipt was not found.",
                "type": "string"
              }
            },
            "required": [
              "code",
              "message"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ReceiptsAuditChainExport": {
        "additionalProperties": false,
        "properties": {
          "anchors": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "canonical_preimages": {
            "type": "object"
          },
          "entries": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "manifest": {
            "properties": {
              "anchor_count": {
                "type": "integer"
              },
              "entry_count": {
                "type": "integer"
              },
              "exported_at": {
                "format": "date-time",
                "type": "string"
              },
              "first_id": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "from": {
                "format": "date",
                "type": "string"
              },
              "jwks_uri": {
                "format": "uri",
                "type": "string"
              },
              "last_id": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "org_id": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "row_cap": {
                "maximum": 50000,
                "type": "integer"
              },
              "rows_available": {
                "type": "integer"
              },
              "signature_alg": {
                "type": "string"
              },
              "to": {
                "format": "date",
                "type": "string"
              },
              "truncated": {
                "type": "boolean"
              },
              "type": {
                "const": "audit_log_chain_export_v1",
                "type": "string"
              }
            },
            "required": [
              "type",
              "org_id",
              "from",
              "to",
              "entry_count",
              "rows_available",
              "row_cap",
              "truncated",
              "first_id",
              "last_id",
              "anchor_count",
              "exported_at",
              "jwks_uri",
              "signature_alg"
            ],
            "type": "object"
          },
          "manifest_sha256": {
            "type": "string"
          },
          "manifest_signature": {
            "type": "string"
          }
        },
        "required": [
          "manifest",
          "manifest_sha256",
          "manifest_signature",
          "anchors",
          "entries",
          "canonical_preimages"
        ],
        "type": "object"
      },
      "ReceiptsByJti": {
        "$ref": "#/components/schemas/OpenReceiptEnvelope"
      },
      "ReceiptsChainBreakError": {
        "additionalProperties": false,
        "properties": {
          "errors": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message",
          "errors"
        ],
        "type": "object"
      },
      "ReceiptsChainManifest": {
        "additionalProperties": false,
        "properties": {
          "chain_id": {
            "type": "string"
          },
          "entries": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "canonical_sha256": {
                  "type": "string"
                },
                "created_at": {
                  "format": "date-time",
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "jti": {
                  "type": "string"
                },
                "kid": {
                  "type": "string"
                },
                "prev_hash": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "seq": {
                  "type": "integer"
                }
              },
              "required": [
                "seq",
                "jti",
                "prev_hash",
                "canonical_sha256",
                "kid",
                "created_at"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "manifest_sha256": {
            "type": "string"
          },
          "manifest_signature": {
            "$ref": "#/components/schemas/OpenReceiptEnvelope"
          }
        },
        "required": [
          "chain_id",
          "entries",
          "manifest_sha256",
          "manifest_signature"
        ],
        "type": "object"
      },
      "ReceiptsCountersignError": {
        "additionalProperties": false,
        "properties": {
          "details": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "ref": {
            "type": "string"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ReceiptsCountersignResponse": {
        "additionalProperties": false,
        "properties": {
          "receipt": {
            "$ref": "#/components/schemas/OpenReceiptEnvelope"
          }
        },
        "required": [
          "receipt"
        ],
        "type": "object"
      },
      "ReceiptsEngineHashes": {
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "type": "string"
          },
          "canonical_binary_hashes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "engine_binary_hashes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "engines": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "note": {
            "type": "string"
          },
          "published": {
            "type": "boolean"
          },
          "ruleset_version": {
            "type": "string"
          },
          "updated_at": {
            "type": [
              "string",
              "null"
            ]
          },
          "withdrawn_binary_hashes": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "algorithm",
          "engine_binary_hashes",
          "withdrawn_binary_hashes",
          "canonical_binary_hashes",
          "engines",
          "ruleset_version",
          "published",
          "updated_at",
          "note"
        ],
        "type": "object"
      },
      "ReceiptsErasureReceipt": {
        "additionalProperties": false,
        "properties": {
          "chain_id": {
            "type": "string"
          },
          "chain_seq": {
            "type": "integer"
          },
          "completed_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "downstream_open": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "dsar_request_id": {
            "example": "dsar_01j4x8m2a6b7c9d0e1f2g3h4j5",
            "type": "string"
          },
          "erasure_scope": {
            "type": [
              "object",
              "array",
              "string",
              "null"
            ]
          },
          "incomplete_reasons": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "jti": {
            "type": "string"
          },
          "retain_until": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "signed_envelope": {
            "$ref": "#/components/schemas/OpenReceiptEnvelope"
          }
        },
        "required": [
          "dsar_request_id",
          "jti",
          "chain_id",
          "chain_seq",
          "completed_at",
          "retain_until",
          "erasure_scope",
          "downstream_open",
          "incomplete_reasons",
          "signed_envelope"
        ],
        "type": "object"
      },
      "ReceiptsErasureVerify": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "dsar_request_id": {
            "type": "string"
          },
          "jti": {
            "type": "string"
          },
          "completed_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "retain_until": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "erasure_scope": {
            "type": [
              "string",
              "null"
            ]
          },
          "downstream_open": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "incomplete_reasons": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "checks": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "valid",
          "reason",
          "dsar_request_id",
          "jti",
          "completed_at",
          "retain_until",
          "erasure_scope",
          "downstream_open",
          "incomplete_reasons",
          "checks"
        ],
        "additionalProperties": false
      },
      "ReceiptsMac": {
        "additionalProperties": false,
        "properties": {
          "mac": {
            "example": "9f2c4b8d6e1a3f50718293a4b5c6d7e8f90123456789abcdef0123456789abcd",
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          }
        },
        "required": [
          "mac"
        ],
        "type": "object"
      },
      "ReceiptsMacAuthError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "ReceiptsMerkleConsistency": {
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "example": "sha256-rfc6962-v1",
            "type": "string"
          },
          "consistency_proof": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "first": {
            "minimum": 0,
            "type": "integer"
          },
          "first_root_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "second": {
            "minimum": 0,
            "type": "integer"
          },
          "second_root_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "signed_tree_heads": {
            "additionalProperties": false,
            "properties": {
              "first": {
                "type": [
                  "object",
                  "null"
                ]
              },
              "second": {
                "type": [
                  "object",
                  "null"
                ]
              }
            },
            "required": [
              "first",
              "second"
            ],
            "type": "object"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "required": [
          "verified",
          "first",
          "second",
          "first_root_hash",
          "second_root_hash",
          "consistency_proof",
          "algorithm",
          "signed_tree_heads"
        ],
        "type": "object"
      },
      "ReceiptsMerkleInclusion": {
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "example": "sha256-rfc6962-v1",
            "type": "string"
          },
          "audit_path": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "canonical_leaf_record": {
            "type": "string"
          },
          "included": {
            "type": "boolean"
          },
          "leaf_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "leaf_index": {
            "minimum": 0,
            "type": "integer"
          },
          "leaf_record": {
            "type": "object"
          },
          "note": {
            "type": "string"
          },
          "root_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "signed_tree_head": {
            "type": [
              "object",
              "null"
            ]
          },
          "tree_size": {
            "minimum": 0,
            "type": "integer"
          },
          "verified": {
            "type": "boolean"
          }
        },
        "required": [
          "included",
          "tree_size",
          "algorithm"
        ],
        "type": "object"
      },
      "ReceiptsMerkleLeaves": {
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "example": "sha256-rfc6962-v1",
            "type": "string"
          },
          "data": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "canonical_leaf_record": {
                  "type": "string"
                },
                "leaf_hash": {
                  "pattern": "^[a-f0-9]{64}$",
                  "type": "string"
                },
                "leaf_index": {
                  "minimum": 0,
                  "type": "integer"
                },
                "leaf_record": {
                  "type": "object"
                }
              },
              "required": [
                "leaf_index",
                "leaf_hash",
                "leaf_record",
                "canonical_leaf_record"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "limit": {
            "minimum": 1,
            "type": "integer"
          },
          "start": {
            "minimum": 0,
            "type": "integer"
          },
          "tree_size": {
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "data",
          "start",
          "limit",
          "tree_size",
          "algorithm"
        ],
        "type": "object"
      },
      "ReceiptsMerkleSpec": {
        "additionalProperties": false,
        "properties": {
          "algorithm": {
            "example": "sha256-rfc6962-v1",
            "type": "string"
          },
          "canonical_json": {
            "type": "string"
          },
          "content_policy": {
            "type": "string"
          },
          "empty_root": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "leaf_hash": {
            "type": "string"
          },
          "leaf_record_fields": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "leaf_version": {
            "type": "integer"
          },
          "node_hash": {
            "type": "string"
          },
          "payload_hash": {
            "type": "string"
          },
          "specification": {
            "type": "string"
          },
          "sth_signature": {
            "additionalProperties": false,
            "properties": {
              "algorithm": {
                "type": "string"
              },
              "body": {
                "type": "string"
              }
            },
            "required": [
              "algorithm",
              "body"
            ],
            "type": "object"
          },
          "tenant_id_hash": {
            "type": "string"
          }
        },
        "required": [
          "algorithm",
          "specification",
          "leaf_version",
          "canonical_json",
          "leaf_hash",
          "node_hash",
          "empty_root",
          "payload_hash",
          "leaf_record_fields",
          "tenant_id_hash",
          "sth_signature",
          "content_policy"
        ],
        "type": "object"
      },
      "ReceiptsMerkleTreeHead": {
        "additionalProperties": false,
        "properties": {
          "leaf_count": {
            "minimum": 0,
            "type": "integer"
          },
          "published_at": {
            "format": "date-time",
            "type": "string"
          },
          "root_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          },
          "signature": {
            "type": "string"
          },
          "signed_body": {
            "type": "string"
          },
          "tree_size": {
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "tree_size",
          "root_hash",
          "published_at",
          "signed_body"
        ],
        "type": "object"
      },
      "ReceiptsMerkleTreeHeads": {
        "additionalProperties": false,
        "properties": {
          "data": {
            "items": {
              "additionalProperties": false,
              "properties": {
                "published_at": {
                  "format": "date-time",
                  "type": "string"
                },
                "root_hash": {
                  "pattern": "^[a-f0-9]{64}$",
                  "type": "string"
                },
                "tree_size": {
                  "minimum": 0,
                  "type": "integer"
                }
              },
              "required": [
                "tree_size",
                "root_hash",
                "published_at"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "tree_size": {
            "minimum": 0,
            "type": "integer"
          }
        },
        "required": [
          "data",
          "tree_size"
        ],
        "type": "object"
      },
      "ReceiptsMetricsValidationError": {
        "additionalProperties": false,
        "properties": {
          "errors": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message",
          "errors"
        ],
        "type": "object"
      },
      "ReceiptsPublicInclusionPath": {
        "additionalProperties": false,
        "properties": {
          "parent_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": [
              "string",
              "null"
            ]
          },
          "seed_hash": {
            "pattern": "^[a-f0-9]{64}$",
            "type": "string"
          }
        },
        "required": [
          "seed_hash",
          "parent_hash"
        ],
        "type": "object"
      },
      "ReceiptsPublicSeeds": {
        "additionalProperties": false,
        "properties": {
          "before": {
            "type": [
              "integer",
              "null"
            ]
          },
          "data": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "has_more": {
            "type": "boolean"
          },
          "key_id": {
            "type": "string"
          },
          "limit": {
            "minimum": 1,
            "type": "integer"
          },
          "next_before": {
            "type": [
              "integer",
              "null"
            ]
          }
        },
        "required": [
          "data",
          "limit",
          "has_more"
        ],
        "type": "object"
      },
      "ReceiptsReceiptDetail": {
        "additionalProperties": false,
        "properties": {
          "api_key_id": {
            "type": [
              "integer",
              "null"
            ]
          },
          "canonical_sha256": {
            "type": [
              "string",
              "null"
            ]
          },
          "capability": {
            "type": [
              "string",
              "null"
            ]
          },
          "chain_id": {
            "type": [
              "string",
              "null"
            ]
          },
          "chain_seq": {
            "type": [
              "integer",
              "null"
            ]
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "detector_hits": {
            "type": [
              "integer",
              "null"
            ]
          },
          "envelope": {
            "type": [
              "object",
              "null"
            ]
          },
          "jti": {
            "type": "string"
          },
          "kid": {
            "type": [
              "string",
              "null"
            ]
          },
          "latency_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "mode": {
            "type": [
              "string",
              "null"
            ]
          },
          "model": {
            "type": [
              "string",
              "null"
            ]
          },
          "prev_hash": {
            "type": [
              "string",
              "null"
            ]
          },
          "provider": {
            "type": [
              "string",
              "null"
            ]
          },
          "surface": {
            "enum": [
              "chat",
              "api",
              "extension",
              "desktop-local"
            ],
            "type": "string"
          },
          "tier": {
            "type": [
              "string",
              "null"
            ]
          },
          "tokens_in": {
            "type": [
              "integer",
              "null"
            ]
          },
          "tokens_out": {
            "type": [
              "integer",
              "null"
            ]
          },
          "user_id": {
            "type": "integer"
          },
          "verifiable": {
            "type": "boolean"
          }
        },
        "required": [
          "jti",
          "surface",
          "user_id",
          "provider",
          "model",
          "tier",
          "tokens_in",
          "tokens_out",
          "verifiable",
          "created_at",
          "envelope"
        ],
        "type": "object"
      },
      "ReceiptsSignedSubmitValidationError": {
        "additionalProperties": false,
        "properties": {
          "errors": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "object"
          },
          "message": {
            "type": "string"
          }
        },
        "required": [
          "message",
          "errors"
        ],
        "type": "object"
      },
      "ReceiptsTransparencyToggleFailure": {
        "additionalProperties": false,
        "properties": {
          "enabled": {
            "type": "boolean"
          },
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "code",
              "message"
            ],
            "type": "object"
          },
          "public_feed_updated": {
            "const": false,
            "type": "boolean"
          }
        },
        "required": [
          "enabled",
          "public_feed_updated",
          "error"
        ],
        "type": "object"
      },
      "ReceiptsValidationError": {
        "additionalProperties": false,
        "properties": {
          "errors": {
            "additionalProperties": {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            "type": "object"
          },
          "message": {
            "example": "The given data was invalid.",
            "type": "string"
          }
        },
        "required": [
          "message",
          "errors"
        ],
        "type": "object"
      },
      "ReceiptsVerifyRequest": {
        "properties": {
          "receipt": {
            "$ref": "#/components/schemas/OpenReceiptEnvelope"
          }
        },
        "required": [
          "receipt"
        ],
        "type": "object"
      },
      "ReceiptsVerifyResponse": {
        "properties": {
          "chain_ok": {
            "type": "boolean"
          },
          "error": {
            "type": [
              "string",
              "null"
            ]
          },
          "kid": {
            "type": "string"
          },
          "seq": {
            "type": "integer"
          },
          "valid": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "RecordLegalOnboardingAcceptance": {
        "properties": {
          "privacy_policy_accepted_at": {
            "description": "A value accepted by date validation.",
            "type": "string"
          },
          "privacy_version": {
            "maxLength": 20,
            "type": "string"
          },
          "terms_accepted_at": {
            "description": "A value accepted by date validation.",
            "type": "string"
          },
          "terms_version": {
            "maxLength": 20,
            "type": "string"
          }
        },
        "required": [
          "terms_accepted_at",
          "privacy_policy_accepted_at",
          "terms_version",
          "privacy_version"
        ],
        "type": "object"
      },
      "ReviewedToolJsonSchema": {
        "additionalProperties": false,
        "description": "Reviewed tool JSON Schema. description, title and string examples are tokenised by the SDK. enum, const, default, pattern and unknown keys are refused by the gateway. required entries are limited to 64 strings of at most 64 characters, each naming a sibling properties key.",
        "properties": {
          "$defs": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "object"
          },
          "$ref": {
            "type": "string"
          },
          "additionalProperties": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReviewedToolJsonSchema"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "allOf": {
            "items": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "array"
          },
          "anyOf": {
            "items": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "array"
          },
          "definitions": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "object"
          },
          "description": {
            "type": "string"
          },
          "examples": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "exclusiveMaximum": {
            "type": "number"
          },
          "exclusiveMinimum": {
            "type": "number"
          },
          "format": {
            "enum": [
              "date-time",
              "date",
              "time",
              "email",
              "hostname",
              "ipv4",
              "ipv6",
              "uri",
              "uuid",
              "regex",
              "byte",
              "binary",
              "int32",
              "int64",
              "float",
              "double",
              "password"
            ],
            "type": "string"
          },
          "items": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ReviewedToolJsonSchema"
              },
              {
                "type": "boolean"
              }
            ]
          },
          "maxItems": {
            "type": "integer"
          },
          "maxLength": {
            "type": "integer"
          },
          "maxProperties": {
            "type": "integer"
          },
          "maximum": {
            "type": "number"
          },
          "minItems": {
            "type": "integer"
          },
          "minLength": {
            "type": "integer"
          },
          "minProperties": {
            "type": "integer"
          },
          "minimum": {
            "type": "number"
          },
          "multipleOf": {
            "type": "number"
          },
          "not": {
            "$ref": "#/components/schemas/ReviewedToolJsonSchema"
          },
          "nullable": {
            "type": "boolean"
          },
          "oneOf": {
            "items": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "array"
          },
          "properties": {
            "additionalProperties": {
              "$ref": "#/components/schemas/ReviewedToolJsonSchema"
            },
            "type": "object"
          },
          "required": {
            "description": "Each entry must match a sibling properties key.",
            "items": {
              "maxLength": 64,
              "type": "string"
            },
            "maxItems": 64,
            "type": "array"
          },
          "title": {
            "type": "string"
          },
          "type": {
            "enum": [
              "object",
              "array",
              "string",
              "number",
              "integer",
              "boolean"
            ],
            "type": "string"
          },
          "uniqueItems": {
            "type": "boolean"
          }
        },
        "type": "object"
      },
      "ScimGroupResource": {
        "description": "SCIM Group response fields emitted by ScimController::groupToScim.",
        "properties": {
          "displayName": {
            "type": "string"
          },
          "externalId": {
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "string"
          },
          "mappedRole": {
            "type": [
              "string",
              "null"
            ]
          },
          "meta": {
            "properties": {
              "created": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "lastModified": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "location": {
                "format": "uri",
                "type": "string"
              },
              "resourceType": {
                "const": "Group",
                "type": "string"
              }
            },
            "required": [
              "resourceType",
              "created",
              "lastModified",
              "location"
            ],
            "type": "object"
          },
          "schemas": {
            "items": {
              "type": "string"
            },
            "type": "array"
          }
        },
        "required": [
          "schemas",
          "id",
          "displayName",
          "externalId",
          "mappedRole",
          "meta"
        ],
        "type": "object"
      },
      "ScimUserResource": {
        "description": "SCIM User response fields emitted by ScimController::userToScim.",
        "properties": {
          "active": {
            "type": "boolean"
          },
          "emails": {
            "items": {
              "properties": {
                "primary": {
                  "const": true,
                  "type": "boolean"
                },
                "value": {
                  "format": "email",
                  "type": "string"
                }
              },
              "required": [
                "value",
                "primary"
              ],
              "type": "object"
            },
            "type": "array"
          },
          "id": {
            "type": "string"
          },
          "meta": {
            "properties": {
              "created": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "lastModified": {
                "format": "date-time",
                "type": [
                  "string",
                  "null"
                ]
              },
              "location": {
                "format": "uri",
                "type": "string"
              },
              "resourceType": {
                "const": "User",
                "type": "string"
              }
            },
            "required": [
              "resourceType",
              "created",
              "lastModified",
              "location"
            ],
            "type": "object"
          },
          "name": {
            "properties": {
              "formatted": {
                "type": "string"
              }
            },
            "required": [
              "formatted"
            ],
            "type": "object"
          },
          "schemas": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "userName": {
            "format": "email",
            "type": "string"
          }
        },
        "required": [
          "schemas",
          "id",
          "userName",
          "name",
          "active",
          "emails",
          "meta"
        ],
        "type": "object"
      },
      "SloMetricsResponse": {
        "properties": {
          "api_uptime_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "cached_at": {
            "format": "date-time",
            "type": "string"
          },
          "error_rate": {
            "type": "null"
          },
          "latency_ms": {
            "properties": {
              "p50": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "p90": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "p95": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "p99": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            },
            "required": [
              "p50",
              "p90",
              "p95",
              "p99"
            ],
            "type": "object"
          },
          "latency_scope": {
            "const": "end-to-end, includes upstream model time",
            "type": "string"
          },
          "latency_source": {
            "const": "gateway-request-log",
            "type": "string"
          },
          "note": {
            "type": "string"
          },
          "p95_latency_ms": {
            "type": [
              "integer",
              "null"
            ]
          },
          "records_in_window": {
            "type": "integer"
          },
          "region": {
            "type": "string"
          },
          "sample_size": {
            "type": "integer"
          },
          "status": {
            "const": "ok",
            "type": "string"
          },
          "uptime_30d_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "uptime_sample_size": {
            "type": [
              "integer",
              "null"
            ]
          },
          "uptime_source": {
            "enum": [
              "synthetic-http-probe",
              null
            ],
            "type": [
              "string",
              "null"
            ]
          },
          "window": {
            "const": "30d",
            "type": "string"
          },
          "window_iso": {
            "type": "string"
          }
        },
        "required": [
          "status",
          "window",
          "api_uptime_pct",
          "p95_latency_ms",
          "error_rate",
          "sample_size",
          "note",
          "uptime_source",
          "uptime_sample_size",
          "latency_source",
          "latency_scope",
          "records_in_window",
          "uptime_30d_pct",
          "latency_ms",
          "region",
          "window_iso",
          "cached_at"
        ],
        "type": "object"
      },
      "TokensCountRequest": {
        "properties": {
          "messages": {
            "items": {
              "type": "object"
            },
            "type": "array"
          },
          "model": {
            "type": "string"
          }
        },
        "required": [
          "model",
          "messages"
        ],
        "type": "object"
      },
      "TokensCountResponse": {
        "properties": {
          "input_tokens": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "UserResource": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "email": {
            "format": "email",
            "type": "string"
          },
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "balance_micros": {
            "description": "Exact wallet balance in USD micro-dollars.",
            "type": "integer"
          }
        },
        "type": "object"
      },
      "WebhookDeliveryC6b": {
        "properties": {
          "attempt_count": {
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "delivered_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "endpoint_id": {
            "type": "integer"
          },
          "event": {
            "example": "receipt.signed",
            "type": "string"
          },
          "event_id": {
            "description": "Idempotency key — consumers must dedupe on this for ≥24h",
            "type": "string"
          },
          "first_attempt_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ]
          },
          "last_response_body": {
            "maxLength": 4096,
            "type": [
              "string",
              "null"
            ]
          },
          "last_status_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "next_attempt_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "payload": {
            "additionalProperties": true,
            "type": "object"
          },
          "response_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "signature": {
            "description": "HMAC-SHA256(secret, json_encode(payload)) in hex",
            "type": "string"
          },
          "status": {
            "enum": [
              "pending",
              "in_flight",
              "delivered",
              "failed",
              "dead"
            ],
            "type": "string"
          },
          "updated_at": {
            "format": "date-time",
            "type": "string"
          },
          "webhook_endpoint_id": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "webhook_endpoint_id",
          "endpoint_id",
          "event",
          "event_id",
          "status",
          "attempt_count",
          "last_status_code",
          "response_status",
          "next_attempt_at",
          "delivered_at",
          "first_attempt_at",
          "created_at",
          "updated_at",
          "last_response_body",
          "last_error",
          "payload",
          "signature"
        ],
        "type": "object"
      },
      "WebhookDeliveryListItem": {
        "properties": {
          "attempt_count": {
            "type": "integer"
          },
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "delivered_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "endpoint_id": {
            "type": "integer"
          },
          "event": {
            "example": "receipt.signed",
            "type": "string"
          },
          "event_id": {
            "description": "Idempotency key — consumers must dedupe on this for ≥24h",
            "type": "string"
          },
          "first_attempt_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "id": {
            "type": "integer"
          },
          "last_status_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "next_attempt_at": {
            "format": "date-time",
            "type": [
              "string",
              "null"
            ]
          },
          "response_status": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "enum": [
              "pending",
              "in_flight",
              "delivered",
              "failed",
              "dead"
            ],
            "type": "string"
          },
          "webhook_endpoint_id": {
            "type": "integer"
          }
        },
        "required": [
          "id",
          "webhook_endpoint_id",
          "endpoint_id",
          "event",
          "event_id",
          "status",
          "attempt_count",
          "last_status_code",
          "response_status",
          "next_attempt_at",
          "delivered_at",
          "first_attempt_at",
          "created_at"
        ],
        "type": "object"
      },
      "WebhookEndpoint": {
        "properties": {
          "created_at": {
            "format": "date-time",
            "type": "string"
          },
          "events": {
            "example": [
              "receipt.signed",
              "compliance.pack.*"
            ],
            "items": {
              "maxLength": 64,
              "type": "string"
            },
            "type": [
              "array",
              "null"
            ]
          },
          "id": {
            "example": 42,
            "type": "integer"
          },
          "is_active": {
            "type": "boolean"
          },
          "url": {
            "format": "uri",
            "maxLength": 512,
            "type": "string"
          }
        },
        "required": [
          "id",
          "url",
          "events",
          "is_active",
          "created_at"
        ],
        "type": "object"
      },
      "GenericError": {
        "type": "object",
        "properties": {
          "error": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          },
          "error_code": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "detail": {
            "type": "string"
          },
          "status": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              }
            ]
          },
          "errors": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "ArbitrageRuleValidationError": {
        "additionalProperties": false,
        "description": "Field-level validation errors for a routing-rule request.",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorWithCode"
          },
          "message": {
            "type": "string"
          },
          "errors": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "errors"
        ],
        "type": "object"
      },
      "CacheUsageGroup": {
        "type": "object",
        "properties": {
          "tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "rate_cents_per_million": {
            "type": [
              "number",
              "null"
            ]
          },
          "provider_cost_micros": {
            "type": [
              "integer",
              "null"
            ]
          },
          "unpriced_tokens": {
            "type": "integer"
          }
        },
        "required": [
          "tokens",
          "provider_cost_micros",
          "unpriced_tokens"
        ],
        "additionalProperties": false
      },
      "CacheUsageBreakdown": {
        "type": "object",
        "properties": {
          "read": {
            "$ref": "#/components/schemas/CacheUsageGroup"
          },
          "write_5m": {
            "$ref": "#/components/schemas/CacheUsageGroup"
          },
          "write_1h": {
            "$ref": "#/components/schemas/CacheUsageGroup"
          },
          "write_30m": {
            "$ref": "#/components/schemas/CacheUsageGroup"
          },
          "write_12h": {
            "$ref": "#/components/schemas/CacheUsageGroup"
          },
          "write_total_tokens": {
            "type": "integer"
          },
          "per_type_available": {
            "type": "boolean"
          },
          "records_without_audit_detail": {
            "type": "integer"
          }
        },
        "required": [
          "read",
          "write_5m",
          "write_1h",
          "write_30m",
          "write_12h",
          "write_total_tokens",
          "per_type_available",
          "records_without_audit_detail"
        ],
        "additionalProperties": false
      },
      "ApiKeyUnauthorized": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "type": {
                "const": "authentication_error",
                "type": "string"
              },
              "code": {
                "enum": [
                  "missing_api_key",
                  "invalid_api_key",
                  "expired_api_key",
                  "account_not_found",
                  "account_deletion_scheduled"
                ],
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            },
            "required": [
              "type",
              "message",
              "code"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      },
      "GatewayModelSelectionError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "type",
              "code",
              "message",
              "param"
            ],
            "properties": {
              "type": {
                "type": "string",
                "const": "invalid_request_error"
              },
              "code": {
                "type": "string",
                "enum": [
                  "model_not_priced",
                  "model_retired",
                  "model_unavailable",
                  "model_endpoint_unsupported"
                ]
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string",
                "const": "model"
              },
              "suggested_model": {
                "$ref": "#/components/schemas/SuggestedModelId"
              }
            }
          }
        }
      },
      "GatewayCatalogueStaleError": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "type",
              "code",
              "message",
              "param",
              "catalogue_version",
              "catalogue_url"
            ],
            "properties": {
              "type": {
                "type": "string",
                "const": "invalid_request_error"
              },
              "code": {
                "type": "string",
                "const": "model_unknown_refresh_catalogue"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "type": "string",
                "const": "model"
              },
              "catalogue_version": {
                "type": "integer"
              },
              "catalogue_url": {
                "type": "string"
              },
              "suggested_model": {
                "$ref": "#/components/schemas/SuggestedModelId"
              }
            }
          }
        }
      },
      "SuggestedModelId": {
        "description": "Suggested active model ID, or null when no current alternative can be recommended.",
        "nullable": true,
        "type": "string"
      },
      "GatewayModelEndpointUnsupportedError": {
        "additionalProperties": false,
        "properties": {
          "error": {
            "additionalProperties": false,
            "properties": {
              "code": {
                "const": "model_endpoint_unsupported",
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "param": {
                "const": "model",
                "type": "string"
              },
              "suggested_model": {
                "$ref": "#/components/schemas/SuggestedModelId"
              },
              "type": {
                "const": "invalid_request_error",
                "type": "string"
              }
            },
            "required": [
              "type",
              "code",
              "message",
              "param"
            ],
            "type": "object"
          }
        },
        "required": [
          "error"
        ],
        "type": "object"
      }
    },
    "securitySchemes": {
      "ApiKey": {
        "bearerFormat": "cloak_<key>",
        "description": "CloakAPI tenant API key. Send as `Authorization: Bearer cloak_<32-char-key>`.\nProvision via the portal at https://app.cloakapi.io/api-keys.\nTokens never expire by default; revoke or rotate from the same page.\n",
        "scheme": "bearer",
        "type": "http"
      },
      "BearerToken": {
        "description": "bearer token (for dashboard endpoints reached via the browser portal).",
        "scheme": "bearer",
        "type": "http"
      },
      "ScimToken": {
        "description": "SCIM bearer token (for `/scim/v2/*` directory-sync endpoints).",
        "scheme": "bearer",
        "type": "http"
      }
    }
  },
  "info": {
    "contact": {
      "name": "CloakAPI Support",
      "url": "https://cloakapi.io"
    },
    "description": "CloakAPI lets customers use several supported LLM providers through a single API.\nOn supported client paths, on-device detection makes a best-effort attempt to find\nand tokenise personal data before a request leaves the customer's device; it can\nmiss details, see the Terms for the known limitations.\n\n**Authentication.** Authenticated operations declare their required security\nscheme individually. Health, discovery, SSO callback, and data-subject\nrequest routes are unauthenticated where their operation says so.\n\n**URL prefix.** Versioned API routes use the `/api/` prefix, including\n`/api/v1/messages` and `/api/v1/chat/completions`. The receipt public key\nis also available at the top-level `/.well-known/cloakapi-receipt-pubkey.pem`.\nSend API keys using `Authorization: Bearer`.\n\n**Receipt envelope** – inference calls can carry an\n[OpenReceipt](https://signedreceipts.org) ECDSA-P-256 receipt.\nSee `#/components/schemas/OpenReceiptEnvelope`. Verify with\n`cloak-receipt verify --receipt <file> --jwks https://api.cloakapi.io/.well-known/openreceipt-pubkeys.jwks`\nor via `POST /api/v1/receipts/verify`. The CLI takes named flags, not a\npositional filename. Binaries and SHA-256 checksums for Linux and Windows:\nhttps://app.cloakapi.io/downloads (Receipt verifier section) — macOS is not built,\nbuild it from source. The CLI resolves the key from the published JWKS and\nasks CloakAPI for nothing.\n\n**Beyond the API.** This spec is the foundation, but there are three ways to use\nCloakAPI — the API/SDK/proxy documented here, the in-browser\n[Chat](https://docs.cloakapi.io/start/chat/), and the\n[browser extension](https://docs.cloakapi.io/start/extension/) — plus a Windows\n[desktop power-up](https://docs.cloakapi.io/start/desktop/). See\n[Ways to use CloakAPI](https://docs.cloakapi.io/#ways-to-use-cloakapi). Pricing is\nusage-based, USD only.\n",
    "license": {
      "name": "Proprietary",
      "url": "https://cloakapi.io/legal/terms"
    },
    "title": "CloakAPI Gateway",
    "version": "2026.11.19.1",
    "x-logo": {
      "altText": "CloakAPI",
      "href": "https://docs.cloakapi.io/",
      "url": "/api-reference/logo-mini.svg"
    }
  },
  "openapi": "3.1.0",
  "paths": {
    "/.well-known/cloakapi-receipt-pubkey.pem": {
      "get": {
        "description": "Returns the configured v2 receipt-signing public key as PEM; if the key cannot be loaded, the response body is empty.",
        "operationId": "wellKnownReceiptPubkeyPem",
        "responses": {
          "200": {
            "content": {
              "application/x-pem-file": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "PEM bundle"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [],
        "summary": "Receipt signing public key (PEM)",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/cloakapi-receipt-pubkey.pem": {
      "get": {
        "description": "Returns the configured gateway signing public key as PEM, or a fallback text body when no key can be read.",
        "operationId": "wellKnownReceiptPubkeyPemApi",
        "responses": {
          "200": {
            "content": {
              "application/x-pem-file": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "PEM-encoded receipt signing public key."
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Receipt signing public key (PEM)",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/cloakapi-receipt-pubkeys.jwks": {
      "get": {
        "description": "Returns the available receipt-signing public keys in JWKS form; the keys array can be empty when no key can be loaded.",
        "operationId": "wellKnownReceiptPubkeysJwks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptJwksResponse"
                }
              }
            },
            "description": "JWKS document"
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "JWK Set of current receipt-signing public keys",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/jwks.json": {
      "get": {
        "description": "Returns available keys from the gateway key registry as a JWKS document; the keys array can be empty if the registry cannot be loaded. Public requests are limited to 120 per minute; the response is cached for up to five minutes.",
        "operationId": "gatewayReceiptJwks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptJwksResponse"
                }
              }
            },
            "description": "JWKS containing the available gateway receipt verification keys."
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Gateway receipt-key rotation JWKS",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/oauth-authorization-server": {
      "get": {
        "description": "Returns OAuth authorization-server metadata used by clients to discover the configured authorization endpoints and supported capabilities.",
        "operationId": "wellKnownOauthAuthorizationServer",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "Authorization server metadata"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "OAuth 2.0 / OIDC authorization server metadata",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/openapi.json": {
      "get": {
        "description": "Returns the committed OpenAPI JSON document served by the gateway's well-known endpoint.",
        "operationId": "wellKnownOpenapiJson",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "OpenAPI JSON document"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "OpenAPI spec (JSON)",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/.well-known/security.txt": {
      "get": {
        "description": "Returns the gateway's security contact and vulnerability-disclosure policy as plain text.",
        "operationId": "wellKnownSecurityTxt",
        "responses": {
          "200": {
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "security.txt content"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "security.txt vulnerability disclosure",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/auth/finalize-exchange": {
      "post": {
        "description": "Consumes the one-time 64-character lowercase hexadecimal code from the email-verification redirect. A used, expired, or unknown code returns 400.",
        "operationId": "authFinalizeExchange",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "maxLength": 64,
                    "minLength": 64,
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "token": {
                      "type": "string",
                      "writeOnly": true
                    },
                    "user": {
                      "$ref": "#/components/schemas/UserResource"
                    }
                  },
                  "required": [
                    "token",
                    "user"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Exchange succeeded."
          },
          "400": {
            "description": "The code is unknown, expired, or already used. error.code is invalid_or_expired_code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The code is missing or malformed; validation_error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Exchange an email-verification code for a bearer token",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/forgot-password": {
      "post": {
        "description": "Always returns the same body whether or not the email exists\n(anti-enumeration). Controllers throttle this endpoint.\n",
        "operationId": "authForgotPassword",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "status": {
                      "example": "sent",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Reset link dispatched if the account exists"
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Request a password-reset link",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/login": {
      "post": {
        "description": "Authenticates with email and password and returns a bearer token plus user resource on success. Invalid credentials return a uniform 401; an organisation requiring SSO returns 403; per-account lockout or route throttling can return 429.",
        "operationId": "authLogin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "password"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "token": {
                      "type": "string",
                      "writeOnly": true
                    },
                    "user": {
                      "$ref": "#/components/schemas/UserResource"
                    }
                  },
                  "required": [
                    "user",
                    "token"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authenticated; a token and user resource are returned."
          },
          "401": {
            "description": "Invalid email/password combination.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Password login is disallowed because the organisation requires SSO.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Email or password request field failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Login rate limit or per-account lockout. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Obtain a bearer token",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/logout": {
      "post": {
        "description": "Revokes the current bearer token and returns `{message: \"Logged out.\"}` with HTTP 200.",
        "operationId": "authLogout",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "const": "Logged out.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Current token revoked."
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Revoke current bearer token",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/me": {
      "get": {
        "description": "Alias of GET /api/auth/user. Returns the profile for the authenticated Sanctum bearer and has the same throttle.",
        "operationId": "authMe",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserResource"
                }
              }
            },
            "description": "Current authenticated user profile."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "429": {
            "description": "The 60-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get authenticated user (portal alias)",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/register": {
      "post": {
        "description": "Creates an account and issues a bearer token. Standard signup requires name, email, password, and confirmation; the campaign mini-shell accepts email plus campaign target slug and derives the other values. Signup may be paused with 503; validation or billing/invite rules can return 422, an expired invitation returns 410, and the named signup limiter can return 429.",
        "operationId": "authRegister",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "properties": {
                      "billing_country": {
                        "maxLength": 2,
                        "minLength": 2,
                        "pattern": "^[A-Za-z]{2}$",
                        "type": "string"
                      },
                      "billing_currency": {
                        "maxLength": 3,
                        "minLength": 3,
                        "pattern": "^[A-Za-z]{3}$",
                        "type": "string"
                      },
                      "billing_vat_id": {
                        "maxLength": 32,
                        "type": "string"
                      },
                      "campaign_target_slug": {
                        "maxLength": 100,
                        "pattern": "^[a-z0-9][a-z0-9-]*$",
                        "type": "string"
                      },
                      "company_name": {
                        "maxLength": 255,
                        "type": "string"
                      },
                      "country_code": {
                        "maxLength": 2,
                        "minLength": 2,
                        "pattern": "^[A-Za-z]{2}$",
                        "type": "string"
                      },
                      "email": {
                        "format": "email",
                        "maxLength": 255,
                        "type": "string"
                      },
                      "invite_token": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "name": {
                        "maxLength": 255,
                        "type": "string"
                      },
                      "password": {
                        "format": "password",
                        "type": "string"
                      },
                      "password_confirmation": {
                        "format": "password",
                        "type": "string"
                      },
                      "utm_campaign": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "utm_content": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "utm_medium": {
                        "maxLength": 64,
                        "type": "string"
                      },
                      "utm_source": {
                        "maxLength": 64,
                        "type": "string"
                      }
                    },
                    "required": [
                      "name",
                      "email",
                      "password",
                      "password_confirmation"
                    ],
                    "type": "object"
                  },
                  {
                    "properties": {
                      "campaign_target_slug": {
                        "maxLength": 100,
                        "pattern": "^[a-z0-9][a-z0-9-]*$",
                        "type": "string"
                      },
                      "email": {
                        "format": "email",
                        "maxLength": 255,
                        "type": "string"
                      },
                      "utm_campaign": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "utm_content": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "utm_medium": {
                        "maxLength": 64,
                        "type": "string"
                      },
                      "utm_source": {
                        "maxLength": 64,
                        "type": "string"
                      }
                    },
                    "required": [
                      "email",
                      "campaign_target_slug"
                    ],
                    "type": "object"
                  }
                ]
              }
            }
          },
          "description": "Standard registration requires all four credential fields; campaign mini-shell derives name and password from email when only email and campaign_target_slug are sent.",
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "email_delivery_failed": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string",
                      "writeOnly": true
                    },
                    "user": {
                      "$ref": "#/components/schemas/UserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Account created and a bearer token returned."
          },
          "410": {
            "description": "Invitation expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation, invitation, or signup billing gate rejected the request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Signup rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Signups are paused.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Register a new account",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/reset-password": {
      "post": {
        "description": "Consumes the {token,email,password,password_confirmation} payload.\nPassword must be at least 12 characters long. On success\nreturns a bearer token and revokes prior tokens.\n",
        "operationId": "authResetPassword",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "password": {
                    "format": "password",
                    "minLength": 12,
                    "type": "string"
                  },
                  "password_confirmation": {
                    "type": "string"
                  },
                  "token": {
                    "type": "string"
                  }
                },
                "required": [
                  "token",
                  "email",
                  "password",
                  "password_confirmation"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Password updated; caller is signed in"
          },
          "422": {
            "description": "Validation error or reset_failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Reset password with emailed token",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/auth/sso/oidc/callback": {
      "get": {
        "description": "Consumes the code and required 32-character state from the OIDC callback. State is single-use and binds the exchange to the initiation-time PKCE verifier and nonce. On success the controller returns api_token, user_id and email as JSON; it does not redirect. The unauthenticated route is limited to 20 requests per minute per IP.",
        "operationId": "ssoOidcCallback",
        "parameters": [
          {
            "in": "query",
            "name": "code",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "state",
            "required": true,
            "schema": {
              "maxLength": 32,
              "minLength": 32,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_token": {
                      "type": "string"
                    },
                    "email": {
                      "format": "email",
                      "type": "string"
                    },
                    "user_id": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "api_token",
                    "user_id",
                    "email"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "OIDC code exchange succeeded."
          },
          "422": {
            "description": "Missing or invalid state, configuration, code exchange, or tenant account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "OIDC callback – exchange code for token",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/auth/sso/oidc/initiate": {
      "get": {
        "description": "Builds an authorization URL from the tenant_id and redirect_uri query parameters. Both are validated; tenant_id must be a positive integer and redirect_uri a URL of at most 2048 characters. The enabled OIDC configuration must exist. Returns auth_url, state and binding as JSON; this route is unauthenticated and limited to 20 requests per minute per IP.",
        "operationId": "ssoOidcInitiate",
        "parameters": [
          {
            "in": "query",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "redirect_uri",
            "required": true,
            "schema": {
              "format": "uri",
              "maxLength": 2048,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "auth_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "binding": {
                      "description": "One-time client-held secret (64 hex characters). Keep it in the client that started the sign-in and send it to the OIDC token endpoint together with the code and state.",
                      "maxLength": 64,
                      "minLength": 64,
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "auth_url",
                    "state",
                    "binding"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authorization URL, single-use state and client-held binding returned."
          },
          "422": {
            "description": "OIDC is not configured or the request is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          },
          "502": {
            "description": "OIDC initiation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "oidc_initiate_failed"
                    },
                    "detail": {
                      "type": "string"
                    },
                    "ref": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail",
                    "ref"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Initiate OIDC SSO flow",
        "tags": [
          "sso"
        ]
      },
      "post": {
        "description": "Accepts tenant_id and redirect_uri in a JSON request body and returns auth_url, state and binding as JSON. Both values are validated; tenant_id must be a positive integer and redirect_uri a URL of at most 2048 characters. The enabled OIDC configuration must exist. This route is unauthenticated and limited to 20 requests per minute per IP.",
        "operationId": "ssoOidcInitiatePost",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "redirect_uri": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "tenant_id": {
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "required": [
                  "tenant_id",
                  "redirect_uri"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "auth_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "binding": {
                      "description": "One-time client-held secret (64 hex characters). Keep it in the client that started the sign-in and send it to the OIDC token endpoint together with the code and state.",
                      "maxLength": 64,
                      "minLength": 64,
                      "type": "string"
                    },
                    "state": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "auth_url",
                    "state",
                    "binding"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authorization URL, single-use state and client-held binding returned."
          },
          "422": {
            "description": "OIDC is not configured or the request is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          },
          "502": {
            "description": "OIDC initiation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "oidc_initiate_failed"
                    },
                    "detail": {
                      "type": "string"
                    },
                    "ref": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail",
                    "ref"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Initiate OIDC SSO flow (POST variant)",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/auth/sso/saml/initiate": {
      "get": {
        "description": "Looks up the enabled SAML configuration for tenant_id, stores an opaque RelayState for ten minutes and redirects to the configured IdP SSO URL with that RelayState. The handler does not add a SAMLRequest parameter. The unauthenticated route is limited to 20 requests per minute per IP.",
        "operationId": "ssoSamlInitiate",
        "parameters": [
          {
            "in": "query",
            "name": "tenant_id",
            "required": true,
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the configured IdP SSO URL."
          },
          "422": {
            "description": "Tenant or SAML configuration is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          },
          "503": {
            "description": "SAML state could not be stored.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "saml_state_unavailable"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Start SAML sign-in at the configured IdP",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/auth/user": {
      "get": {
        "description": "Returns the profile for the authenticated Sanctum bearer. The route has a 60-request-per-minute throttle and does not accept a user identifier.",
        "operationId": "authUser",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UserResource"
                }
              }
            },
            "description": "Current authenticated user profile."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "429": {
            "description": "The 60-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get authenticated user",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/billing/balance": {
      "get": {
        "description": "Returns the authenticated account's prepaid balance in cents and dollars, low-balance flag, and configured threshold. The route requires the billing balance authentication middleware and accepted terms.",
        "operationId": "billingBalance",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "balance_cents": {
                      "type": "integer"
                    },
                    "balance_dollars": {
                      "type": "number"
                    },
                    "is_low_balance": {
                      "type": "boolean"
                    },
                    "low_balance_threshold_dollars": {
                      "type": "number"
                    },
                    "balance_micros": {
                      "description": "Exact balance in USD micro-dollars. Existing cents fields remain for compatibility.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "balance_cents",
                    "balance_dollars",
                    "is_low_balance",
                    "low_balance_threshold_dollars",
                    "balance_micros"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authenticated prepaid balance and low-balance threshold."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Get current balance",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/checkout/amounts": {
      "get": {
        "description": "Returns the configured top-up amount entries and currency for the authenticated account. Checkout creation is handled by POST `/api/billing/checkout/topup`.",
        "operationId": "billingTopupAmounts",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "amounts": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "amount_cents": {
                            "type": "integer"
                          }
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "currency": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "amounts",
                    "currency"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Configured top-up entries and currency for the authenticated account."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List available top-up amounts",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/checkout/topup": {
      "post": {
        "description": "Creates a Stripe Checkout session for a prepaid top-up and returns its URL, session ID, and amount in cents. The return URL must be HTTP(S) on an allowed dashboard host; amount/VAT checks return 422 and Stripe-session failures return 502.",
        "operationId": "billingCheckoutTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "amount_cents": {
                    "maximum": 200000,
                    "minimum": 500,
                    "type": "integer"
                  },
                  "return_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  }
                },
                "required": [
                  "amount_cents",
                  "return_url"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "checkout_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "checkout_url",
                    "session_id",
                    "amount_cents"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Stripe Checkout session created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "description": "Invalid amount/return URL or billing details are incomplete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Checkout session creation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create a top-up checkout session",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/invoices": {
      "get": {
        "description": "Returns the authenticated account's prepaid transactions, newest first, using pagination with 50 rows per page. This handler accepts no filter parameters.",
        "operationId": "billingInvoicesList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "transactions": {
                      "additionalProperties": true,
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "data": {
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "amount_micros": {
                                "description": "Exact signed transaction amount in USD micro-dollars; legacy cents-only rows are returned as amount_cents × 10,000.",
                                "type": "integer"
                              },
                              "has_receipt": {
                                "description": "Whether a signed receipt is linked to the usage record for this debit.",
                                "type": "boolean"
                              },
                              "amount_cents": {
                                "description": "Signed whole-cent wallet settlement for this transaction. For usage debits the subcent remainder is carried across calls, so this can differ from rounding amount_micros per row.",
                                "type": "integer"
                              }
                            },
                            "required": [
                              "amount_micros",
                              "has_receipt",
                              "amount_cents"
                            ]
                          },
                          "type": "array"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "next_page_url": {
                          "format": "uri",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "per_page": {
                          "const": 50,
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "data",
                        "current_page",
                        "per_page",
                        "total"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "transactions"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Transactions ordered newest first with pagination metadata (50 rows per page)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List invoices",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/redeem-license": {
      "post": {
        "description": "Redeems an eligible license code and adds its credit to the authenticated account balance. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "billingRedeemLicenseLegacy",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "code": {
                    "maxLength": 64,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "balance_cents": {
                      "type": "integer"
                    },
                    "balance_dollars": {
                      "type": "number"
                    },
                    "credit_cents": {
                      "type": "integer"
                    },
                    "credit_dollars": {
                      "type": "number"
                    },
                    "balance_micros": {
                      "description": "Exact wallet balance in USD micro-dollars after redemption.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "credit_cents",
                    "credit_dollars",
                    "balance_cents",
                    "balance_dollars",
                    "balance_micros"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code was redeemed and the account balance was updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "enum": [
                            "expired",
                            "exhausted",
                            "already_redeemed"
                          ],
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code is expired, exhausted, or has already been redeemed by this account."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code is missing, invalid, or failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "too_many_attempts",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "scope": {
                          "const": "route",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The limit of 10 redemption requests per minute was exceeded. An edge rate limit may return an HTML error page.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "minimum": 1,
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "const": "route",
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Redeem License",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/topup": {
      "post": {
        "description": "Creates a checkout session for a prepaid top-up and returns its URL, session ID, and amount in cents. The return URL must use HTTPS and an allowed dashboard host. The configured minimum amount is at least 2500 cents; the maximum is 200000 cents. Include a valid `topup_nonce` with each request. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "billingTopupLegacy",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "amount_cents": {
                    "maximum": 200000,
                    "minimum": 2500,
                    "type": "integer"
                  },
                  "return_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "topup_nonce": {
                    "description": "A client-generated nonce containing 16 to 64 letters, digits, underscores, or hyphens.",
                    "maxLength": 64,
                    "minLength": 16,
                    "pattern": "^[A-Za-z0-9_-]{16,64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "amount_cents",
                  "return_url",
                  "topup_nonce"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "checkout_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "checkout_url",
                    "session_id",
                    "amount_cents"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Checkout session created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The amount, HTTPS return URL, billing details, nonce, or request fields are invalid."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "stripe_error",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The checkout session could not be created."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Topup",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/usage": {
      "get": {
        "description": "Returns the authenticated account's usage records, pagination metadata, and totals computed over the same optional filters. Requires `billing.read`; `per_page` defaults to 50 and is capped at 100. `to` must not precede `from`, and the date range cannot exceed 366 days. This list uses offset pagination ordered by `created_at DESC`, then `id DESC`. Keep the same filters and `per_page` value for every page. If rows are added or deleted while paging, rows can repeat or be skipped. Restart at page 1 after the list has stopped changing for a fresh traversal; this endpoint does not provide a point-in-time snapshot.",
        "operationId": "billingUsageIndex",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "description": "Must be on or after from.",
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "per_page",
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "pagination": {
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "per_page": {
                          "maximum": 100,
                          "minimum": 1,
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "current_page",
                        "last_page",
                        "per_page",
                        "total"
                      ],
                      "type": "object"
                    },
                    "records": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "provider_cost_micros": {
                            "description": "Exact provider cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "markup_micros": {
                            "description": "Exact markup in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "total_cost_micros": {
                            "description": "Exact billed cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "has_receipt": {
                            "description": "Whether a signed receipt is linked to this usage record.",
                            "type": "boolean"
                          },
                          "cache_usage": {
                            "anyOf": [
                              {
                                "$ref": "#/components/schemas/CacheUsageBreakdown"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Per-type cache provider-cost detail, already included in provider_cost_micros and not added again to the billed total."
                          },
                          "receipt_mode": {
                            "description": "Optional mode from the linked receipt; absent when no receipt is linked.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "receipt_tier": {
                            "description": "Optional privacy tier from the linked receipt; absent when no receipt is linked.",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "provider_cost_micros",
                          "markup_micros",
                          "total_cost_micros",
                          "has_receipt"
                        ]
                      },
                      "type": "array"
                    },
                    "totals": {
                      "properties": {
                        "input_tokens": {
                          "type": "integer"
                        },
                        "markup_cents": {
                          "type": "integer"
                        },
                        "output_tokens": {
                          "type": "integer"
                        },
                        "provider_cost_cents": {
                          "type": "integer"
                        },
                        "scope_filtered": {
                          "type": "boolean"
                        },
                        "total_cost_cents": {
                          "type": "integer"
                        },
                        "total_cost_dollars": {
                          "type": "number"
                        },
                        "provider_cost_micros": {
                          "type": "integer"
                        },
                        "markup_micros": {
                          "type": "integer"
                        },
                        "total_cost_micros": {
                          "type": "integer"
                        },
                        "cache_usage": {
                          "$ref": "#/components/schemas/CacheUsageBreakdown"
                        }
                      },
                      "required": [
                        "input_tokens",
                        "output_tokens",
                        "provider_cost_cents",
                        "markup_cents",
                        "total_cost_cents",
                        "total_cost_dollars",
                        "scope_filtered",
                        "provider_cost_micros",
                        "markup_micros",
                        "total_cost_micros",
                        "cache_usage"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "records",
                    "pagination",
                    "totals"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Paginated usage records and totals over the same optional filters."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid filters or a requested date range exceeding 366 days.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Usage analytics (full)",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/usage/export": {
      "get": {
        "description": "Streams a CSV of up to 10,000 usage rows with request ID, provider, model, token counts, costs, response time, and creation time. Requires `billing.read`. Optional date and provider filters are supported; the route is limited to five requests per minute.",
        "operationId": "billingUsageExport",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "CSV export with at most 10,000 rows."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Date or provider query value failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The five-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Export usage as CSV",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/billing/usage/summary": {
      "get": {
        "description": "Returns daily per-provider usage rows and window aggregates for requests, tokens, billed cost, latency percentiles, traffic presence, request-count change, and usage rows without linked receipts. `window` accepts `24h`, `7d`, `30d`, or `90d`; explicit `from` and `to` dates take precedence. Latency percentiles and the change value can be null when there is no sample or comparison window.",
        "operationId": "billingUsageSummary",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "window",
            "schema": {
              "enum": [
                "24h",
                "7d",
                "30d",
                "90d"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "cost_billed_cents": {
                      "type": "integer"
                    },
                    "from": {
                      "format": "date",
                      "type": "string"
                    },
                    "has_traffic": {
                      "type": "boolean"
                    },
                    "input_tokens": {
                      "type": "integer"
                    },
                    "output_tokens": {
                      "type": "integer"
                    },
                    "p50_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "p95_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "p99_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "requests": {
                      "type": "integer"
                    },
                    "requests_delta_pct": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "summary": {
                      "items": {
                        "properties": {
                          "cost_cents": {
                            "type": "integer"
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "input_tokens": {
                            "type": "integer"
                          },
                          "output_tokens": {
                            "type": "integer"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "request_count": {
                            "type": "integer"
                          },
                          "cost_micros": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "date",
                          "provider",
                          "request_count",
                          "input_tokens",
                          "output_tokens",
                          "cost_cents",
                          "cost_micros"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "to": {
                      "format": "date",
                      "type": "string"
                    },
                    "tokens_provider": {
                      "type": "integer"
                    },
                    "total_requests": {
                      "type": "integer"
                    },
                    "cost_billed_micros": {
                      "type": "integer"
                    },
                    "no_receipt_count": {
                      "description": "Number of usage records without a linked receipt; these rows remain included in totals.",
                      "type": "integer"
                    },
                    "cache_usage": {
                      "$ref": "#/components/schemas/CacheUsageBreakdown"
                    }
                  },
                  "required": [
                    "summary",
                    "from",
                    "to",
                    "requests",
                    "total_requests",
                    "has_traffic",
                    "input_tokens",
                    "output_tokens",
                    "tokens_provider",
                    "cost_billed_cents",
                    "p50_latency_ms",
                    "p95_latency_ms",
                    "p99_latency_ms",
                    "requests_delta_pct",
                    "cost_billed_micros",
                    "no_receipt_count",
                    "cache_usage"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Daily provider rows and window aggregates derived from usage records."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid date, provider, or window filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Usage summary (aggregated)",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/buffer/{requestId}": {
      "get": {
        "description": "Retrieves a buffered response for the authenticated user and request ID. API keys require the explicit `buffer` permission and can read only responses stored with that key; Sanctum PATs require the `buffer` ability and retain the user ownership filter. The ID must be a UUID; malformed IDs return 400, while missing, expired, or already retrieved responses return 404. Retrieval conditionally deletes the unread row inside a transaction before returning its payload.",
        "operationId": "bufferRetrieve",
        "parameters": [
          {
            "in": "path",
            "name": "requestId",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Buffered response returned after conditional deletion of the unread row inside a transaction."
          },
          "400": {
            "description": "The request identifier is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "invalid_request_id"
                        },
                        "type": {
                          "type": "string",
                          "const": "invalid_request"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "type",
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token or API key."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "A 403 response means that the credential lacks the required buffer permission or ability, or that the API key was rejected by its IP allowlist."
          },
          "404": {
            "description": "The buffered response was not found, expired, or already retrieved.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "buffer_not_found"
                        },
                        "type": {
                          "type": "string",
                          "const": "not_found"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "type",
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          },
          {
            "ApiKey": []
          }
        ],
        "summary": "Retrieve buffered streaming response by request ID",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/devices": {
      "get": {
        "description": "Lists non-deleted backup devices for the authenticated account, ordered by last-seen time. Each item contains device metadata and pairing/online state; the encrypted token blob is not included.",
        "operationId": "devicesList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "devices": {
                      "items": {
                        "properties": {
                          "created_at": {
                            "format": "date-time",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "device_fingerprint": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "device_name": {
                            "type": "string"
                          },
                          "id": {
                            "type": "integer"
                          },
                          "is_active": {
                            "type": "boolean"
                          },
                          "is_online": {
                            "type": "boolean"
                          },
                          "last_seen_at": {
                            "format": "date-time",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "pairing_complete": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "device_name",
                          "pairing_complete",
                          "is_active",
                          "is_online"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "devices"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Non-deleted backup devices ordered by last-seen time; encrypted token blobs are not returned."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List paired backup devices",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/devices/pair": {
      "post": {
        "description": "Creates a pending backup-device pairing for the authenticated account. `device_name` is optional and limited to 100 characters; the response contains a six-digit code and a 300-second expiry. A sixth active device is rejected with 422.",
        "operationId": "devicesInitiatePairing",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "device_name": {
                    "maxLength": 100,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "device_id": {
                      "type": "integer"
                    },
                    "expires_in_seconds": {
                      "const": 300,
                      "type": "integer"
                    },
                    "instructions": {
                      "type": "string"
                    },
                    "pairing_code": {
                      "pattern": "^[0-9]{6}$",
                      "type": "string"
                    }
                  },
                  "required": [
                    "device_id",
                    "pairing_code",
                    "expires_in_seconds",
                    "instructions"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Pairing code created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Device limit reached or invalid device name.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Initiate device pairing",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/devices/{id}": {
      "delete": {
        "description": "Soft-deletes the backup device with this ID for the authenticated account and returns a message. A missing device or an ID belonging to another account is not found.",
        "operationId": "devicesDestroy",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "const": "Device removed.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Device removed."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "404": {
            "description": "Device not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "not_found"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Remove a paired device",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/devices/{id}/complete-pairing": {
      "post": {
        "description": "Completes pairing for a device owned by the authenticated account using its six-digit pairing code and a 32-byte X25519 public key encoded as base64 or hex. Invalid or expired codes return 400; malformed input returns 422; an unowned/missing device returns 404.",
        "operationId": "devicesCompletePairing",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "pairing_code": {
                    "maxLength": 6,
                    "minLength": 6,
                    "pattern": "^[0-9]{6}$",
                    "type": "string"
                  },
                  "public_key": {
                    "description": "32-byte X25519 public key encoded as base64 or hexadecimal.",
                    "oneOf": [
                      {
                        "maxLength": 44,
                        "minLength": 44,
                        "pattern": "^[A-Za-z0-9+/]{43}=$",
                        "type": "string"
                      },
                      {
                        "maxLength": 64,
                        "minLength": 64,
                        "pattern": "^[A-Fa-f0-9]{64}$",
                        "type": "string"
                      }
                    ]
                  }
                },
                "required": [
                  "pairing_code",
                  "public_key"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "device": {
                      "properties": {
                        "created_at": {
                          "format": "date-time",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "device_fingerprint": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "device_name": {
                          "type": "string"
                        },
                        "id": {
                          "type": "integer"
                        },
                        "is_active": {
                          "type": "boolean"
                        },
                        "is_online": {
                          "type": "boolean"
                        },
                        "last_seen_at": {
                          "format": "date-time",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "pairing_complete": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "id",
                        "device_name",
                        "pairing_complete",
                        "is_active",
                        "is_online"
                      ],
                      "type": "object"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "device",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Device paired."
          },
          "400": {
            "description": "Pairing code is invalid or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "404": {
            "description": "Device was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Pairing fields or public-key encoding are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Complete device pairing (confirm challenge)",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/devices/{id}/heartbeat": {
      "post": {
        "description": "Records a heartbeat for a completed backup device owned by the authenticated account and returns an `ok` status with timestamp. A missing or unpaired device returns 404.",
        "operationId": "devicesHeartbeat",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "status": {
                      "const": "ok",
                      "type": "string"
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "status",
                    "timestamp"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Heartbeat accepted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "404": {
            "description": "Device was not found or is not paired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Device heartbeat (keep-alive)",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/devices/{id}/token-blob": {
      "post": {
        "description": "Stores the caller-provided encrypted token blob for a completed device owned by the authenticated account. The string must be 16 to 65,536 characters; the response contains a message, not the blob. Invalid input returns 422 and a missing/unowned device returns 404.",
        "operationId": "devicesUploadTokenBlob",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "encrypted_blob": {
                    "description": "Base64-encoded AES-GCM ciphertext",
                    "type": "string"
                  }
                },
                "required": [
                  "encrypted_blob"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "const": "Token blob stored.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Encrypted blob stored."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "404": {
            "description": "Completed device was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Upload encrypted token-blob for backup device",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/gdpr/dsar-status/{request_id}": {
      "get": {
        "description": "Looks up a data-subject request using the path request ID, the required email query value, and the X-Verification-Token header. The request ID alone is not authorization. Invalid credentials and an unknown request share a 404 response; the route is limited to ten requests per minute.",
        "operationId": "gdprDsarStatus",
        "parameters": [
          {
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "email",
            "required": true,
            "schema": {
              "format": "email",
              "type": "string"
            }
          },
          {
            "in": "header",
            "name": "X-Verification-Token",
            "required": true,
            "schema": {
              "maxLength": 256,
              "minLength": 8,
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "completed_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "deadline": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "requested_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "type": {
                      "enum": [
                        "export",
                        "erasure"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "request_id",
                    "type",
                    "status",
                    "requested_at",
                    "completed_at",
                    "deadline"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authenticated request status."
          },
          "404": {
            "description": "No request matched the request ID, email, and token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Email or verification token failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The data-subject lookup throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Check DSAR (Data Subject Access Request) status",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/gdpr/erasure-request": {
      "post": {
        "description": "Creates a pending erasure request for the required `email` address (valid email, up to 254 characters). The API returns 202 whether or not an account is linked; when one is linked, it emails a verification token, and erasure is scheduled only after confirmation. Invalid input returns 422; more than 10 requests per minute returns 429.",
        "operationId": "gdprErasureRequest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "reason": {
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Request accepted"
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Submit a GDPR erasure (right-to-erasure) request",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/gdpr/export-download/{request_id}": {
      "get": {
        "description": "Legacy GET compatibility route. Credentials in the query string are ignored; use POST with a JSON body to send email and verification_token. Depending on storage configuration, a valid request streams JSON (or requested HTML) or redirects to a temporary storage URL. Missing/not-ready files return 404 and expired exports return 410; the route is limited to ten requests per minute.",
        "operationId": "gdprExportDownload",
        "parameters": [
          {
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the exact value `html` selects the HTML response; other values use JSON.",
            "in": "query",
            "name": "format",
            "schema": {
              "default": "json",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Local-storage export. JSON is the default; `format=html` returns an HTML view."
          },
          "302": {
            "description": "Redirect to a temporary storage URL.",
            "headers": {
              "Location": {
                "schema": {
                  "format": "uri",
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Export is not available or credentials do not match.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "Export link has expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Email or verification token failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The export-download throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Legacy GET alias for completed data export",
        "tags": [
          "compliance"
        ]
      },
      "post": {
        "description": "Returns a completed export after matching the request ID, email, and verification token. Credentials are sent in the JSON request body so the token is not copied into the URL, access logs, or Referer. Depending on storage configuration it streams JSON (or requested HTML) or redirects to a temporary storage URL. Missing/not-ready files return 404 and expired exports return 410; the route is limited to ten requests per minute.",
        "operationId": "gdprExportDownloadPost",
        "parameters": [
          {
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Only the exact value `html` selects the HTML response; other values use JSON.",
            "in": "query",
            "name": "format",
            "schema": {
              "default": "json",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "verification_token": {
                    "maxLength": 256,
                    "minLength": 8,
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "verification_token"
                ],
                "type": "object"
              }
            }
          },
          "description": "Credentials are sent in the request body so the verification token is not copied into the URL, access logs, or Referer.",
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Local-storage export. JSON is the default; `format=html` returns an HTML view."
          },
          "302": {
            "description": "Redirect to a temporary storage URL.",
            "headers": {
              "Location": {
                "schema": {
                  "format": "uri",
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Export is not available or credentials do not match.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "Export link has expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Email or verification token failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The export-download throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Download completed data export",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/gdpr/export-download/{request_id}/signed": {
      "get": {
        "description": "Streams a complete or partial Article 15 export through the short-lived signed link sent in the completion email. The requester must also be authenticated as the account linked to the export. A valid link signature alone does not grant access. Email addresses and export contents are not placed in the URL.",
        "operationId": "gdprExportDownloadSigned",
        "parameters": [
          {
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "pattern": "^[a-z0-9\\-]+$",
              "type": "string"
            }
          },
          {
            "description": "The exact value `html` selects the HTML response; other values use JSON.",
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "default": "json",
              "type": "string"
            }
          },
          {
            "description": "Expiry timestamp signed by the gateway.",
            "in": "query",
            "name": "expires",
            "required": true,
            "schema": {
              "type": "integer"
            }
          },
          {
            "description": "The temporary integrity signature. It does not grant access without authentication as the account linked to the export.",
            "in": "query",
            "name": "signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Export streamed from configured storage."
          },
          "401": {
            "description": "Authentication as the account linked to the export is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "The link signature is invalid or expired, or the authenticated account does not own the export.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "The export is unavailable or not complete.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "The export retention period has ended.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The export-download throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Download an export from its signed completion link",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/gdpr/export-request": {
      "post": {
        "description": "Creates a pending data export request for the required `email` address (valid email, up to 254 characters). The API returns 202 whether or not an account is linked; when one is linked, it emails a verification token, and the export is prepared only after confirmation. Invalid input returns 422; more than 10 requests per minute returns 429.",
        "operationId": "gdprExportRequest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "description": "Export request accepted"
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Submit a GDPR data export (right-of-access) request",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/health": {
      "get": {
        "description": "Public liveness signal. Returns only a coarse status and does not expose internal dependency or provider state.",
        "operationId": "health",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "status": {
                      "enum": [
                        "ok"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "status"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Gateway process is responding."
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Liveness/overall health",
        "tags": [
          "health"
        ]
      }
    },
    "/api/health/live": {
      "get": {
        "description": "Returns alive=true while the gateway process can answer the request. This probe does not check database, cache, queue or upstream providers.",
        "operationId": "healthLive",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "alive": {
                      "const": true,
                      "type": "boolean"
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "alive",
                    "timestamp"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Alive"
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [],
        "summary": "Liveness probe (process alive)",
        "tags": [
          "health"
        ]
      }
    },
    "/api/health/ready": {
      "get": {
        "description": "Checks database, cache and engine identity configuration. The status, ready, database, cache and engine_identity fields depend only on readiness checks and are unchanged by hash_mode. The hash_mode and engine_hash_mode_ok fields report enforcement mode for information only; non-enforce mode emits one warning per process and never changes the HTTP status or stops customer traffic. Dependency failures report status=not_ready with HTTP 503. Queue-worker state does not affect readiness.",
        "operationId": "healthReady",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "cache": {
                      "enum": [
                        "ok"
                      ],
                      "type": "string"
                    },
                    "database": {
                      "enum": [
                        "ok"
                      ],
                      "type": "string"
                    },
                    "engine_hash_mode_ok": {
                      "type": "boolean"
                    },
                    "engine_identity": {
                      "enum": [
                        "ok"
                      ],
                      "type": "string"
                    },
                    "hash_mode": {
                      "enum": [
                        "enforce",
                        "log",
                        "off"
                      ],
                      "type": "string"
                    },
                    "ready": {
                      "const": true,
                      "type": "boolean"
                    },
                    "status": {
                      "const": "ready",
                      "type": "string"
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "status",
                    "ready",
                    "database",
                    "cache",
                    "engine_identity",
                    "hash_mode",
                    "engine_hash_mode_ok",
                    "timestamp"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Dependencies and engine identity configuration are ready. HTTP 200 and existing readiness fields are independent of hash_mode."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "cache": {
                      "enum": [
                        "ok",
                        "error"
                      ],
                      "type": "string"
                    },
                    "database": {
                      "enum": [
                        "ok",
                        "error"
                      ],
                      "type": "string"
                    },
                    "engine_hash_mode_ok": {
                      "type": "boolean"
                    },
                    "engine_identity": {
                      "enum": [
                        "ok",
                        "error"
                      ],
                      "type": "string"
                    },
                    "hash_mode": {
                      "enum": [
                        "enforce",
                        "log",
                        "off"
                      ],
                      "type": "string"
                    },
                    "ready": {
                      "const": false,
                      "type": "boolean"
                    },
                    "status": {
                      "const": "not_ready",
                      "type": "string"
                    },
                    "timestamp": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "status",
                    "ready",
                    "database",
                    "cache",
                    "engine_identity",
                    "hash_mode",
                    "engine_hash_mode_ok",
                    "timestamp"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "A required dependency or engine identity configuration is not ready."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [],
        "summary": "Readiness probe (dependencies and engine mode)",
        "tags": [
          "health"
        ]
      }
    },
    "/api/keys": {
      "get": {
        "description": "Lists non-deleted API-key resources and recently revoked keys that remain within the three-day restore window. A revoked key includes its key prefix and restorable_until timestamp; it does not include a revoked_at field or plaintext key material. Requires `keys.read` and `api-keys.read`.",
        "operationId": "dashboardKeysList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_keys": {
                      "items": {
                        "$ref": "#/components/schemas/ApiKeyResourceC6b"
                      },
                      "type": "array"
                    },
                    "revoked_keys": {
                      "items": {
                        "allOf": [
                          {
                            "$ref": "#/components/schemas/ApiKeyResourceC6b"
                          },
                          {
                            "properties": {
                              "restorable_until": {
                                "description": "Time when the three-day restore window ends.",
                                "format": "date-time",
                                "type": "string"
                              }
                            },
                            "required": [
                              "restorable_until"
                            ],
                            "type": "object"
                          }
                        ]
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "api_keys",
                    "revoked_keys"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Non-deleted API keys and keys revoked within the three-day restore window that were not rotated out. Key resources include a prefix and never plaintext key material."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List dashboard API keys",
        "tags": [
          "api-keys"
        ]
      },
      "post": {
        "description": "Creates a key for the authenticated account. Requires `keys.write` and `api-keys.create`; the plaintext appears only once in `api_key.key`. A reuse response returns an existing active key resource with `reused: true` and no plaintext. A newly created key is otherwise returned as an API-key resource. Key-limit, validation, or privacy-floor failures return 422.",
        "operationId": "dashboardKeysCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "name": "CI key",
                  "permissions": [
                    "messages",
                    "completions"
                  ],
                  "rate_limit_rpm": 60
                },
                "properties": {
                  "allowed_ips": {
                    "description": "Optional IPv4/IPv6 addresses or CIDR ranges.",
                    "items": {
                      "description": "Valid IPv4/IPv6 address with optional CIDR prefix.",
                      "type": "string"
                    },
                    "maxItems": 50,
                    "type": "array"
                  },
                  "detector_overrides": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "name": {
                    "description": "Required key label containing non-whitespace characters, 1–100 characters. Duplicate labels are allowed.",
                    "maxLength": 100,
                    "minLength": 1,
                    "type": "string"
                  },
                  "permissions": {
                    "description": "Optional non-empty list of supported scopes; omitted values use the default scopes.",
                    "items": {
                      "enum": [
                        "messages",
                        "completions",
                        "buffer"
                      ],
                      "type": "string"
                    },
                    "minItems": 1,
                    "type": "array"
                  },
                  "privacy_tier_override": {
                    "$ref": "#/components/schemas/PrivacyMode"
                  },
                  "rate_limit_rpm": {
                    "maximum": 600,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "expires_at": {
                    "description": "Optional date after today.",
                    "format": "date",
                    "type": "string"
                  },
                  "transparency_log_opt_in": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "name"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "$ref": "#/components/schemas/ApiKeyResourceC6b"
                    },
                    "reused": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "api_key",
                    "reused"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "An existing active key was returned; no plaintext key is included."
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ApiKeyResourceC6b"
                        },
                        {
                          "properties": {
                            "key": {
                              "type": "string",
                              "writeOnly": true
                            }
                          },
                          "required": [
                            "key"
                          ],
                          "type": "object"
                        }
                      ]
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "api_key",
                    "warning"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "API key created; plaintext is included once in api_key.key."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "description": "Validation, active-key-limit, or privacy-floor check failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create a dashboard API key",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/keys/reveal/{jti}": {
      "get": {
        "description": "Returns the one-time plaintext for the authenticated account’s newly created default key. The 32-character hexadecimal JTI is consumed atomically. Invalid JTI returns 400; missing, expired, or already used JTI returns 404.",
        "operationId": "dashboardKeysReveal",
        "parameters": [
          {
            "in": "path",
            "name": "jti",
            "required": true,
            "schema": {
              "maxLength": 32,
              "minLength": 32,
              "pattern": "^[0-9a-f]{32}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "plaintext": {
                      "type": "string",
                      "writeOnly": true
                    }
                  },
                  "required": [
                    "plaintext"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "One-time plaintext returned."
          },
          "400": {
            "description": "Invalid JTI format.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated caller lacks required permission or ability.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "JTI is missing, expired, already used, or belongs to another user.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Reveal a newly created default API key once",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/keys/{id}": {
      "delete": {
        "description": "Revokes a key owned by the authenticated account. Requires `keys.write` and `api-keys.revoke`. The soft-deleted key is not returned; a missing or other-account key is 404.",
        "operationId": "dashboardKeysDelete",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "const": "API key revoked.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Key revoked."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "500": {
            "description": "Revocation failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete a dashboard API key",
        "tags": [
          "api-keys"
        ]
      },
      "get": {
        "description": "Returns one API-key resource owned by the authenticated account. Requires `keys.read` and `api-keys.read`; plaintext is not returned. A missing or other-account ID returns 404.",
        "operationId": "dashboardKeysShow",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "$ref": "#/components/schemas/ApiKeyResourceC6b"
                    }
                  },
                  "required": [
                    "api_key"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "API key resource owned by the authenticated account, without plaintext token."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get a specific dashboard API key",
        "tags": [
          "api-keys"
        ]
      },
      "parameters": [
        {
          "in": "path",
          "name": "id",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "patch": {
        "description": "PATCH alias of PUT for selected settings on a key owned by the authenticated account. Requires `keys.write` and `api-keys.create`.",
        "operationId": "dashboardKeysPatch",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "is_active": true
                },
                "properties": {
                  "allowed_ips": {
                    "items": {
                      "description": "Valid IPv4/IPv6 address with optional CIDR prefix.",
                      "type": "string"
                    },
                    "maxItems": 50,
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "rate_limit_rpm": {
                    "maximum": 600,
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "$ref": "#/components/schemas/ApiKeyResourceC6b"
                    }
                  },
                  "required": [
                    "api_key"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Selected key settings updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "description": "One or more key settings failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Partially update a dashboard API key",
        "tags": [
          "api-keys"
        ]
      },
      "put": {
        "description": "Updates selected settings on a key owned by the authenticated account. Requires `keys.write` and the route's `api-keys.create` permission. The body may set name, active state, rate limit, or IP allowlist; `allowed_ips: null` clears the allowlist. An empty object is a valid no-op.",
        "operationId": "dashboardKeysUpdate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "is_active": true
                },
                "properties": {
                  "allowed_ips": {
                    "items": {
                      "description": "Valid IPv4/IPv6 address with optional CIDR prefix.",
                      "type": "string"
                    },
                    "maxItems": 50,
                    "type": [
                      "array",
                      "null"
                    ]
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "rate_limit_rpm": {
                    "maximum": 600,
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "$ref": "#/components/schemas/ApiKeyResourceC6b"
                    }
                  },
                  "required": [
                    "api_key"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Selected key settings updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "description": "One or more key settings failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update a dashboard API key",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/keys/{id}/restore": {
      "post": {
        "description": "Restores a recently revoked key owned by the authenticated account and reactivates it. The three-day restore window is reported as `restorable_until` by GET `/api/keys`; after it ends this operation returns 410 with `error.code=window_closed`. Requires `keys.write` and `api-keys.revoke`.",
        "operationId": "dashboardKeysRestore",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "$ref": "#/components/schemas/ApiKeyResourceC6b"
                    },
                    "message": {
                      "const": "API key restored. It can sign calls again.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "api_key",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The key was restored and reactivated."
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Authenticated caller lacks required permission or ability.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "No revoked key with that ID is available in the recovery window.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "const": "not_found",
                          "type": "string"
                        },
                        "message": {
                          "const": "No revoked key with that id in the recovery window.",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "410": {
            "description": "The three-day restore window has ended; error.code is window_closed.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "const": "window_closed",
                          "type": "string"
                        },
                        "message": {
                          "const": "The 3-day recovery window for this key has closed.",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "The privacy floor would be violated or the account already has the maximum of ten active API keys.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Restore a recently revoked dashboard API key",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/keys/{id}/rotate": {
      "post": {
        "description": "Atomically creates a replacement for a key owned by the authenticated account and deactivates the old key. Requires `keys.write` and `api-keys.rotate`; the new plaintext is returned once. Transaction failure returns 500 and a missing or other-account key returns 404.",
        "operationId": "dashboardKeysRotate",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/ApiKeyResourceC6b"
                        },
                        {
                          "properties": {
                            "key": {
                              "type": "string",
                              "writeOnly": true
                            }
                          },
                          "required": [
                            "key"
                          ],
                          "type": "object"
                        }
                      ]
                    },
                    "rotated_from": {
                      "type": "integer"
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "api_key",
                    "rotated_from",
                    "warning"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Replacement key created; plaintext is returned once and the old key is deactivated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "500": {
            "description": "Rotation transaction failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Rotate a dashboard API key (revoke old, issue new)",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/onboarding/complete": {
      "post": {
        "description": "Marks the authenticated account's onboarding as complete at step seven. Repeated calls are safe and return the completion timestamp.",
        "operationId": "onboardingComplete",
        "responses": {
          "200": {
            "description": "Onboarding complete"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Finalise onboarding",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/generate-api-key": {
      "post": {
        "description": "Creates a default API key only when the account has none. A newly created plaintext token is returned once; if a default key already exists, the response contains only its ID and masked prefix. Both branches return HTTP 200.",
        "operationId": "onboardingGenerateApiKey",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "already_generated": {
                      "type": "boolean"
                    },
                    "key_id": {
                      "type": "integer"
                    },
                    "key_prefix": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "plaintext": {
                      "description": "Present only when a new key is created; shown once.",
                      "type": "string",
                      "writeOnly": true
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Default key created, or an existing default key was reported without its plaintext."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Generate the first CloakAPI key during onboarding",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/generate-pairing-url": {
      "post": {
        "description": "Creates a single-use `cloakapi://` pairing URL for the authenticated account, valid for 15 minutes. `region` defaults to `eu-central` and accepts `us-east`, `eu-central`, or `us-gov`.",
        "operationId": "onboardingGeneratePairingUrl",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "pairing_url": {
                      "format": "uri",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Pairing URL"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Generate a desktop pairing URL",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/skip": {
      "post": {
        "description": "Marks the authenticated account's onboarding as skipped and returns `{skipped: true}` with HTTP 200. The controller does not delete onboarding progress.",
        "operationId": "onboardingSkip",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "skipped": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "skipped"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Onboarding marked skipped."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Skip onboarding entirely",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/state": {
      "get": {
        "description": "Returns the authenticated account's onboarding step, segment, skipped/completed flags and timestamps, plus the current total step count of seven.",
        "operationId": "onboardingState",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "completed": {
                      "type": "boolean"
                    },
                    "completed_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "segment": {
                      "type": "string"
                    },
                    "skipped": {
                      "type": "boolean"
                    },
                    "skipped_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "step": {
                      "type": "integer"
                    },
                    "total_steps": {
                      "const": 7,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "step",
                    "segment",
                    "skipped",
                    "completed",
                    "skipped_at",
                    "completed_at",
                    "total_steps"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Current onboarding step and completion state."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get current onboarding state",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/step/{n}/complete": {
      "post": {
        "description": "Marks a step from 1 through 7 complete when it is the current step or the next step. Invalid numbers and attempts to skip ahead return 422.",
        "operationId": "onboardingCompleteStep",
        "parameters": [
          {
            "in": "path",
            "name": "n",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "completed": {
                      "type": "boolean"
                    },
                    "next_step": {
                      "maximum": 7,
                      "minimum": 2,
                      "type": "integer"
                    },
                    "step": {
                      "maximum": 7,
                      "minimum": 1,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "step",
                    "next_step",
                    "completed"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Step progress updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid step or attempt to skip ahead.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Mark an onboarding step complete",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/onboarding/validate-provider": {
      "post": {
        "description": "Makes a lightweight validation call for an OpenAI or Anthropic API key of at least 20 characters. Returns `{valid: true}` on success; invalid keys or a failed validation call return `{valid: false}` with 422. The key is not included in logs or the response.",
        "operationId": "onboardingValidateProvider",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "api_key": {
                    "type": "string"
                  },
                  "provider": {
                    "type": "string"
                  }
                },
                "required": [
                  "provider",
                  "api_key"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "provider": {
                      "enum": [
                        "openai",
                        "anthropic"
                      ],
                      "type": "string"
                    },
                    "valid": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "valid",
                    "provider"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Provider key validated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "valid": {
                      "const": false,
                      "type": "boolean"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Key is invalid, input validation failed, or provider validation call failed."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Validate a provider API key during onboarding",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/providers": {
      "get": {
        "description": "Returns the active offered-provider catalogue for the authenticated user. A key is connected only after a successful provider verification; saved, active, and rejected status are separate. Provider-key secrets are not part of this response.",
        "operationId": "providersIndex",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "markup_pct": {
                      "type": "number"
                    },
                    "mode": {
                      "const": "cloakapi_keys",
                      "type": "string"
                    },
                    "providers": {
                      "items": {
                        "properties": {
                          "connected": {
                            "type": "boolean",
                            "description": "True only when the saved user key has a successful provider verification."
                          },
                          "last_verified_at": {
                            "format": "date-time",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "markup_pct": {
                            "type": "number"
                          },
                          "masked_key": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "models": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "name": {
                            "type": "string"
                          },
                          "pricing": {
                            "additionalProperties": {
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                }
                              },
                              "type": "object"
                            },
                            "type": "object"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "saved": {
                            "type": "boolean",
                            "description": "Whether a key row is saved, including a rejected key."
                          },
                          "byok_active": {
                            "type": "boolean",
                            "description": "Whether a saved user key is currently selected for routing."
                          },
                          "verification_status": {
                            "enum": [
                              "not_connected",
                              "verified",
                              "not_verified",
                              "rejected"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "slug",
                          "name",
                          "models",
                          "connected",
                          "masked_key",
                          "last_verified_at",
                          "markup_pct",
                          "pricing",
                          "saved",
                          "byok_active",
                          "verification_status"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "providers",
                    "mode",
                    "markup_pct"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Offered provider catalogue, connected-key metadata, model pricing, mode, and configured markup field."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "503": {
            "description": "Provider availability could not be loaded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "type": {
                          "const": "server_error",
                          "type": "string"
                        },
                        "code": {
                          "const": "provider_lookup_unavailable",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List supported providers and connection status",
        "tags": [
          "providers"
        ]
      }
    },
    "/api/providers/{provider}/key": {
      "delete": {
        "description": "Removes the authenticated user's saved provider key. Requires `byok.write` and `org.settings-write`. A syntactically valid slug with no saved key is an idempotent success; a malformed slug returns 422.",
        "operationId": "providersDeleteKey",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "const": "Provider key removed.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Provider key removed; a missing saved key is still a successful no-op."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Provider slug is malformed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete saved provider API key",
        "tags": [
          "providers"
        ]
      },
      "parameters": [
        {
          "in": "path",
          "name": "provider",
          "required": true,
          "schema": {
            "type": "string"
          }
        }
      ],
      "post": {
        "description": "Validates a submitted key with a read-only provider request when an endpoint is supported, then stores it encrypted. A rejected key returns provider_key_rejected without replacing the saved row. Network failure or an unsupported endpoint stores the key as not verified. The response never echoes the submitted key.",
        "operationId": "providersSaveKey",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "api_key": {
                    "format": "password",
                    "type": "string"
                  }
                },
                "required": [
                  "api_key"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "active": {
                      "const": true,
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "provider": {
                      "type": "string"
                    },
                    "verification_status": {
                      "enum": [
                        "verified",
                        "not_verified"
                      ],
                      "type": "string"
                    },
                    "verification_reason": {
                      "enum": [
                        "accepted",
                        "unavailable",
                        "unsupported"
                      ],
                      "type": "string"
                    },
                    "verification_message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message",
                    "provider",
                    "active",
                    "verification_status",
                    "verification_reason",
                    "verification_message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Provider key saved; verification status reflects the provider response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Malformed input, unknown provider, or provider rejected the key (provider_key_rejected).",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/GenericError"
                    },
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "object",
                          "properties": {
                            "type": {
                              "const": "provider_key_error",
                              "type": "string"
                            },
                            "code": {
                              "const": "provider_key_rejected",
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "type",
                            "code",
                            "message"
                          ]
                        }
                      },
                      "required": [
                        "error"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Save BYOK provider API key",
        "tags": [
          "providers"
        ]
      }
    },
    "/api/receipt/chain-status": {
      "get": {
        "description": "Returns the cached receipt-chain status derived from the latest client-submitted chain claim. The gateway does not independently verify the client's chain; a result may remain `never_verified` until a claim is submitted. The route accepts an API key or Sanctum bearer and caches the result for five minutes.",
        "operationId": "receiptChainStatus",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "active_key_fingerprint": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "break_detected_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "chain_ok": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "entries_verified": {
                      "type": "integer"
                    },
                    "last_verified_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "verification_state": {
                      "enum": [
                        "never_verified",
                        "client_claimed",
                        "verified",
                        "break_detected"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "chain_ok",
                    "verification_state",
                    "last_verified_at",
                    "break_detected_at",
                    "entries_verified",
                    "active_key_fingerprint"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Cached receipt-chain state based on the latest client claim; the gateway does not verify the chain."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid API key or bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Get receipt chain health status",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/receipt/chain-verify": {
      "post": {
        "description": "Records the caller's reported chain result and invalidates the cached status. This is a client claim, not gateway verification; the response echoes the submitted `chain_ok` value and does not attest that the claim is true.",
        "operationId": "submitChainClaim",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "break_detected_at": null,
                  "chain_ok": true,
                  "entries_verified": 42
                },
                "properties": {
                  "break_detected_at": {
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "chain_ok": {
                    "type": "boolean"
                  },
                  "entries_verified": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "chain_ok",
                  "entries_verified"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "chain_ok": {
                      "type": "boolean"
                    },
                    "recorded": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "recorded",
                    "chain_ok"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Client claim recorded."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid API key or bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Claim fields failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Verify a receipt chain segment",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/receipts/since/{timestamp}": {
      "get": {
        "description": "Returns JSON usage-record metadata for the authenticated user at or after the path timestamp. The timestamp may be ISO 8601 or Unix seconds; `page_size` defaults to 100 and is capped at 1,000, with `cursor` for the next page. The response contains usage metadata, not prompt or completion content; invalid timestamps return 400.",
        "operationId": "receiptsTailSince",
        "parameters": [
          {
            "description": "ISO 8601 timestamp or Unix epoch seconds.",
            "in": "path",
            "name": "timestamp",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "cursor",
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "page_size",
            "schema": {
              "default": 100,
              "maximum": 1000,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "count": {
                      "type": "integer"
                    },
                    "data": {
                      "items": {
                        "properties": {
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "id": {
                            "type": "integer"
                          },
                          "input_tokens": {
                            "type": "integer"
                          },
                          "markup_cents": {
                            "type": "integer"
                          },
                          "model": {
                            "type": "string"
                          },
                          "output_tokens": {
                            "type": "integer"
                          },
                          "provider_cost_cents": {
                            "type": "integer"
                          },
                          "request_id": {
                            "type": "string"
                          },
                          "total_cost_cents": {
                            "type": "integer"
                          },
                          "was_buffered": {
                            "type": "boolean"
                          },
                          "was_streamed": {
                            "type": "boolean"
                          },
                          "was_tokenized": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "request_id",
                          "model",
                          "input_tokens",
                          "output_tokens",
                          "provider_cost_cents",
                          "markup_cents",
                          "total_cost_cents",
                          "was_tokenized",
                          "was_streamed",
                          "was_buffered",
                          "created_at"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "has_more": {
                      "type": "boolean"
                    },
                    "next_cursor": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "object": {
                      "const": "list",
                      "type": "string"
                    },
                    "since": {
                      "format": "date-time",
                      "type": "string"
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "has_more",
                    "next_cursor",
                    "since",
                    "count"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Paginated JSON usage metadata; contains no prompt or completion content."
          },
          "400": {
            "description": "Timestamp could not be parsed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid cursor or page_size query value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The 30-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Stream receipts since a given timestamp (tail)",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/recommend": {
      "post": {
        "description": "Returns CloakAPI editorial provider defaults for the requested use case, priority, and optional ISO 639-1 language. Scores and ordering are editorial choices, not measurements of provider quality, latency, price, or privacy. This is a recommendation response, not a provider-routing call; invalid enum values or a malformed language code return 422.",
        "operationId": "providersRecommend",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "language": "en",
                  "priority": "quality",
                  "use_case": "code_generation"
                },
                "properties": {
                  "language": {
                    "maxLength": 2,
                    "minLength": 2,
                    "pattern": "^[A-Za-z]{2}$",
                    "type": "string"
                  },
                  "priority": {
                    "enum": [
                      "quality",
                      "speed",
                      "cost",
                      "privacy",
                      "language"
                    ],
                    "type": "string"
                  },
                  "use_case": {
                    "enum": [
                      "long_docs",
                      "code_generation",
                      "creative_writing",
                      "realtime",
                      "privacy",
                      "cost",
                      "norwegian",
                      "general"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "use_case",
                  "priority"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ordering_basis": {
                      "description": "Basis for the editorial ordering of providers.",
                      "enum": [
                        "editorial_matrix_v1"
                      ],
                      "type": "string"
                    },
                    "providers": {
                      "items": {
                        "properties": {
                          "caveats": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "editorial_score": {
                            "description": "Editorial default score; not a measured provider result.",
                            "maximum": 100,
                            "minimum": 0,
                            "type": "integer"
                          },
                          "name": {
                            "type": "string"
                          },
                          "reason": {
                            "type": "string"
                          },
                          "recommended_model": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "score": {
                            "description": "Backward-compatible v1 alias for editorial_score.",
                            "maximum": 100,
                            "minimum": 0,
                            "type": "integer"
                          },
                          "score_basis": {
                            "description": "Basis for the editorial score.",
                            "enum": [
                              "editorial_matrix_v1"
                            ],
                            "type": "string"
                          },
                          "slug": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "slug",
                          "name",
                          "recommended_model",
                          "score",
                          "editorial_score",
                          "score_basis",
                          "reason",
                          "caveats"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "use_case": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "providers",
                    "use_case",
                    "ordering_basis"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Editorial provider recommendations; scores and order are not measured results."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid use case, priority, or language.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Recommend a provider/model for a use-case",
        "tags": [
          "providers"
        ]
      }
    },
    "/api/scim/v2/Groups": {
      "get": {
        "description": "Lists groups for the tenant identified by the SCIM bearer token. Returns a SCIM ListResponse with startIndex set to 1 and one resource per group.",
        "operationId": "scimListGroups",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "Resources": {
                      "items": {
                        "$ref": "#/components/schemas/ScimGroupResource"
                      },
                      "type": "array"
                    },
                    "itemsPerPage": {
                      "minimum": 0,
                      "type": "integer"
                    },
                    "schemas": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "startIndex": {
                      "const": 1,
                      "type": "integer"
                    },
                    "totalResults": {
                      "minimum": 0,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "schemas",
                    "totalResults",
                    "startIndex",
                    "itemsPerPage",
                    "Resources"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "SCIM group list"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "List SCIM groups",
        "tags": [
          "scim"
        ]
      },
      "post": {
        "description": "Creates a group for the tenant identified by the SCIM bearer token. displayName is required and limited to 255 characters; externalId is optional and limited to 255 characters; mappedRole is optional and must match a role configured by the gateway. Returns the created SCIM Group resource with HTTP 201.",
        "operationId": "scimCreateGroup",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "displayName": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "externalId": {
                    "maxLength": 255,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "mappedRole": {
                    "description": "Must match a role name in the gateway's RBAC role configuration.",
                    "maxLength": 64,
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "displayName"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroupResource"
                }
              }
            },
            "description": "Group created"
          },
          "422": {
            "description": "Invalid group fields or mappedRole.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Create SCIM group",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/Groups/{id}": {
      "delete": {
        "description": "Deletes a group belonging to the tenant identified by the SCIM bearer token. Returns an empty 204 response on deletion, or an empty 404 response when the group is not in the tenant.",
        "operationId": "scimDeleteGroup",
        "responses": {
          "204": {
            "description": "Group deleted"
          },
          "404": {
            "description": "SCIM group not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schemas": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "const": "404"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "schemas",
                    "status",
                    "detail"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "SCIM bearer token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "unauthorized"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "The SCIM token lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "scim_not_configured"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "SCIM route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Delete SCIM group",
        "tags": [
          "scim"
        ]
      },
      "get": {
        "description": "Returns a SCIM Group resource only when it belongs to the tenant identified by the SCIM bearer token; otherwise returns 404.",
        "operationId": "scimGetGroup",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroupResource"
                }
              }
            },
            "description": "SCIM group"
          },
          "404": {
            "description": "SCIM group not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schemas": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "const": "404"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "schemas",
                    "status",
                    "detail"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "SCIM bearer token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "unauthorized"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "The SCIM token lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "scim_not_configured"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "SCIM route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Get SCIM group",
        "tags": [
          "scim"
        ]
      },
      "parameters": [
        {
          "in": "path",
          "name": "id",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "patch": {
        "description": "Applies Operations entries whose path is displayName or mappedRole to a group in the token's tenant. Other paths are ignored. The handler does not validate the request body; it defaults a missing Operations list to an empty list. Returns 404 when the group is not in the tenant.",
        "operationId": "scimPatchGroup",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "Operations": {
                    "items": {
                      "properties": {
                        "op": {
                          "type": "string"
                        },
                        "path": {
                          "description": "Supported paths are displayName and mappedRole; other paths are ignored.",
                          "type": "string"
                        },
                        "value": {
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "type": "object"
                    },
                    "type": "array"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroupResource"
                }
              }
            },
            "description": "Group patched"
          },
          "404": {
            "description": "SCIM group not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schemas": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "const": "404"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "schemas",
                    "status",
                    "detail"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "SCIM bearer token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "unauthorized"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "The SCIM token lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "scim_not_configured"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "SCIM route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Patch SCIM group",
        "tags": [
          "scim"
        ]
      },
      "put": {
        "description": "Replaces displayName and mappedRole for a group in the token's tenant. displayName is required and limited to 255 characters; mappedRole is optional and limited to 64 characters. Returns 404 when the group is not in the tenant.",
        "operationId": "scimReplaceGroup",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "displayName": {
                    "maxLength": 255,
                    "minLength": 1,
                    "type": "string"
                  },
                  "mappedRole": {
                    "maxLength": 64,
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "required": [
                  "displayName"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimGroupResource"
                }
              }
            },
            "description": "Group replaced"
          },
          "404": {
            "description": "SCIM group not found.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "schemas": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "status": {
                      "type": "string",
                      "const": "404"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "schemas",
                    "status",
                    "detail"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "Invalid group fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "SCIM bearer token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "unauthorized"
                    },
                    "detail": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "403": {
            "description": "The SCIM token lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "scim_not_configured"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "429": {
            "description": "SCIM route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Replace SCIM group",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/ResourceTypes": {
      "get": {
        "description": "Returns the two resource types implemented here — User and Group — with their collection endpoints and core schema URNs. Requires a valid SCIM bearer token.",
        "operationId": "scimResourceTypes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "Resources": {
                      "items": {
                        "properties": {
                          "endpoint": {
                            "enum": [
                              "/Users",
                              "/Groups"
                            ],
                            "type": "string"
                          },
                          "id": {
                            "enum": [
                              "User",
                              "Group"
                            ],
                            "type": "string"
                          },
                          "name": {
                            "enum": [
                              "User",
                              "Group"
                            ],
                            "type": "string"
                          },
                          "schema": {
                            "type": "string"
                          },
                          "schemas": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          }
                        },
                        "required": [
                          "schemas",
                          "id",
                          "name",
                          "endpoint",
                          "schema"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "schemas": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "totalResults": {
                      "const": 2,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "schemas",
                    "totalResults",
                    "Resources"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Resource types"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "SCIM resource types discovery",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/Schemas": {
      "get": {
        "description": "Returns the core SCIM User and Group schema identifiers implemented by this service. Requires a valid SCIM bearer token.",
        "operationId": "scimSchemas",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "Resources": {
                      "items": {
                        "properties": {
                          "id": {
                            "type": "string"
                          },
                          "name": {
                            "enum": [
                              "User",
                              "Group"
                            ],
                            "type": "string"
                          }
                        },
                        "required": [
                          "id",
                          "name"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "schemas": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "totalResults": {
                      "const": 2,
                      "type": "integer"
                    }
                  },
                  "required": [
                    "schemas",
                    "totalResults",
                    "Resources"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Schemas"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "SCIM schemas discovery",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/ServiceProviderConfig": {
      "get": {
        "description": "Returns the public SCIM ServiceProviderConfig document. Feature support and the maximum filter result count come from SCIM configuration; change-password, sort, and ETag support are reported as disabled.",
        "operationId": "scimServiceProviderConfig",
        "responses": {
          "200": {
            "content": {
              "application/scim+json": {
                "schema": {
                  "type": "object"
                }
              }
            },
            "description": "SCIM service provider configuration"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "SCIM Service Provider Config (unauthenticated)",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/Users": {
      "get": {
        "description": "Lists users within the organisation bound to the SCIM bearer token. The optional filter handler recognizes `userName eq \"email\"`; other filter expressions are not applied. `startIndex` is one-based and `count` is bounded by configured pagination limits.",
        "operationId": "scimListUsers",
        "parameters": [
          {
            "in": "query",
            "name": "filter",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "startIndex",
            "schema": {
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "count",
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "SCIM user list"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid SCIM bearer credentials."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The SCIM integration is not configured."
          },
          "400": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "List SCIM users",
        "tags": [
          "scim"
        ]
      },
      "post": {
        "description": "Creates a SCIM User in the organisation bound to the SCIM bearer token. `userName` must be an email; supported fields include name, active, emails, and billing extension values. Existing users return 409 and validation or billing-gate failures return 422.",
        "operationId": "scimCreateUser",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "billing_country": {
                    "maxLength": 2,
                    "minLength": 2,
                    "pattern": "^[A-Za-z]{2}$",
                    "type": "string"
                  },
                  "billing_currency": {
                    "maxLength": 3,
                    "minLength": 3,
                    "pattern": "^[A-Za-z]{3}$",
                    "type": "string"
                  },
                  "billing_vat_id": {
                    "maxLength": 32,
                    "type": "string"
                  },
                  "emails": {
                    "items": {
                      "properties": {
                        "value": {
                          "format": "email",
                          "type": "string"
                        }
                      },
                      "type": "object"
                    },
                    "type": "array"
                  },
                  "name": {
                    "properties": {
                      "familyName": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "formatted": {
                        "maxLength": 255,
                        "type": "string"
                      },
                      "givenName": {
                        "maxLength": 128,
                        "type": "string"
                      }
                    },
                    "type": "object"
                  },
                  "userName": {
                    "format": "email",
                    "type": "string"
                  }
                },
                "required": [
                  "userName"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUserResource"
                }
              }
            },
            "description": "SCIM User created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid SCIM bearer credentials."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The SCIM integration is not configured."
          },
          "409": {
            "description": "User already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation or billing-gate failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Create SCIM user",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/scim/v2/Users/{id}": {
      "delete": {
        "description": "Deletes the SCIM user only when it belongs to the organisation identified by the SCIM bearer token. Success returns an empty 204; a missing or out-of-scope user returns an empty 404.",
        "operationId": "scimDeleteUser",
        "responses": {
          "204": {
            "description": "User deleted; response body is empty."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid SCIM bearer credentials."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The SCIM integration is not configured."
          },
          "404": {
            "description": "User was not found in the token's tenant; response body is empty.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Delete SCIM user",
        "tags": [
          "scim"
        ]
      },
      "get": {
        "description": "Returns a SCIM User resource only when the numeric user ID belongs to the organisation bound to the SCIM bearer token. A missing or out-of-scope user returns SCIM 404.",
        "operationId": "scimGetUser",
        "responses": {
          "200": {
            "description": "SCIM user"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid SCIM bearer credentials."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The SCIM integration is not configured."
          },
          "404": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Get SCIM user by ID",
        "tags": [
          "scim"
        ]
      },
      "parameters": [
        {
          "in": "path",
          "name": "id",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "patch": {
        "description": "Applies SCIM PatchOp Operations to a user belonging to the SCIM token's tenant. The request requires a schemas array and at least one Operations entry; each entry must be an object. The service handles the individual operations. Returns the updated user or 404 when the user is outside the tenant or does not exist.",
        "operationId": "scimPatchUser",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "Operations": {
                    "items": {
                      "type": "object"
                    },
                    "minItems": 1,
                    "type": "array"
                  },
                  "schemas": {
                    "items": {
                      "type": "string"
                    },
                    "type": "array"
                  }
                },
                "required": [
                  "schemas",
                  "Operations"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUserResource"
                }
              }
            },
            "description": "User patched"
          },
          "404": {
            "description": "User was not found in the token's tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid PatchOp request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Patch SCIM user (partial update / deactivation)",
        "tags": [
          "scim"
        ]
      },
      "put": {
        "description": "Replaces supported SCIM User fields for a user in the organisation bound to the SCIM bearer token. `userName` is required; missing/out-of-scope users return 404 and invalid fields return 422.",
        "operationId": "scimReplaceUser",
        "requestBody": {
          "content": {
            "application/scim+json": {
              "schema": {
                "properties": {
                  "active": {
                    "type": "boolean"
                  },
                  "billing_country": {
                    "maxLength": 2,
                    "minLength": 2,
                    "pattern": "^[A-Za-z]{2}$",
                    "type": "string"
                  },
                  "billing_currency": {
                    "maxLength": 3,
                    "minLength": 3,
                    "pattern": "^[A-Za-z]{3}$",
                    "type": "string"
                  },
                  "billing_vat_id": {
                    "maxLength": 32,
                    "type": "string"
                  },
                  "name": {
                    "properties": {
                      "familyName": {
                        "maxLength": 128,
                        "type": "string"
                      },
                      "formatted": {
                        "maxLength": 255,
                        "type": "string"
                      },
                      "givenName": {
                        "maxLength": 128,
                        "type": "string"
                      }
                    },
                    "type": "object"
                  },
                  "userName": {
                    "format": "email",
                    "type": "string"
                  }
                },
                "required": [
                  "userName"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ScimUserResource"
                }
              }
            },
            "description": "SCIM User replaced."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid SCIM bearer credentials."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The SCIM integration is not configured."
          },
          "404": {
            "description": "User was not found in the token's tenant.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ScimToken": []
          }
        ],
        "summary": "Replace SCIM user",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/slo": {
      "get": {
        "description": "Returns the same cached 30-day availability and latency snapshot as the root status endpoint. The response is cached for up to 60 seconds; fields without a valid measurement can be null.",
        "operationId": "sloApi",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SloMetricsResponse"
                }
              }
            },
            "description": "SLO metrics"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "SLO metrics snapshot",
        "tags": [
          "metrics"
        ]
      }
    },
    "/api/sso/config": {
      "get": {
        "description": "Returns the authenticated tenant administrator's SSO configuration metadata. The response reports whether an OIDC client secret is set but never returns the secret value. OIDC ID tokens require the Boolean email_verified=true claim unless this caller-scoped setting is enabled; it never permits a present false or non-boolean claim. When an ID token omits email_verified and this exception is enabled, its issuer and subject are bound to the first account; an unbound subject cannot use an existing email, and later email changes for a bound subject are rejected. Tokens with Boolean email_verified=true keep the verified-email path for first account linking; later logins remain bound to that issuer and subject.",
        "operationId": "ssoGetConfig",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "accept_signins_without_email_verified": {
                      "default": false,
                      "description": "Defaults to false. When true, only an absent email_verified claim is accepted; a present false or non-boolean value is always rejected. For tokens with a missing claim, issuer and subject are bound to the first account; an unbound subject cannot use an existing email, and later email changes for a bound subject are rejected. Tokens with Boolean email_verified=true keep the verified-email path for first account linking; later logins remain bound to that issuer and subject. Microsoft Entra ID usually omits this claim, so enable the exception only if the provider confirms it verifies email addresses.",
                      "type": "boolean"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "idp_entity_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "idp_sso_url": {
                      "format": "uri",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "last_login_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "oidc_client_id": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "oidc_discovery_url": {
                      "format": "uri",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "oidc_redirect_uri": {
                      "format": "uri",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "oidc_secret_set": {
                      "type": "boolean"
                    },
                    "protocol": {
                      "enum": [
                        "saml",
                        "oidc"
                      ],
                      "type": "string"
                    },
                    "scim_enabled": {
                      "type": "boolean"
                    },
                    "sso_configured": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "sso_configured",
                    "accept_signins_without_email_verified"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "SSO metadata; OIDC client secret is never returned."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get SSO configuration for tenant",
        "tags": [
          "sso"
        ]
      },
      "put": {
        "description": "Creates or updates the authenticated tenant's SSO configuration; the route requires a verified owner/admin bearer with the write ability and sso.config-write permission. Protocol, IdP/OIDC metadata, and SCIM settings are validated, and outbound URLs are checked before storage. The client secret is write-only and is never returned; unsafe or invalid fields return 422.",
        "operationId": "ssoPutConfig",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "accept_signins_without_email_verified": {
                    "description": "Per-IdP exception. On creation, omission defaults to false. On update, omission leaves the existing value unchanged. When true, a missing email_verified claim is accepted, but a present false or non-boolean value is rejected. For tokens with a missing claim, issuer and subject are bound to the first account; an unbound subject cannot use an existing email, and later email changes for a bound subject are rejected. Tokens with Boolean email_verified=true keep the verified-email path for first account linking; later logins remain bound to that issuer and subject. Enable only if the provider confirms it verifies email addresses.",
                    "type": "boolean"
                  },
                  "attribute_map": {
                    "type": [
                      "object",
                      "null"
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "idp_certificate": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "idp_entity_id": {
                    "maxLength": 512,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "idp_slo_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "idp_sso_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "oidc_client_id": {
                    "maxLength": 512,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "oidc_client_secret": {
                    "maxLength": 2048,
                    "type": [
                      "string",
                      "null"
                    ],
                    "writeOnly": true
                  },
                  "oidc_discovery_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "oidc_redirect_uri": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "protocol": {
                    "enum": [
                      "saml",
                      "oidc"
                    ],
                    "type": "string"
                  },
                  "scim_enabled": {
                    "type": "boolean"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "accept_signins_without_email_verified": {
                      "description": "The effective per-IdP missing-claim exception value after this update.",
                      "type": "boolean"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "sso_config_id": {
                      "type": "integer"
                    },
                    "warning": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "sso_config_id",
                    "enabled",
                    "accept_signins_without_email_verified"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Updated SSO configuration ID and enabled state; an enabled SAML configuration without a certificate may include a warning."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Field validation failed or an outbound URL was rejected.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update SSO configuration",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/sso/oidc/token": {
      "post": {
        "description": "Exchanges a code using the tenant's enabled OIDC configuration and the single-use state record created by the initiate endpoint. The required code, tenant_id, redirect_uri, 32-character state and 64-character binding are form-encoded; success returns api_token, user_id and email as JSON. Validation, state, exchange and tenant-account failures return 422.",
        "operationId": "ssoOidcToken",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "properties": {
                  "binding": {
                    "description": "The one-time secret returned as `binding` by the initiate endpoint. A request without it fails validation (422 validation_error); a value that does not match the one stored with the state is rejected with 422 invalid_state and leaves the state unused.",
                    "maxLength": 64,
                    "minLength": 64,
                    "type": "string"
                  },
                  "code": {
                    "minLength": 1,
                    "type": "string"
                  },
                  "redirect_uri": {
                    "format": "uri",
                    "type": "string"
                  },
                  "state": {
                    "maxLength": 32,
                    "minLength": 32,
                    "type": "string"
                  },
                  "tenant_id": {
                    "minimum": 1,
                    "type": "integer"
                  }
                },
                "required": [
                  "code",
                  "tenant_id",
                  "redirect_uri",
                  "state",
                  "binding"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_token": {
                      "type": "string"
                    },
                    "email": {
                      "format": "email",
                      "type": "string"
                    },
                    "user_id": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "api_token",
                    "user_id",
                    "email"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token response"
          },
          "422": {
            "description": "Invalid request, state, OIDC exchange, or tenant account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "OIDC token endpoint",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/sso/saml/acs": {
      "post": {
        "description": "Accepts a form-encoded SAMLResponse and optional RelayState. The assertion is validated against the enabled tenant SSO configuration; on success the handler returns a Sanctum api_token, user_id and email as JSON. Assertion/configuration failures return 422.",
        "operationId": "ssoSamlAcs",
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "properties": {
                  "RelayState": {
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "SAMLResponse": {
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "SAMLResponse"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_token": {
                      "type": "string"
                    },
                    "email": {
                      "format": "email",
                      "type": "string"
                    },
                    "user_id": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "api_token",
                    "user_id",
                    "email"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "SAML assertion accepted and bearer token issued."
          },
          "422": {
            "description": "Invalid request, unconfigured SSO, or rejected assertion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "SAML Assertion Consumer Service",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/sso/saml/metadata": {
      "get": {
        "description": "Returns the service-provider metadata as XML. The optional `tenant_id` query value selects the entity ID path; if omitted, the shared service-provider entity ID is used.",
        "operationId": "ssoSamlMetadata",
        "parameters": [
          {
            "in": "query",
            "name": "tenant_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/samlmetadata+xml": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "SAML metadata"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "SAML SP metadata XML",
        "tags": [
          "sso"
        ]
      }
    },
    "/api/sso/scim/provision-token": {
      "post": {
        "description": "Enables SCIM for the authenticated tenant administrator and returns a new bearer token and SCIM base URL. The plaintext token is shown only in this response; the stored value is a hash.",
        "operationId": "ssoScimProvisionToken",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "note": {
                      "type": "string"
                    },
                    "scim_base_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "scim_token": {
                      "type": "string",
                      "writeOnly": true
                    }
                  },
                  "required": [
                    "scim_token",
                    "scim_base_url",
                    "note"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "SCIM enabled and bearer token issued once."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Provision a SCIM bearer token for the tenant",
        "tags": [
          "scim"
        ]
      }
    },
    "/api/updates/{target}/{arch}/{current_version}": {
      "get": {
        "description": "Returns an updater manifest when a newer matching artefact is available. Invalid target, architecture, or version values return 400; an up-to-date client or missing release returns 204; a withdrawn build returns 410. The route is limited to 60 requests per minute.",
        "operationId": "desktopUpdaterManifest",
        "parameters": [
          {
            "in": "path",
            "name": "target",
            "required": true,
            "schema": {
              "example": "windows-x86_64",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "arch",
            "required": true,
            "schema": {
              "example": "x86_64",
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "current_version",
            "required": true,
            "schema": {
              "example": "1.2.3",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "notes": {
                      "type": "string"
                    },
                    "platforms": {
                      "additionalProperties": {
                        "properties": {
                          "signature": {
                            "type": "string"
                          },
                          "url": {
                            "format": "uri",
                            "type": "string"
                          }
                        },
                        "required": [
                          "signature",
                          "url"
                        ],
                        "type": "object"
                      },
                      "type": "object"
                    },
                    "pub_date": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "version",
                    "notes",
                    "pub_date",
                    "platforms"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Tauri updater manifest for a newer matching release."
          },
          "204": {
            "description": "No matching release is available, the client is up to date, or no matching asset exists."
          },
          "400": {
            "description": "target, arch, or current_version is malformed or unsupported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "advisory_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "artefacts": {
                      "items": {
                        "properties": {
                          "filename": {
                            "type": "string"
                          },
                          "sha256": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "filename",
                          "sha256"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "const": "withdrawn",
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "status",
                    "version",
                    "artefacts",
                    "reason",
                    "advisory_url",
                    "source"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The current build is withdrawn."
          },
          "429": {
            "description": "The 60-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Tauri auto-updater manifest",
        "tags": [
          "well-known"
        ]
      }
    },
    "/api/v1/api-keys": {
      "get": {
        "description": "Lists keys owned by the authenticated account. Requires `keys.read` and `api-keys.read`. The response omits `key_hash` and plaintext key material.",
        "operationId": "v1ApiKeysList",
        "responses": {
          "200": {
            "description": "API key list without key hashes or plaintext key material"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List API keys (v1 / programmatic)",
        "tags": [
          "api-keys"
        ]
      },
      "post": {
        "description": "Creates an API key for the authenticated account. Requires `api-keys.create`; name is required and budget, expiry, and privacy-mode override are optional validated fields. The plaintext is returned once and is not stored as plaintext.",
        "operationId": "v1ApiKeysCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "budget": 10000,
                  "name": "CI key"
                },
                "properties": {
                  "budget": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "expires_at": {
                    "format": "date-time",
                    "type": "string"
                  },
                  "name": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "privacy_tier_override": {
                    "$ref": "#/components/schemas/PrivacyMode"
                  }
                },
                "required": [
                  "name"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "created_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "key_id": {
                      "type": "integer"
                    },
                    "key_prefix": {
                      "type": "string"
                    },
                    "last_four": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "plaintext": {
                      "type": "string",
                      "writeOnly": true
                    }
                  },
                  "required": [
                    "key_id",
                    "name",
                    "plaintext",
                    "key_prefix",
                    "last_four",
                    "is_active",
                    "created_at",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "API key created; plaintext is returned once."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Validation or healthtech privacy-floor check failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The account is paused because scheduled deletion is pending.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "account_deletion_scheduled",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create an API key (v1 / programmatic)",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/v1/api-keys/{id}": {
      "delete": {
        "description": "Revokes an API key owned by the authenticated account. Requires `api-keys.revoke` and returns `{deleted: true}`. A missing or out-of-scope key returns 404.",
        "operationId": "v1ApiKeysDelete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "deleted": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Key revoked."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "404": {
            "description": "Key was not found for this account.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete an API key (v1 / programmatic)",
        "tags": [
          "api-keys"
        ]
      }
    },
    "/api/v1/arbitrage/rules": {
      "get": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "GetArbitrageRules",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get rules",
        "tags": [
          "Arbitrage"
        ]
      },
      "post": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "PostArbitrageRules",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcArbitrageRuleCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArbitrageRuleValidationError"
                }
              }
            },
            "description": "The expression or provider/model target failed validation."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post rules",
        "tags": [
          "Arbitrage"
        ]
      }
    },
    "/api/v1/arbitrage/rules/reorder": {
      "post": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "PostArbitrageRulesReorder",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcArbitrageReorder"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post reorder",
        "tags": [
          "Arbitrage"
        ]
      }
    },
    "/api/v1/arbitrage/rules/{id}": {
      "delete": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "DeleteArbitrageRulesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete item",
        "tags": [
          "Arbitrage"
        ]
      },
      "get": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "GetArbitrageRulesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get item",
        "tags": [
          "Arbitrage"
        ]
      },
      "patch": {
        "description": "Read or update saved provider-routing rules for the authenticated account. Rules are stored and validated but are not applied to requests yet; requests continue to follow the account's default routing.",
        "operationId": "PatchArbitrageRulesId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcArbitrageRuleUpdate"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ArbitrageRuleValidationError"
                }
              }
            },
            "description": "The expression or provider/model target failed validation."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Patch item",
        "tags": [
          "Arbitrage"
        ]
      }
    },
    "/api/v1/audit-log": {
      "get": {
        "description": "Returns a paginated audit-log view for the authenticated user with the `audit.view` permission. Supports page, per-page, action, action prefix, date range, and legacy `since`/`until` filters. Sealed payloads are presented in the controller's tenant-scoped row shape. This list uses offset pagination ordered by `id DESC`. Keep the same filters and `per_page` value for every page. If rows are added or deleted while paging, rows can repeat or be skipped. Restart at page 1 after the list has stopped changing for a fresh traversal; this endpoint does not provide a point-in-time snapshot.",
        "operationId": "v1AuditLog",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "schema": {
              "default": 1,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "per_page",
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "action",
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "action_prefix",
            "schema": {
              "maxLength": 64,
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "description": "Legacy alias used when from is absent.",
            "in": "query",
            "name": "since",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          },
          {
            "description": "Legacy alias used when to is absent.",
            "in": "query",
            "name": "until",
            "schema": {
              "format": "date-time",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "current_page": {
                      "type": "integer"
                    },
                    "data": {
                      "items": {
                        "properties": {
                          "action": {
                            "type": "string"
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "erased": {
                            "type": "boolean"
                          },
                          "hash_version": {
                            "type": "string"
                          },
                          "id": {
                            "type": "integer"
                          },
                          "ip_address": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "meta": {
                            "additionalProperties": true,
                            "type": [
                              "object",
                              "null"
                            ]
                          },
                          "resource_external_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "resource_id": {
                            "type": [
                              "string",
                              "integer",
                              "null"
                            ]
                          },
                          "resource_type": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "result": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "retention_category": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "subject_id": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "user_agent": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "user_id": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "id",
                          "action",
                          "result",
                          "created_at",
                          "hash_version",
                          "erased"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "last_page": {
                      "type": "integer"
                    },
                    "per_page": {
                      "type": "integer"
                    },
                    "total": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "data",
                    "current_page",
                    "per_page",
                    "total",
                    "last_page"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Paginated response containing tenant-scoped audit rows; sealed v2 payloads are exposed only after tenant-scoped decryption."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "The audit-log query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Query tenant audit log",
        "tags": [
          "audit"
        ]
      }
    },
    "/api/v1/audit-log/export": {
      "get": {
        "description": "Downloads audit log entries as a CSV file.",
        "operationId": "GetAuditLogExport",
        "parameters": [
          {
            "in": "query",
            "name": "action",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "action_prefix",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "description": "An audit-log filter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET audit-log/export",
        "tags": [
          "audit-log"
        ]
      }
    },
    "/api/v1/audit-log/export-bundle": {
      "get": {
        "description": "Downloads a signed ZIP bundle containing audit.csv, a manifest, its signature, and signing instructions.",
        "operationId": "GetAuditLogExportBundle",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/zip": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An audit-log filter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET audit-log/export-bundle",
        "tags": [
          "audit-log"
        ]
      }
    },
    "/api/v1/audit-log/export-chain": {
      "get": {
        "description": "Exports the organisation's hash-linked audit rows for a date range with signed daily anchors and a signed manifest.",
        "operationId": "GetAuditLogExportChain",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsAuditChainExport"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An audit-log filter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET audit-log/export-chain",
        "tags": [
          "audit-log"
        ]
      }
    },
    "/api/v1/audit-log/export.csv": {
      "get": {
        "description": "Downloads audit log entries as a CSV file.",
        "operationId": "GetAuditLogExportCsv",
        "parameters": [
          {
            "in": "query",
            "name": "action",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "action_prefix",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An audit-log filter failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET audit-log/export.csv",
        "tags": [
          "audit-log"
        ]
      }
    },
    "/api/v1/audit/export": {
      "get": {
        "description": "Exports the organisation's hash-linked audit rows for a date range with signed daily anchors and a signed manifest.",
        "operationId": "GetAuditExport",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsAuditChainExport"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "description": "The audit export query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "unauthenticated"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The account lacks audit export permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "forbidden"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET audit/export",
        "tags": [
          "audit"
        ]
      }
    },
    "/api/v1/auth/social/exchange": {
      "post": {
        "description": "Exchanges a single-use code for a dashboard token and user resource.",
        "operationId": "privacyPostApiV1AuthSocialExchange",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "code": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "maxLength": 64,
                    "minLength": 64,
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacySocialExchange"
                }
              }
            },
            "description": "Dashboard token and user."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The exchange code is invalid, expired, or already used."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [],
        "summary": "Exchange a social sign-in code",
        "tags": [
          "Social auth"
        ]
      }
    },
    "/api/v1/auth/social/google/callback": {
      "get": {
        "description": "Consumes the provider callback and redirects to the configured return target with a one-time exchange code.",
        "operationId": "privacyGetApiV1AuthSocialGoogleCallback",
        "parameters": [
          {
            "description": "One-time OAuth state.",
            "in": "query",
            "name": "state",
            "required": false,
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          },
          {
            "description": "Authorization code returned by Google.",
            "in": "query",
            "name": "code",
            "required": false,
            "schema": {
              "maxLength": 2048,
              "type": "string"
            }
          },
          {
            "description": "Provider error when authorization was denied.",
            "in": "query",
            "name": "error",
            "required": false,
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to configured return target."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The sign-in state is invalid or expired."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "501": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Social sign-in is not configured."
          }
        },
        "security": [],
        "summary": "Handle Google sign-in callback",
        "tags": [
          "Social auth"
        ]
      },
      "post": {
        "description": "Handles a provider callback submitted as a form post.",
        "operationId": "privacyPostApiV1AuthSocialGoogleCallback",
        "parameters": [
          {
            "description": "One-time OAuth state.",
            "in": "query",
            "name": "state",
            "required": false,
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          },
          {
            "description": "Authorization code returned by Google.",
            "in": "query",
            "name": "code",
            "required": false,
            "schema": {
              "maxLength": 2048,
              "type": "string"
            }
          },
          {
            "description": "Provider error when authorization was denied.",
            "in": "query",
            "name": "error",
            "required": false,
            "schema": {
              "maxLength": 128,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "code": "example-value",
                "error": "example-value",
                "state": "example-value"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "error": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "302": {
            "description": "Redirect to configured return target."
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The sign-in state is invalid or expired."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "501": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Social sign-in is not configured."
          }
        },
        "security": [],
        "summary": "Handle Google sign-in callback (form post)",
        "tags": [
          "Social auth"
        ]
      }
    },
    "/api/v1/auth/social/google/redirect": {
      "get": {
        "description": "Creates a sign-in state and redirects to Google, or returns an authorization URL when JSON is requested.",
        "operationId": "privacyGetApiV1AuthSocialGoogleRedirect",
        "parameters": [
          {
            "description": "Allowlisted portal return URL.",
            "in": "query",
            "name": "return_to",
            "required": false,
            "schema": {
              "format": "uri",
              "type": "string"
            }
          },
          {
            "description": "Portal authentication intent.",
            "in": "query",
            "name": "intent",
            "required": false,
            "schema": {
              "enum": [
                "signin",
                "signup"
              ],
              "type": "string"
            }
          },
          {
            "description": "Return the authorization URL as JSON when true.",
            "in": "query",
            "name": "json",
            "required": false,
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacySocialAuthorize"
                }
              }
            },
            "description": "Authorization URL when JSON is requested."
          },
          "302": {
            "description": "Redirect to Google authorization endpoint."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "501": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Social sign-in is not configured."
          }
        },
        "security": [],
        "summary": "Start Google sign-in",
        "tags": [
          "Social auth"
        ]
      }
    },
    "/api/v1/billing/auto-topup": {
      "get": {
        "description": "Returns the authenticated account’s auto top-up settings and saved payment-method availability. Requires an authenticated user with the `billing.read` ability or `*` wildcard on a bearer access token. Browser session authentication uses the account session.",
        "operationId": "v1GetBillingAutoTopup",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "available": {
                      "type": "boolean"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "has_payment_method": {
                      "type": "boolean"
                    },
                    "payment_method": {
                      "additionalProperties": true,
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "threshold_cents": {
                      "type": "integer"
                    },
                    "unavailable_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "enabled",
                    "threshold_cents",
                    "amount_cents",
                    "has_payment_method",
                    "payment_method",
                    "available",
                    "unavailable_reason"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Auto top-up settings and availability."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Auto Topup",
        "tags": [
          "billing"
        ]
      },
      "patch": {
        "description": "Updates the authenticated account’s auto top-up settings. `enabled` is required; `threshold_cents` and `amount_cents` are optional. Enabling requires an available saved payment method. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "v1PatchBillingAutoTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "amount_cents": {
                    "maximum": 200000,
                    "minimum": 2500,
                    "type": "integer"
                  },
                  "enabled": {
                    "type": "boolean"
                  },
                  "threshold_cents": {
                    "maximum": 20000,
                    "minimum": 100,
                    "type": "integer"
                  }
                },
                "required": [
                  "enabled"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "available": {
                      "type": "boolean"
                    },
                    "enabled": {
                      "type": "boolean"
                    },
                    "has_payment_method": {
                      "type": "boolean"
                    },
                    "payment_method": {
                      "additionalProperties": true,
                      "type": [
                        "object",
                        "null"
                      ]
                    },
                    "threshold_cents": {
                      "type": "integer"
                    },
                    "unavailable_reason": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  },
                  "required": [
                    "enabled",
                    "threshold_cents",
                    "amount_cents",
                    "has_payment_method",
                    "payment_method",
                    "available",
                    "unavailable_reason"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Auto top-up settings updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "available": {
                      "const": false,
                      "type": "boolean"
                    },
                    "error": {
                      "const": "auto_topup_blocked",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "unavailable_reason": {
                      "const": "auto_topup_blocked",
                      "type": "string"
                    }
                  },
                  "required": [
                    "available",
                    "unavailable_reason",
                    "error",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Auto top-up is unavailable while the account-level gate is active."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation or no saved payment method is available."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Auto Topup",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/balance": {
      "get": {
        "description": "Returns the authenticated account’s prepaid balance in cents and dollars, low-balance flag, and configured threshold. Bearer-token callers need the `billing.read` ability; API-key callers must provide a valid API key. This read operation does not require legal acceptance.",
        "operationId": "billingBalanceV1Alias",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "balance_cents": {
                      "type": "integer"
                    },
                    "balance_dollars": {
                      "type": "number"
                    },
                    "is_low_balance": {
                      "type": "boolean"
                    },
                    "low_balance_threshold_dollars": {
                      "type": "number"
                    },
                    "balance_micros": {
                      "description": "Exact balance in USD micro-dollars. Existing cents fields remain for compatibility.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "balance_cents",
                    "balance_dollars",
                    "is_low_balance",
                    "low_balance_threshold_dollars",
                    "balance_micros"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authenticated prepaid balance and low-balance threshold."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "A bearer token is missing the `billing.read` ability."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Get current balance",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/checkout/amounts": {
      "get": {
        "description": "Returns the configured top-up amount entries and currency for the authenticated account. Checkout creation is handled by POST `/api/billing/checkout/topup`. This operation is also available under the versioned path.",
        "operationId": "billingTopupAmountsV1Alias",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "amounts": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "amount_cents": {
                            "type": "integer"
                          }
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "currency": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "amounts",
                    "currency"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Configured top-up entries and currency for the authenticated account."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List available top-up amounts",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/checkout/topup": {
      "post": {
        "description": "Creates a checkout session for a prepaid top-up and returns its URL, session ID, and amount in cents. The return URL must use HTTPS and an allowed dashboard host. The configured minimum amount is at least 2500 cents; the maximum is 200000 cents. Include a valid `topup_nonce` with each request. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "billingCheckoutTopupV1Alias",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "amount_cents": {
                    "maximum": 200000,
                    "minimum": 2500,
                    "type": "integer"
                  },
                  "return_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "topup_nonce": {
                    "description": "A client-generated nonce containing 16 to 64 letters, digits, underscores, or hyphens.",
                    "maxLength": 64,
                    "minLength": 16,
                    "pattern": "^[A-Za-z0-9_-]{16,64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "amount_cents",
                  "return_url",
                  "topup_nonce"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "checkout_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "checkout_url",
                    "session_id",
                    "amount_cents"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Checkout session created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The amount, HTTPS return URL, billing details, nonce, or request fields are invalid."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "stripe_error",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The checkout session could not be created."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create a top-up checkout session",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/invoices": {
      "get": {
        "description": "Returns the authenticated account's prepaid transactions, newest first, using offset pagination with 50 rows per page. This handler accepts no filter parameters. This operation is also available under the versioned path.",
        "operationId": "billingInvoicesListV1Alias",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "transactions": {
                      "additionalProperties": true,
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "data": {
                          "items": {
                            "additionalProperties": true,
                            "type": "object",
                            "properties": {
                              "amount_micros": {
                                "description": "Exact signed transaction amount in USD micro-dollars; legacy cents-only rows are returned as amount_cents × 10,000.",
                                "type": "integer"
                              },
                              "has_receipt": {
                                "description": "Whether a signed receipt is linked to the usage record for this debit.",
                                "type": "boolean"
                              },
                              "amount_cents": {
                                "description": "Signed whole-cent wallet settlement for this transaction. For usage debits the subcent remainder is carried across calls, so this can differ from rounding amount_micros per row.",
                                "type": "integer"
                              }
                            },
                            "required": [
                              "amount_micros",
                              "has_receipt",
                              "amount_cents"
                            ]
                          },
                          "type": "array"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "next_page_url": {
                          "format": "uri",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "per_page": {
                          "const": 50,
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "data",
                        "current_page",
                        "per_page",
                        "total"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "transactions"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Transactions ordered newest first with pagination metadata (50 rows per page)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List invoices",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/markup-breakdown": {
      "get": {
        "description": "Performs the account operation at `/api/v1/billing/markup-breakdown`.",
        "operationId": "v1GetBillingMarkupBreakdown",
        "responses": {
          "200": {
            "description": "Usage-record billing breakdown for the current calendar month; receipts provide mode attributes only.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "description": "Currency of raw usage_records and receipt provider micros.",
                      "type": "string",
                      "const": "USD"
                    },
                    "month": {
                      "type": "string"
                    },
                    "month_label": {
                      "type": "string"
                    },
                    "covers_legacy_usage": {
                      "description": "True when monthly totals include all usage_records, including rows without receipts.",
                      "type": "boolean"
                    },
                    "modes": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "has_receipt": {
                            "description": "Whether the usage rows in this breakdown line have linked signed receipts.",
                            "type": "boolean"
                          },
                          "unitemised": {
                            "description": "True when a usage row cannot be assigned to a billing mode.",
                            "type": "boolean"
                          },
                          "total_cost_micros": {
                            "description": "Exact billed amount in USD micros from usage_records; receipt amounts do not replace it.",
                            "type": "integer"
                          }
                        },
                        "required": [
                          "has_receipt",
                          "unitemised",
                          "total_cost_micros"
                        ],
                        "additionalProperties": true
                      }
                    },
                    "total_calls": {
                      "type": "integer"
                    },
                    "total_fee_micros": {
                      "type": "integer",
                      "description": "Exact fee total in USD micros from usage_records."
                    },
                    "total_fee_cents": {
                      "type": "integer"
                    },
                    "total_fee": {
                      "type": "string"
                    },
                    "total_billed_micros": {
                      "type": "integer",
                      "description": "Exact total in USD micros from usage_records."
                    },
                    "total_billed_cents": {
                      "type": "integer"
                    },
                    "total_billed": {
                      "type": "string"
                    },
                    "no_receipt_calls": {
                      "type": "integer"
                    },
                    "has_traffic": {
                      "type": "boolean"
                    },
                    "cache_usage": {
                      "$ref": "#/components/schemas/CacheUsageBreakdown"
                    }
                  },
                  "required": [
                    "currency",
                    "month",
                    "month_label",
                    "covers_legacy_usage",
                    "modes",
                    "total_calls",
                    "total_fee_micros",
                    "total_fee_cents",
                    "total_fee",
                    "total_billed_micros",
                    "total_billed_cents",
                    "total_billed",
                    "no_receipt_calls",
                    "has_traffic",
                    "cache_usage"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Markup Breakdown",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/monthly-usage": {
      "get": {
        "description": "Performs the account operation at `/api/v1/billing/monthly-usage`.",
        "operationId": "v1GetBillingMonthlyUsage",
        "responses": {
          "200": {
            "description": "Monthly usage by calendar month.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "description": "Currency of raw usage_records wallet micros.",
                      "type": "string",
                      "const": "USD"
                    },
                    "covers_legacy_usage": {
                      "description": "True when monthly totals include all usage_records, including rows without receipts.",
                      "type": "boolean"
                    },
                    "months": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "month": {
                            "type": "string"
                          },
                          "month_label": {
                            "type": "string"
                          },
                          "status": {
                            "type": "string",
                            "enum": [
                              "in_progress",
                              "closed",
                              "paid"
                            ]
                          },
                          "total_cents": {
                            "type": "integer"
                          },
                          "total": {
                            "type": "string"
                          },
                          "call_count": {
                            "type": "integer"
                          },
                          "total_micros": {
                            "description": "Exact monthly total in USD micro-units from the usage ledger.",
                            "type": "integer"
                          }
                        },
                        "required": [
                          "month",
                          "month_label",
                          "status",
                          "total_cents",
                          "total",
                          "call_count",
                          "total_micros"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "currency",
                    "covers_legacy_usage",
                    "months"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "The account lacks billing read permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "forbidden"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "422": {
            "description": "The months query parameter is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Monthly Usage",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/redeem-license": {
      "post": {
        "description": "Redeems an eligible license code and adds its credit to the authenticated account balance. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "v1PostBillingRedeemLicense",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "code": {
                    "maxLength": 64,
                    "minLength": 1,
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "balance_cents": {
                      "type": "integer"
                    },
                    "balance_dollars": {
                      "type": "number"
                    },
                    "credit_cents": {
                      "type": "integer"
                    },
                    "credit_dollars": {
                      "type": "number"
                    },
                    "balance_micros": {
                      "description": "Exact wallet balance in USD micro-dollars after redemption.",
                      "type": "integer"
                    }
                  },
                  "required": [
                    "credit_cents",
                    "credit_dollars",
                    "balance_cents",
                    "balance_dollars",
                    "balance_micros"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code was redeemed and the account balance was updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "enum": [
                            "expired",
                            "exhausted",
                            "already_redeemed"
                          ],
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code is expired, exhausted, or has already been redeemed by this account."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The code is missing, invalid, or failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "too_many_attempts",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "scope": {
                          "const": "route",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The limit of 10 redemption requests per minute was exceeded. An edge rate limit may return an HTML error page.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "minimum": 1,
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "const": "route",
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Redeem License",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/tier-detector-summary": {
      "get": {
        "description": "Performs the account operation at `/api/v1/billing/tier-detector-summary`.",
        "operationId": "v1GetBillingTierDetectorSummary",
        "responses": {
          "200": {
            "description": "Detector and provider spend rollup. Cost amounts are raw USD micros.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "currency": {
                      "description": "Currency of provider and markup micros.",
                      "type": "string",
                      "const": "USD"
                    },
                    "window_days": {
                      "type": "integer",
                      "const": 30
                    },
                    "tiers": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "tier_id": {
                            "type": "string"
                          },
                          "tier": {
                            "type": "string"
                          },
                          "tier_label": {
                            "type": "string"
                          },
                          "call_count": {
                            "type": "integer"
                          },
                          "detector_hits": {
                            "type": "integer"
                          },
                          "share_pct": {
                            "type": "number"
                          },
                          "cost_micros": {
                            "description": "Exact cost in USD micros.",
                            "type": "integer"
                          },
                          "cost_cents": {
                            "type": "integer"
                          },
                          "cost": {
                            "type": "string"
                          }
                        },
                        "required": [
                          "tier_id",
                          "tier",
                          "tier_label",
                          "call_count",
                          "detector_hits",
                          "share_pct",
                          "cost_micros",
                          "cost_cents",
                          "cost"
                        ],
                        "additionalProperties": false
                      }
                    }
                  },
                  "required": [
                    "currency",
                    "window_days",
                    "tiers"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid bearer token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Tier Detector Summary",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/topup": {
      "post": {
        "description": "Creates a checkout session for a prepaid top-up and returns its URL, session ID, and amount in cents. The return URL must use HTTPS and an allowed dashboard host. The configured minimum amount is at least 2500 cents; the maximum is 200000 cents. Include a valid `topup_nonce` with each request. Requires an authenticated user. Bearer access tokens need the `billing.write` ability, and the associated account needs the `billing.change` permission. The `*` wildcard also satisfies the bearer ability check. Browser session authentication uses the account permission check without a token-ability check. API-key credentials are not accepted. A bearer token missing its ability receives a 403 JSON body with `error: \"token_ability_missing\"`, `required: [\"billing.write\"]`, and `have`.",
        "operationId": "v1PostBillingTopup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": true,
                "properties": {
                  "amount_cents": {
                    "maximum": 200000,
                    "minimum": 2500,
                    "type": "integer"
                  },
                  "return_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "topup_nonce": {
                    "description": "A client-generated nonce containing 16 to 64 letters, digits, underscores, or hyphens.",
                    "maxLength": 64,
                    "minLength": 16,
                    "pattern": "^[A-Za-z0-9_-]{16,64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "amount_cents",
                  "return_url",
                  "topup_nonce"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amount_cents": {
                      "type": "integer"
                    },
                    "checkout_url": {
                      "format": "uri",
                      "type": "string"
                    },
                    "session_id": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "checkout_url",
                    "session_id",
                    "amount_cents"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Checkout session created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The amount, HTTPS return URL, billing details, nonce, or request fields are invalid."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "stripe_error",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message",
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The checkout session could not be created."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Topup",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/topup-amounts": {
      "get": {
        "description": "Returns the configured top-up amount entries and currency for the authenticated account. Requires an authenticated user with the `billing.read` ability or `*` wildcard on a bearer access token. Browser session authentication uses the account session.",
        "operationId": "v1GetBillingTopupAmounts",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "amounts": {
                      "items": {
                        "additionalProperties": true,
                        "properties": {
                          "amount_cents": {
                            "type": "integer"
                          },
                          "label": {
                            "type": "string"
                          },
                          "popular": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "amount_cents",
                          "label",
                          "popular"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "currency": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "amounts",
                    "currency"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Configured top-up entries and currency for the authenticated account."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "token_ability_missing",
                          "type": "string"
                        },
                        "have": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "message": {
                          "type": "string"
                        },
                        "required": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [
                        "error",
                        "message",
                        "required",
                        "have"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": true,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "description": "The bearer token lacks the required ability or the authenticated account lacks the required permission."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Billing Topup Amounts",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/usage": {
      "get": {
        "description": "Returns the authenticated account's usage records, pagination metadata, and totals computed over the same optional filters. Requires `billing.read`; `per_page` defaults to 50 and is capped at 100. `to` must not precede `from`, and the date range cannot exceed 366 days. This list uses offset pagination ordered by `created_at DESC`, then `id DESC`. Keep the same filters and `per_page` value for every page. If rows are added or deleted while paging, rows can repeat or be skipped. Restart at page 1 after the list has stopped changing for a fresh traversal; this endpoint does not provide a point-in-time snapshot. This operation is also available under the versioned path.",
        "operationId": "billingUsageIndexV1Alias",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "description": "Must be on or after from.",
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "per_page",
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "pagination": {
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "per_page": {
                          "maximum": 100,
                          "minimum": 1,
                          "type": "integer"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "current_page",
                        "last_page",
                        "per_page",
                        "total"
                      ],
                      "type": "object"
                    },
                    "records": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object",
                        "properties": {
                          "provider_cost_micros": {
                            "description": "Exact provider cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "markup_micros": {
                            "description": "Exact markup in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "total_cost_micros": {
                            "description": "Exact billed cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.",
                            "type": "integer"
                          },
                          "has_receipt": {
                            "description": "Whether a signed receipt is linked to this usage record.",
                            "type": "boolean"
                          },
                          "cache_usage": {
                            "anyOf": [
                              {
                                "$ref": "#/components/schemas/CacheUsageBreakdown"
                              },
                              {
                                "type": "null"
                              }
                            ],
                            "description": "Per-type cache provider-cost detail, already included in provider_cost_micros and not added again to the billed total."
                          },
                          "receipt_mode": {
                            "description": "Optional mode from the linked receipt; absent when no receipt is linked.",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "receipt_tier": {
                            "description": "Optional privacy tier from the linked receipt; absent when no receipt is linked.",
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "provider_cost_micros",
                          "markup_micros",
                          "total_cost_micros",
                          "has_receipt"
                        ]
                      },
                      "type": "array"
                    },
                    "totals": {
                      "properties": {
                        "input_tokens": {
                          "type": "integer"
                        },
                        "markup_cents": {
                          "type": "integer"
                        },
                        "output_tokens": {
                          "type": "integer"
                        },
                        "provider_cost_cents": {
                          "type": "integer"
                        },
                        "scope_filtered": {
                          "type": "boolean"
                        },
                        "total_cost_cents": {
                          "type": "integer"
                        },
                        "total_cost_dollars": {
                          "type": "number"
                        },
                        "provider_cost_micros": {
                          "type": "integer"
                        },
                        "markup_micros": {
                          "type": "integer"
                        },
                        "total_cost_micros": {
                          "type": "integer"
                        },
                        "cache_usage": {
                          "$ref": "#/components/schemas/CacheUsageBreakdown"
                        }
                      },
                      "required": [
                        "input_tokens",
                        "output_tokens",
                        "provider_cost_cents",
                        "markup_cents",
                        "total_cost_cents",
                        "total_cost_dollars",
                        "scope_filtered",
                        "provider_cost_micros",
                        "markup_micros",
                        "total_cost_micros",
                        "cache_usage"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "records",
                    "pagination",
                    "totals"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Paginated usage records and totals over the same optional filters."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid filters or a requested date range exceeding 366 days.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Usage analytics (full)",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/usage/export": {
      "get": {
        "description": "Streams a CSV of up to 10,000 usage rows with request ID, provider, model, token counts, costs, response time, and creation time. Requires `billing.read`. Optional date and provider filters are supported; the route is limited to five requests per minute. This operation is also available under the versioned path.",
        "operationId": "billingUsageExportV1Alias",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/csv": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "CSV export with at most 10,000 rows."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Date or provider query value failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The five-requests-per-minute route throttle was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Export usage as CSV",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/billing/usage/summary": {
      "get": {
        "description": "Returns daily per-provider usage rows and window aggregates for requests, tokens, billed cost, latency percentiles, traffic presence, request-count change, and usage rows without linked receipts. `window` accepts `24h`, `7d`, `30d`, or `90d`; explicit `from` and `to` dates take precedence. Latency percentiles and the change value can be null when there is no sample or comparison window. This operation is also available under the versioned path.",
        "operationId": "billingUsageSummaryV1Alias",
        "parameters": [
          {
            "in": "query",
            "name": "from",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "to",
            "schema": {
              "format": "date",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "window",
            "schema": {
              "enum": [
                "24h",
                "7d",
                "30d",
                "90d"
              ],
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "schema": {
              "maxLength": 64,
              "pattern": "^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "cost_billed_cents": {
                      "type": "integer"
                    },
                    "from": {
                      "format": "date",
                      "type": "string"
                    },
                    "has_traffic": {
                      "type": "boolean"
                    },
                    "input_tokens": {
                      "type": "integer"
                    },
                    "output_tokens": {
                      "type": "integer"
                    },
                    "p50_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "p95_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "p99_latency_ms": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "requests": {
                      "type": "integer"
                    },
                    "requests_delta_pct": {
                      "type": [
                        "number",
                        "null"
                      ]
                    },
                    "summary": {
                      "items": {
                        "properties": {
                          "cost_cents": {
                            "type": "integer"
                          },
                          "date": {
                            "format": "date",
                            "type": "string"
                          },
                          "input_tokens": {
                            "type": "integer"
                          },
                          "output_tokens": {
                            "type": "integer"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "request_count": {
                            "type": "integer"
                          },
                          "cost_micros": {
                            "type": "integer"
                          }
                        },
                        "required": [
                          "date",
                          "provider",
                          "request_count",
                          "input_tokens",
                          "output_tokens",
                          "cost_cents",
                          "cost_micros"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "to": {
                      "format": "date",
                      "type": "string"
                    },
                    "tokens_provider": {
                      "type": "integer"
                    },
                    "total_requests": {
                      "type": "integer"
                    },
                    "cost_billed_micros": {
                      "type": "integer"
                    },
                    "no_receipt_count": {
                      "description": "Number of usage records without a linked receipt; these rows remain included in totals.",
                      "type": "integer"
                    },
                    "cache_usage": {
                      "$ref": "#/components/schemas/CacheUsageBreakdown"
                    }
                  },
                  "required": [
                    "summary",
                    "from",
                    "to",
                    "requests",
                    "total_requests",
                    "has_traffic",
                    "input_tokens",
                    "output_tokens",
                    "tokens_provider",
                    "cost_billed_cents",
                    "p50_latency_ms",
                    "p95_latency_ms",
                    "p99_latency_ms",
                    "requests_delta_pct",
                    "cost_billed_micros",
                    "no_receipt_count",
                    "cache_usage"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Daily provider rows and window aggregates derived from usage records."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Invalid date, provider, or window filter.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Usage summary (aggregated)",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/break-glass/confirm": {
      "post": {
        "description": "Tenant-facing step 2 of the SSO break-glass flow. Requires the step 1 confirmation_token and acknowledged_impact=true, and the same authenticated user who initiated it. A successful response returns a single-use approval_token and a six-digit final_authorization_code for step 3; both expire within two minutes.",
        "operationId": "v1BreakGlassConfirm",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "acknowledged_impact": {
                    "const": true,
                    "type": "boolean"
                  },
                  "confirmation_token": {
                    "maxLength": 32,
                    "minLength": 32,
                    "type": "string"
                  }
                },
                "required": [
                  "confirmation_token",
                  "acknowledged_impact"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "approval_token": {
                      "maxLength": 32,
                      "minLength": 32,
                      "type": "string"
                    },
                    "expires_in_seconds": {
                      "const": 120,
                      "type": "integer"
                    },
                    "final_authorization_code": {
                      "pattern": "^\\d{6}$",
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "next_step": {
                      "const": "POST /api/v1/break-glass/execute",
                      "type": "string"
                    }
                  },
                  "required": [
                    "approval_token",
                    "final_authorization_code",
                    "expires_in_seconds",
                    "next_step",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Confirmed"
          },
          "401": {
            "description": "Sanctum authentication is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the break-glass.trigger permission or did not initiate step 1.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid or expired confirmation token, missing impact acknowledgement, or token ownership mismatch.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Confirm tenant break-glass (step 2 of 3)",
        "tags": [
          "sso"
        ],
        "x-internal": false
      }
    },
    "/api/v1/break-glass/execute": {
      "post": {
        "description": "Tenant-facing step 3 of the SSO break-glass flow. Requires the step 2 approval_token and final_authorization_code, the same authenticated user, and break-glass.trigger permission. The returned code is six digits; the controller accepts a 6–12 character string but only the issued code succeeds. The approval token is single-use and expires after two minutes.",
        "operationId": "v1BreakGlassExecute",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "approval_token": {
                    "maxLength": 32,
                    "minLength": 32,
                    "type": "string"
                  },
                  "final_authorization_code": {
                    "maxLength": 12,
                    "minLength": 6,
                    "type": "string"
                  }
                },
                "required": [
                  "approval_token",
                  "final_authorization_code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "break_glass_id": {
                      "type": "string"
                    },
                    "confirmation_steps_completed": {
                      "const": 3,
                      "type": "integer"
                    },
                    "executed": {
                      "const": true,
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "break_glass_id",
                    "executed",
                    "confirmation_steps_completed",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Break-glass executed"
          },
          "401": {
            "description": "Sanctum authentication is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the break-glass.trigger permission or did not initiate the flow.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Invalid or expired approval token or final authorization code.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Execute tenant break-glass (step 3 of 3)",
        "tags": [
          "sso"
        ],
        "x-internal": false
      }
    },
    "/api/v1/break-glass/initiate": {
      "post": {
        "description": "Tenant-facing step 1 of the SSO break-glass flow. Requires Sanctum authentication and the break-glass.trigger RBAC permission; the route is limited to five requests per minute. scope must be user or all, reason_code must be an accepted code, and target_user is optional. A successful response returns a confirmation_token that expires after five minutes.",
        "operationId": "v1BreakGlassInitiate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "reason_code": {
                    "enum": [
                      "idp_outage",
                      "security_incident",
                      "emergency_access_required",
                      "regulatory_order"
                    ],
                    "type": "string"
                  },
                  "scope": {
                    "enum": [
                      "user",
                      "all"
                    ],
                    "type": "string"
                  },
                  "target_user": {
                    "minimum": 1,
                    "type": [
                      "integer",
                      "null"
                    ]
                  }
                },
                "required": [
                  "scope",
                  "reason_code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "confirmation_token": {
                      "maxLength": 32,
                      "minLength": 32,
                      "type": "string"
                    },
                    "expires_in_seconds": {
                      "const": 300,
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "next_step": {
                      "const": "POST /api/v1/break-glass/confirm",
                      "type": "string"
                    }
                  },
                  "required": [
                    "confirmation_token",
                    "expires_in_seconds",
                    "next_step",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Challenge issued"
          },
          "401": {
            "description": "Sanctum authentication is required.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "The caller lacks the break-glass.trigger permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "scope, reason_code or target_user failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Initiate tenant break-glass (step 1 of 3)",
        "tags": [
          "sso"
        ],
        "x-internal": false
      }
    },
    "/api/v1/builder/users": {
      "get": {
        "description": "Provision or list end-user accounts attributed to the authenticated builder application.",
        "operationId": "GetBuilderUsers",
        "parameters": [
          {
            "in": "query",
            "name": "app_id",
            "required": false,
            "schema": {
              "example": "sample-app",
              "maxLength": 64,
              "pattern": "^[a-z0-9._-]+$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "example": 50,
              "maximum": 200,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Get users",
        "tags": [
          "Builder"
        ]
      },
      "post": {
        "description": "Provision or list end-user accounts attributed to the authenticated builder application.",
        "operationId": "PostBuilderUsers",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcBuilderUserCreate"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "201": {
            "description": "The end-user account was created.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "user": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "account_id": {
                          "type": "integer"
                        },
                        "email": {
                          "type": "string",
                          "format": "email"
                        },
                        "email_verified": {
                          "type": "boolean"
                        },
                        "organisation_id": {
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "app_id": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "account_id",
                        "email",
                        "email_verified",
                        "organisation_id",
                        "app_id"
                      ]
                    },
                    "created": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "user",
                    "created"
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Post users",
        "tags": [
          "Builder"
        ]
      }
    },
    "/api/v1/campaigns/intent": {
      "post": {
        "description": "Stores an idempotent campaign enquiry for the supplied email and target slug. The operation returns the same confirmation response for suppressed addresses.",
        "operationId": "submitCampaignIntent",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "browser": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "campaign_target_slug": {
                    "maxLength": 100,
                    "pattern": "^[a-z0-9][a-z0-9-]*$",
                    "type": "string"
                  },
                  "email": {
                    "format": "email",
                    "maxLength": 254,
                    "type": "string"
                  },
                  "os": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "utm_campaign": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "utm_content": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "utm_medium": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "utm_source": {
                    "maxLength": 64,
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "campaign_target_slug"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "ok": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Enquiry stored or suppressed address accepted without disclosure."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Campaign target does not exist."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Email or target slug failed validation."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "summary": "Submit a campaign enquiry"
      }
    },
    "/api/v1/campaigns/page/{slug}": {
      "get": {
        "description": "Returns public campaign target data for a slug. Primary contact and token fields are omitted by the controller.",
        "operationId": "getCampaignPage",
        "parameters": [
          {
            "in": "path",
            "name": "slug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "data": {
                      "additionalProperties": true,
                      "type": "object"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Campaign page returned."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "No campaign page has this slug."
          },
          "410": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Campaign page was removed."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Get a public campaign page"
      }
    },
    "/api/v1/campaigns/unsubscribe": {
      "get": {
        "description": "Processes an unsubscribe token. POST accepts the RFC 8058 one-click form token; GET returns an HTML confirmation page.",
        "operationId": "showCampaignUnsubscribe",
        "parameters": [
          {
            "in": "query",
            "name": "token",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Unsubscribe confirmation or result."
          },
          "404": {
            "description": "Unsubscribe token is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is missing."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Show campaign unsubscribe confirmation"
      },
      "post": {
        "description": "Processes an unsubscribe token. POST accepts the RFC 8058 one-click form token; GET returns an HTML confirmation page.",
        "operationId": "unsubscribeCampaign",
        "parameters": [
          {
            "in": "query",
            "name": "token",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "token": {
                    "type": "string"
                  }
                },
                "required": [],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Unsubscribe confirmation or result."
          },
          "404": {
            "description": "Unsubscribe token is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is missing."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Unsubscribe from a campaign"
      }
    },
    "/api/v1/campaigns/visits": {
      "post": {
        "description": "Records a public campaign funnel event. Request bodies larger than 8 KB are rejected before validation.",
        "operationId": "recordCampaignVisit",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "event_id": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "event_kind": {
                    "enum": [
                      "page_view",
                      "shell_load",
                      "register_click",
                      "register_success",
                      "register_fail",
                      "unsubscribe_click",
                      "onboarding_completed"
                    ],
                    "type": "string"
                  },
                  "extra": {
                    "type": "object"
                  },
                  "slug": {
                    "maxLength": 100,
                    "type": "string"
                  },
                  "ua_family": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "ua_os": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "utm_campaign": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "utm_content": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "utm_medium": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "utm_source": {
                    "maxLength": 64,
                    "type": "string"
                  }
                },
                "required": [
                  "slug",
                  "event_kind"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "ok": {
                      "type": "boolean"
                    },
                    "replayed": {
                      "type": "boolean"
                    }
                  },
                  "required": [],
                  "type": "object"
                }
              }
            },
            "description": "Visit recorded or idempotent replay accepted."
          },
          "413": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Request body exceeded 8 KB."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Required event fields failed validation."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "summary": "Record a campaign visit"
      }
    },
    "/api/v1/changelog/confirm": {
      "get": {
        "description": "Confirms a changelog subscription using its emailed confirmation token.",
        "operationId": "confirmChangelogSubscription",
        "parameters": [
          {
            "in": "query",
            "name": "token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token accepted."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is invalid or expired."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is missing."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Confirms a changelog subscription using its emailed confirmation token"
      }
    },
    "/api/v1/changelog/subscribe": {
      "post": {
        "description": "Adds or reactivates an email subscription and sends a confirmation message. Existing subscriptions may receive a new confirmation message.",
        "operationId": "subscribeChangelog",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "email": {
                    "format": "email",
                    "maxLength": 254,
                    "type": "string"
                  },
                  "source": {
                    "maxLength": 80,
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Already subscribed or a confirmation message was sent."
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Subscription created and a confirmation message was sent."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string"
                        },
                        "fields": {
                          "additionalProperties": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "type": "object"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Email or source failed validation."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Subscribe to changelog updates"
      }
    },
    "/api/v1/changelog/unsubscribe": {
      "get": {
        "description": "Unsubscribes an address using its one-click token.",
        "operationId": "unsubscribeFromChangelog",
        "parameters": [
          {
            "in": "query",
            "name": "token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token accepted."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is invalid or expired."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Token is missing."
          },
          "429": {
            "description": "Request rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "summary": "Unsubscribes an address using its one-click token"
      }
    },
    "/api/v1/chat/completions": {
      "post": {
        "description": "OpenAI-compatible chat completions. Supports streaming, tools/functions,\nand JSON mode. Supported clients attempt best-effort detection and\ntokenisation on-device before sending. The gateway receives and relays\nrequest bytes, but does not inspect message content for personal data or\nverify that detection ran. The content-blind\nshape gate accepts top_p from 0 to 1, frequency_penalty and presence_penalty\nfrom -2 to 2, integer seed from 0 to 2147483647, integer n from 1 to 128,\nand max_completion_tokens from 1 to 200000. stop accepts one string or up to\nfour strings of at most 32 characters; these stop sequences are operator\nconfiguration, not user text. Function-schema required entries must name sibling\nproperties (at most 64 entries, each at most 64 characters). Client proof headers do not verify whether on-device detection ran or inspect message content.\n",
        "operationId": "v1ChatCompletions",
        "parameters": [
          {
            "$ref": "#/components/parameters/PrivacyMode"
          },
          {
            "description": "Client-declared version of the on-device CloakAPI tokeniser associated with this request. The gateway checks it against the minimum (currently 1.6.0) and answers 426 when lower; this does not prove that version ran. Leave it out, together with `X-Cloak-Engine-Hash`, only on a declared rules-only send (see `X-CloakAPI-Tokenized`); any other request without it is answered 428 `engine_identity_required`.",
            "in": "header",
            "name": "X-Cloak-Engine-Version",
            "required": false,
            "schema": {
              "example": "1.6.0",
              "type": "string"
            }
          },
          {
            "description": "Client-declared SHA-256 of the engine binary claimed for this request. The gateway checks whether the hash is on its published allowlist and answers 403 `engine_untrusted` when missing or unknown; this does not prove that binary ran. Leave it out, together with `X-Cloak-Engine-Version`, only on a declared rules-only send.",
            "in": "header",
            "name": "X-Cloak-Engine-Hash",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Client-declared detection coverage, written `true;coverage=full`, `true;coverage=rules_and_names` or `true;coverage=rules_only`. A client that ran rule-based detection without an engine sends exactly `true;coverage=rules_only`, sends neither `X-Cloak-Engine-Version` nor `X-Cloak-Engine-Hash`, and still sends `X-Cloak-Pretokenised` and `X-Cloak-Client-MAC`. The gateway then relays the request without an engine identity, answers with the response header `X-Cloak-Coverage` set to `rules_only`, and signs a receipt that records `x-cloakapi-detection` with `engine_identity` set to `not_declared` and `genuine_engine` set to false. If an engine version or hash is sent, the engine checks apply whatever coverage is declared. The gateway does not read the body and does not verify the declared coverage.",
            "in": "header",
            "name": "X-CloakAPI-Tokenized",
            "required": false,
            "schema": {
              "example": "true;coverage=rules_only",
              "type": "string"
            }
          },
          {
            "description": "Client assertion that the request body was tokenised on-device. The gateway requires this header and verifies the tenant-bound MAC, but cannot verify that detection ran. Missing header answers 428 `pretokenised_required`.",
            "in": "header",
            "name": "X-Cloak-Pretokenised",
            "required": true,
            "schema": {
              "enum": [
                "1"
              ],
              "type": "string"
            }
          },
          {
            "description": "MAC over the exact request body, obtained from `POST /api/v1/pretokenised/mac`. Missing or wrong answers 403 `pretokenised_mac_invalid`.",
            "in": "header",
            "name": "X-Cloak-Client-MAC",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionsResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Chat completion"
          },
          "401": {
            "$ref": "#/components/responses/ApiKeyUnauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientBalance"
          },
          "403": {
            "description": "Engine not recognised (`engine_untrusted`) or client MAC missing/invalid (`pretokenised_mac_invalid`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "An idempotency conflict or a stale client model catalogue. `model_unknown_refresh_catalogue` remains HTTP 409 for compatibility with existing SDKs and includes `error.suggested_model` when a current alternative is available.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/IdempotencyError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayCatalogueStaleError"
                    }
                  ]
                }
              }
            }
          },
          "415": {
            "description": "Request body must use `Content-Type: application/json` (`unsupported_media_type`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An unrecognised message key can result in HTTP 422 with `error.code=untokenisable_content_part`. A model that does not support the chat endpoint also returns HTTP 422 with `error.code=model_endpoint_unsupported` and `error.suggested_model` (nullable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError",
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/GenericError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayModelEndpointUnsupportedError"
                    }
                  ]
                }
              }
            }
          },
          "426": {
            "description": "Engine version below the minimum (`min_engine_version` in the body).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "428": {
            "description": "Either no engine identity was declared: `X-Cloak-Engine-Version` is missing and the request is not a declared rules-only send (`engine_identity_required`; the body carries `min_engine_version` and `upgrade_url`). Or the required client pre-tokenisation assertion was missing (`pretokenised_required`). Response header `X-Cloak-Pretokenised-Required: 1`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/GatewayServiceUnavailable"
          },
          "400": {
            "description": "Invalid request or unavailable chat model. Model selection failures use `model_not_priced`, `model_retired`, or `model_unavailable` and include `error.suggested_model` when a current alternative is available.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/GenericError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayModelSelectionError"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "OpenAI-compatible chat completions",
        "tags": [
          "chat"
        ]
      }
    },
    "/api/v1/compliance/controls": {
      "get": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "GetComplianceControls",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get controls",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/controls/{id}/enable": {
      "post": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "PostComplianceControlsIdEnable",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcComplianceEnableControl"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post enable",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/export": {
      "get": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "GetComplianceExport",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get export",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/export-bundle": {
      "get": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "GetComplianceExportBundle",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get export-bundle",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{orgId}/evidence/{packSlug}.zip": {
      "get": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "GetComplianceOrgOrgIdEvidencePackSlugZip",
        "parameters": [
          {
            "in": "path",
            "name": "orgId",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "path",
            "name": "packSlug",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/zip": {
                "schema": {
                  "format": "binary",
                  "type": "string"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get item.zip",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{org_id}/controls": {
      "get": {
        "description": "Returns the merged compliance controls for the organisation in the path, scoped through the compliance registry. Requires the `compliance.pack-view` permission.",
        "operationId": "complianceMergedControls",
        "parameters": [
          {
            "in": "path",
            "name": "org_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "controls": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "organisation_id": {
                      "type": [
                        "integer",
                        "string"
                      ]
                    }
                  },
                  "required": [
                    "organisation_id",
                    "controls"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Organisation ID and registry-resolved merged control records."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Merged control list across active packs",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{org_id}/ingesters": {
      "get": {
        "description": "Returns the vendor-ingester slugs effective for the organisation's active compliance packs. Requires the `compliance.pack-view` permission.",
        "operationId": "complianceVendorIngesters",
        "parameters": [
          {
            "in": "path",
            "name": "org_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ingesters": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "organisation_id": {
                      "type": [
                        "integer",
                        "string"
                      ]
                    }
                  },
                  "required": [
                    "organisation_id",
                    "ingesters"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Organisation ID and effective vendor-ingester slugs."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List vendor ingesters (GRC platform connectors)",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{org_id}/packs": {
      "get": {
        "description": "Returns the organisation's active compliance packs and effective retention, breach-notification, and vendor-ingester settings. Requires the `compliance.pack-view` permission.",
        "operationId": "complianceOrgPacks",
        "parameters": [
          {
            "in": "path",
            "name": "org_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "active_packs": {
                      "items": {
                        "additionalProperties": true,
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "breach_hours": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "organisation_id": {
                      "type": [
                        "integer",
                        "string"
                      ]
                    },
                    "retention_years": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    },
                    "vendor_ingesters": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "organisation_id",
                    "active_packs",
                    "retention_years",
                    "breach_hours",
                    "vendor_ingesters"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Active packs and effective organisation-level settings."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List active compliance packs for an organisation",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{org_id}/packs/disable": {
      "post": {
        "description": "Disables a known compliance pack for the organisation in the path and returns its resulting state. The JSON body requires `slug` and accepts an optional reason; an unknown pack returns 422. Requires the compliance-pack-toggle permission.",
        "operationId": "complianceDisablePack",
        "parameters": [
          {
            "in": "path",
            "name": "org_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcComplianceOrgPackDisable"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "organisation_id": {
                      "type": [
                        "integer",
                        "string"
                      ]
                    },
                    "pack": {
                      "type": "string"
                    },
                    "status": {
                      "const": "disabled",
                      "type": "string"
                    },
                    "was_active": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "organisation_id",
                    "pack",
                    "status",
                    "was_active"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Pack disabled for the organisation."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Pack slug is invalid or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Disable a compliance pack for an organisation",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/v1/compliance/org/{org_id}/packs/enable": {
      "post": {
        "description": "Enables a known compliance pack for the organisation in the path and returns its resulting state. The JSON body requires `slug` and accepts an optional reason; an unknown pack returns 422. Requires the compliance-pack-toggle permission.",
        "operationId": "complianceEnablePack",
        "parameters": [
          {
            "in": "path",
            "name": "org_id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcComplianceOrgPackEnable"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "already_enabled": {
                      "type": "boolean"
                    },
                    "organisation_id": {
                      "type": [
                        "integer",
                        "string"
                      ]
                    },
                    "pack": {
                      "type": "string"
                    },
                    "status": {
                      "const": "enabled",
                      "type": "string"
                    }
                  },
                  "required": [
                    "organisation_id",
                    "pack",
                    "status",
                    "already_enabled"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Pack enabled for the organisation."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "422": {
            "description": "Pack slug is invalid or unknown.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Enable a compliance pack for an organisation",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/v1/compliance/packs": {
      "get": {
        "description": "Returns the compliance-pack catalogue with pack descriptors and controls; when the authenticated organisation is resolved, each descriptor also indicates whether that organisation imported it. Requires the `compliance.pack-view` permission.",
        "operationId": "complianceListPacks",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "items": {
                    "additionalProperties": true,
                    "type": "object"
                  },
                  "type": "array"
                }
              }
            },
            "description": "Compliance pack catalogue; descriptors may include whether the current organisation imported each pack."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Authenticated caller lacks the required permission, ability, or role."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List all registered compliance packs (public)",
        "tags": [
          "compliance"
        ]
      },
      "post": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "PostCompliancePacks",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcComplianceCustomPack"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request conflicts with an existing resource."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post packs",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/compliance/packs/{id}/import": {
      "post": {
        "description": "Read or update compliance controls and compliance pack data for the authenticated organisation.",
        "operationId": "PostCompliancePacksIdImport",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post import",
        "tags": [
          "Compliance"
        ]
      }
    },
    "/api/v1/consumer-auth/legal-versions": {
      "get": {
        "description": "Public read-only terms and privacy versions. An app sends these versions back when it creates an account. No authentication. Responses may be cached for five minutes.\n",
        "operationId": "consumerAuthLegalVersions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "privacy_version": {
                      "type": "string"
                    },
                    "terms_version": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "privacy_version",
                    "terms_version"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The configured published terms and privacy versions."
          },
          "429": {
            "description": "The request was rate limited."
          }
        },
        "security": [],
        "summary": "Published legal versions",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/magic-link/request": {
      "post": {
        "description": "Public, enumeration-safe passwordless sign-in request. For a valid email,\nthe endpoint returns the same 200 response when consumer sign-in is enabled.\nRate limits or disabled sign-in can return errors. A single-use link is sent\nwhen delivery is available. The return_to origin is resolved against the\ngateway allowlist.\n",
        "operationId": "consumerAuthMagicLinkRequest",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "app_id": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "app_name": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "email": {
                    "format": "email",
                    "maxLength": 255,
                    "type": "string"
                  },
                  "name": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "return_to": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  }
                },
                "required": [
                  "email"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Enumeration-safe response"
          },
          "422": {
            "description": "Invalid email or validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Request consumer magic link",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/magic-link/verify": {
      "post": {
        "description": "Consumes a single-use 64-character magic-link token, provisions or links\nthe consumer account as email-verified, and returns a Sanctum bearer plus\nthe consumer profile.\n",
        "operationId": "consumerAuthMagicLinkVerify",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "token": {
                    "maxLength": 64,
                    "minLength": 64,
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "token"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "nullable": true,
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "$ref": "#/components/schemas/ConsumerUserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Magic link accepted"
          },
          "400": {
            "description": "invalid_or_expired_link",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Verify consumer magic link",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/password/login": {
      "post": {
        "description": "Public builder-facing login. Password length is unconstrained (existing\nshort passwords keep working); only signup/reset enforce minLength 12.\n",
        "operationId": "consumerAuthPasswordLogin",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "password": {
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "password"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "nullable": true,
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "$ref": "#/components/schemas/ConsumerUserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Login successful"
          },
          "401": {
            "description": "invalid_credentials",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Consumer password login",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/password/signup": {
      "post": {
        "description": "Public builder-facing signup. Creates an unverified account, emails a\nverification link, and returns a bearer token. Password must be at least 12 characters long. /api/v1/* relay stays gated until\nemail is verified. Optional app_id attributes trial credit on verify.\n",
        "operationId": "consumerAuthPasswordSignup",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "app_id": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "email": {
                    "format": "email",
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "password": {
                    "format": "password",
                    "minLength": 12,
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "password"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "nullable": true,
                      "type": "string"
                    },
                    "email_verified": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "$ref": "#/components/schemas/ConsumerUserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Account created; verification email sent"
          },
          "409": {
            "description": "email_taken",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Consumer password signup",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/session": {
      "get": {
        "description": "Returns the authenticated consumer profile, including wallet balance and verification state.",
        "operationId": "consumerAuthSession",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/ConsumerUserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Current consumer session"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get consumer session",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/session/exchange": {
      "post": {
        "description": "Swaps the single-use social exchange code from a callback for a Sanctum bearer, optional relay API key, and consumer profile.",
        "operationId": "consumerAuthSessionExchange",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "code": {
                    "maxLength": 64,
                    "minLength": 64,
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "code"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "api_key": {
                      "nullable": true,
                      "type": "string"
                    },
                    "token": {
                      "type": "string"
                    },
                    "user": {
                      "$ref": "#/components/schemas/ConsumerUserResource"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Exchange code accepted"
          },
          "400": {
            "description": "invalid_or_expired_code",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Exchange consumer social code",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/social/{provider}/callback": {
      "get": {
        "description": "Handles the Google GET or Apple-compatible callback, validates state, and\nredirects to the allowlisted builder return URL with a single-use exchange\ncode. The bearer token is never placed in the URL.\n",
        "operationId": "consumerAuthSocialCallback",
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "enum": [
                "google",
                "apple"
              ],
              "type": "string"
            }
          },
          {
            "description": "Provider authorization code.",
            "in": "query",
            "name": "code",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Opaque state issued by the redirect endpoint.",
            "in": "query",
            "name": "state",
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Provider-side denial/error, when present.",
            "in": "query",
            "name": "error",
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "error_description",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the builder return URL with cloak_exchange, or a safe failure reason"
          },
          "400": {
            "description": "invalid_state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "unknown_provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "501": {
            "description": "social_not_configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Complete consumer social sign-in",
        "tags": [
          "authentication"
        ]
      },
      "post": {
        "description": "Form-post variant of the social callback, used by providers such as Apple. It has the same state validation and exchange-code redirect behavior as the GET callback.",
        "operationId": "consumerAuthSocialCallbackPost",
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "enum": [
                "google",
                "apple"
              ],
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "error": {
                    "type": "string"
                  },
                  "error_description": {
                    "type": "string"
                  },
                  "state": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "302": {
            "description": "Redirect to the builder return URL with cloak_exchange, or a safe failure reason"
          },
          "400": {
            "description": "invalid_state",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "unknown_provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "501": {
            "description": "social_not_configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Complete consumer social sign-in (form POST)",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-auth/social/{provider}/redirect": {
      "get": {
        "description": "Starts the Google or Apple browser OAuth round-trip. Browser requests are\nredirected to the provider; callers requesting JSON receive authorize_url\ninstead. Missing provider configuration returns 501 rather than fabricating\ncredentials.\n",
        "operationId": "consumerAuthSocialRedirect",
        "parameters": [
          {
            "in": "path",
            "name": "provider",
            "required": true,
            "schema": {
              "enum": [
                "google",
                "apple"
              ],
              "type": "string"
            }
          },
          {
            "description": "Allowlisted builder return URL used after the browser round-trip.",
            "in": "query",
            "name": "return_to",
            "schema": {
              "format": "uri",
              "maxLength": 2048,
              "type": "string"
            }
          },
          {
            "description": "Return JSON containing authorize_url instead of a browser redirect.",
            "in": "query",
            "name": "json",
            "schema": {
              "type": "boolean"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "authorize_url": {
                      "format": "uri",
                      "type": "string"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "JSON caller response"
          },
          "302": {
            "description": "Redirect to the configured provider authorization endpoint"
          },
          "404": {
            "description": "unknown_provider",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "501": {
            "description": "social_not_configured",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "consumer_auth_disabled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Start consumer social sign-in",
        "tags": [
          "authentication"
        ]
      }
    },
    "/api/v1/consumer-billing/change-plan": {
      "post": {
        "description": "Handles a requested change to the current subscription plan.",
        "operationId": "PostConsumerBillingChangePlan",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "expected_charge_cents": {
                    "minimum": 0,
                    "type": "integer"
                  },
                  "plan": {
                    "type": "string"
                  },
                  "preview": {
                    "type": "boolean"
                  },
                  "preview_id": {
                    "maxLength": 255,
                    "pattern": "^[A-Za-z0-9_]+$",
                    "type": "string"
                  },
                  "proration_date": {
                    "type": "integer"
                  }
                },
                "required": [
                  "plan"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "402": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "POST consumer-billing/change-plan",
        "tags": [
          "consumer-billing"
        ]
      }
    },
    "/api/v1/consumer-billing/checkout": {
      "post": {
        "description": "Creates a checkout session for a selected subscription plan.",
        "operationId": "PostConsumerBillingCheckout",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "cancel_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  },
                  "plan": {
                    "type": "string"
                  },
                  "success_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  }
                },
                "required": [
                  "plan",
                  "success_url",
                  "cancel_url"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "POST consumer-billing/checkout",
        "tags": [
          "consumer-billing"
        ]
      }
    },
    "/api/v1/consumer-billing/plans": {
      "get": {
        "description": "Lists available subscription plans for the selected app.",
        "operationId": "GetConsumerBillingPlans",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET consumer-billing/plans",
        "tags": [
          "consumer-billing"
        ]
      }
    },
    "/api/v1/consumer-billing/portal": {
      "post": {
        "description": "Creates a billing portal session for the signed-in consumer.",
        "operationId": "PostConsumerBillingPortal",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "return_url": {
                    "format": "uri",
                    "maxLength": 2048,
                    "type": "string"
                  }
                },
                "required": [
                  "return_url"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "POST consumer-billing/portal",
        "tags": [
          "consumer-billing"
        ]
      }
    },
    "/api/v1/consumer-billing/subscription": {
      "get": {
        "description": "Returns the current subscription status and period details for the selected app.",
        "operationId": "GetConsumerBillingSubscription",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET consumer-billing/subscription",
        "tags": [
          "consumer-billing"
        ]
      }
    },
    "/api/v1/demo/chat-completions": {
      "post": {
        "description": "Accepts a prompt accompanied by the client pre-tokenisation markers through the authenticated demo chat and returns the model response. The gateway checks the request markers and MAC; it does not verify that tokenisation ran.",
        "operationId": "PostDemoChatCompletions",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "message": {
                    "maxLength": 8000,
                    "type": "string"
                  },
                  "messages": {
                    "items": {
                      "properties": {
                        "content": {
                          "type": "string"
                        },
                        "role": {
                          "enum": [
                            "user",
                            "assistant",
                            "system"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "role",
                        "content"
                      ],
                      "type": "object"
                    },
                    "maxItems": 60,
                    "minItems": 1,
                    "type": "array"
                  },
                  "model": {
                    "maxLength": 64,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "428": {
            "description": "The required pretokenised request marker is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "The demo configuration, provider pricing, or usage limits are unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "object",
                          "properties": {
                            "message": {
                              "type": "string"
                            },
                            "code": {
                              "type": "string",
                              "const": "demo_rate_limit_unavailable"
                            },
                            "type": {
                              "type": "string",
                              "const": "service_unavailable"
                            }
                          },
                          "additionalProperties": false,
                          "required": [
                            "type",
                            "code",
                            "message"
                          ]
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "error"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "error": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "demo_unconfigured"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "error",
                        "code"
                      ]
                    }
                  ]
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Retry delay in seconds.",
                "schema": {
                  "type": "string",
                  "const": "30"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "POST demo/chat-completions",
        "tags": [
          "demo"
        ]
      }
    },
    "/api/v1/demo/relay": {
      "post": {
        "description": "POST /api/v1/demo/relay. Accepts a JSON messages list with user, assistant or system roles and string content; requires X-Cloak-Pretokenised and enforces the route body limit.",
        "operationId": "PostDemoRelay",
        "parameters": [
          {
            "in": "header",
            "name": "X-Cloak-Pretokenised",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "messages": {
                    "items": {
                      "properties": {
                        "content": {
                          "minLength": 1,
                          "type": "string"
                        },
                        "role": {
                          "enum": [
                            "user",
                            "assistant",
                            "system"
                          ],
                          "type": "string"
                        }
                      },
                      "required": [
                        "role",
                        "content"
                      ],
                      "type": "object"
                    },
                    "maxItems": 60,
                    "minItems": 1,
                    "type": "array"
                  }
                },
                "required": [
                  "messages"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "413": {
            "description": "Request body exceeds the route byte limit.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "The request Content-Type must be JSON.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "428": {
            "description": "The required pretokenised header is missing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "The demo relay is unavailable or its configured limits are not ready.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "POST demo/relay",
        "tags": [
          "demo"
        ]
      }
    },
    "/api/v1/devices/pair": {
      "post": {
        "description": "Registers a device public key for receipt signing.",
        "operationId": "PostDevicesPair",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "device_label": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "public_key_pem": {
                    "maxLength": 8192,
                    "type": "string"
                  }
                },
                "required": [
                  "public_key_pem"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the supplied credentials are not accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ApiKeyUnauthorized"
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "The token lacks write ability or the caller lacks organisation settings permission.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "type": {
                          "const": "permission_denied",
                          "type": "string"
                        },
                        "code": {
                          "enum": [
                            "missing_ability",
                            "org_settings_write_required"
                          ],
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "POST devices/pair",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/v1/devices/status": {
      "get": {
        "description": "Reports whether receipt key rotation is required.",
        "operationId": "GetDevicesStatus",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "GET devices/status",
        "tags": [
          "devices"
        ]
      }
    },
    "/api/v1/embeddings": {
      "post": {
        "description": "The request is relayed to the upstream provider you select; the gateway runs no\nlocal embedding model. Supported clients should attempt best-effort detection\nand tokenisation on-device before sending. The gateway receives and relays\nrequest bytes but does not inspect body content for personal data or verify\nthat detection ran.\n",
        "operationId": "v1Embeddings",
        "parameters": [
          {
            "$ref": "#/components/parameters/PrivacyMode"
          },
          {
            "description": "Client-declared version of the on-device CloakAPI tokeniser associated with this request. The gateway checks it against the minimum (currently 1.6.0) and answers 426 when lower; this does not prove that version ran. Leave it out, together with `X-Cloak-Engine-Hash`, only on a declared rules-only send (see `X-CloakAPI-Tokenized`); any other request without it is answered 428 `engine_identity_required`.",
            "in": "header",
            "name": "X-Cloak-Engine-Version",
            "required": false,
            "schema": {
              "example": "1.6.0",
              "type": "string"
            }
          },
          {
            "description": "Client-declared SHA-256 of the engine binary claimed for this request. The gateway checks whether the hash is on its published allowlist and answers 403 `engine_untrusted` when missing or unknown; this does not prove that binary ran. Leave it out, together with `X-Cloak-Engine-Version`, only on a declared rules-only send.",
            "in": "header",
            "name": "X-Cloak-Engine-Hash",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Client-declared detection coverage, written `true;coverage=full`, `true;coverage=rules_and_names` or `true;coverage=rules_only`. A client that ran rule-based detection without an engine sends exactly `true;coverage=rules_only`, sends neither `X-Cloak-Engine-Version` nor `X-Cloak-Engine-Hash`, and still sends `X-Cloak-Pretokenised` and `X-Cloak-Client-MAC`. The gateway then relays the request without an engine identity, answers with the response header `X-Cloak-Coverage` set to `rules_only`, and signs a receipt that records `x-cloakapi-detection` with `engine_identity` set to `not_declared` and `genuine_engine` set to false. If an engine version or hash is sent, the engine checks apply whatever coverage is declared. The gateway does not read the body and does not verify the declared coverage.",
            "in": "header",
            "name": "X-CloakAPI-Tokenized",
            "required": false,
            "schema": {
              "example": "true;coverage=rules_only",
              "type": "string"
            }
          },
          {
            "description": "Client assertion that the request body was tokenised on-device. The gateway requires this header and verifies the tenant-bound MAC, but cannot verify that detection ran. Missing header answers 428 `pretokenised_required`.",
            "in": "header",
            "name": "X-Cloak-Pretokenised",
            "required": true,
            "schema": {
              "enum": [
                "1"
              ],
              "type": "string"
            }
          },
          {
            "description": "MAC over the exact request body, obtained from `POST /api/v1/pretokenised/mac`. Missing or wrong answers 403 `pretokenised_mac_invalid`.",
            "in": "header",
            "name": "X-Cloak-Client-MAC",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingsRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbeddingsResponse"
                }
              }
            },
            "description": "Embeddings"
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid CloakAPI API key."
          },
          "402": {
            "description": "Insufficient balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Engine not recognised (`engine_untrusted`) or client MAC missing/invalid (`pretokenised_mac_invalid`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "410": {
            "$ref": "#/components/responses/GatewayModelUnavailable"
          },
          "415": {
            "description": "Request body must use `Content-Type: application/json` (`unsupported_media_type`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An unrecognised message key can result in HTTP 422 with `error.code=untokenisable_content_part`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "426": {
            "description": "Engine version below the minimum (`min_engine_version` in the body).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "428": {
            "description": "Either no engine identity was declared: `X-Cloak-Engine-Version` is missing and the request is not a declared rules-only send (`engine_identity_required`; the body carries `min_engine_version` and `upgrade_url`). Or the required client pre-tokenisation assertion was missing (`pretokenised_required`). Response header `X-Cloak-Pretokenised-Required: 1`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Embedding generation (relayed to the upstream provider)",
        "tags": [
          "embeddings"
        ]
      }
    },
    "/api/v1/engine/hashes": {
      "get": {
        "description": "Lists SHA-256 hashes and the ruleset version for official engine binaries.",
        "operationId": "GetEngineHashes",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsEngineHashes"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET engine/hashes",
        "tags": [
          "engine"
        ]
      }
    },
    "/api/v1/engine/ruleset": {
      "get": {
        "description": "Returns the canonical tokeniser ruleset artifact when it is available.",
        "operationId": "GetEngineRuleset",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "description": "Hash-addressed ruleset JSON artifact served by this endpoint. The gateway returns the artifact as a whole and does not interpret its object fields.",
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "The ruleset artifact is not mounted on this gateway node.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET engine/ruleset",
        "tags": [
          "engine"
        ]
      }
    },
    "/api/v1/erasure-receipts/{dsar_request_id}": {
      "get": {
        "description": "Returns the signed deletion receipt for a verified data-subject request when available.",
        "operationId": "GetErasureReceipts",
        "parameters": [
          {
            "in": "path",
            "name": "dsar_request_id",
            "required": true,
            "schema": {
              "pattern": "^[a-z0-9-]+$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "email",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "verification_token",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsErasureReceipt"
                }
              }
            },
            "description": "Successful response."
          },
          "403": {
            "description": "The DSAR email and verification token are invalid or expired.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsApiError"
                }
              }
            },
            "description": "The referenced resource was not found."
          },
          "422": {
            "description": "The email or verification token is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The stored signed envelope could not be decoded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "receipt_corrupt",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET erasure-receipts/{}",
        "tags": [
          "erasure-receipts"
        ]
      }
    },
    "/api/v1/erasure-receipts/{dsar_request_id}/verify": {
      "post": {
        "description": "Cryptographically verifies the deletion receipt for a verified data-subject request.",
        "operationId": "PostErasureReceiptsVerify",
        "parameters": [
          {
            "in": "path",
            "name": "dsar_request_id",
            "required": true,
            "schema": {
              "pattern": "^[a-z0-9-]+$",
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "email": {
                    "format": "email",
                    "maxLength": 254,
                    "type": "string"
                  },
                  "verification_token": {
                    "maxLength": 256,
                    "minLength": 8,
                    "type": "string"
                  }
                },
                "required": [
                  "email",
                  "verification_token"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsErasureVerify"
                }
              }
            },
            "description": "Successful response."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsApiError"
                }
              }
            },
            "description": "The referenced resource was not found."
          },
          "422": {
            "description": "The request is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "message": {
                          "type": "string"
                        },
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "The account lacks permission to verify erasure receipts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "verification_failed"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "500": {
            "description": "The erasure receipt could not be verified.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "receipt_corrupt"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              }
            }
          }
        },
        "security": [],
        "summary": "POST erasure-receipts/{}/verify",
        "tags": [
          "erasure-receipts"
        ]
      }
    },
    "/api/v1/extension/checkout": {
      "post": {
        "description": "Starts a hosted checkout for an Unlimited licence on the API key's account. The plan field is monthly or yearly; when it is omitted the server selects yearly. Return URLs must use an allowlisted host. This route does not inspect message content. When signing or the catalogue price is not configured the response is 503 billing_not_configured and no checkout is opened. A catalogue price that does not match the locked amount, currency or interval returns 503 billing_price_mismatch.",
        "operationId": "PostExtensionCheckout",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "cancel_url": {
                    "type": "string"
                  },
                  "plan": {
                    "enum": [
                      "monthly",
                      "yearly"
                    ],
                    "type": "string"
                  },
                  "success_url": {
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "url": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "url"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Hosted checkout URL."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The cloak API key is missing or invalid (invalid_api_key)."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "checkout_in_progress or active_subscription_exists."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "invalid_plan or invalid_return_url."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "too_many_requests. Limit is 30 requests per minute for the API key's user. An edge rate limit may return an HTML error page."
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "stripe_error. Payment processing did not return a checkout URL."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "billing_not_configured or billing_price_mismatch. Retry-After is 3600. No checkout is opened."
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Start Unlimited checkout",
        "tags": [
          "Extension"
        ]
      }
    },
    "/api/v1/extension/entitlement": {
      "get": {
        "description": "Reports whether the API key's account has an active Unlimited licence. The body is active, plan (unlimited_monthly, unlimited_yearly, or null) and current_period_end. ticket is optional and is present only when the licence is active and the subscription price matches the catalogue. ticket is an Ed25519 signature (kid, sub, plan, iat, exp, sig) that expires 72 hours after iat. It is omitted when there is no active paid licence. If the licence is active and the price matches but signing is not configured, the response is 503 entitlement_not_configured and no unsigned ticket is returned. This route does not inspect message content.",
        "operationId": "GetExtensionEntitlement",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "active": {
                      "type": "boolean"
                    },
                    "current_period_end": {
                      "nullable": true,
                      "type": "string"
                    },
                    "plan": {
                      "nullable": true,
                      "type": "string"
                    },
                    "ticket": {
                      "additionalProperties": false,
                      "description": "Present only for an active paid licence whose price matches the catalogue.",
                      "properties": {
                        "exp": {
                          "type": "integer"
                        },
                        "iat": {
                          "type": "integer"
                        },
                        "kid": {
                          "type": "string"
                        },
                        "plan": {
                          "enum": [
                            "monthly",
                            "yearly"
                          ],
                          "type": "string"
                        },
                        "sig": {
                          "type": "string"
                        },
                        "sub": {
                          "type": "string"
                        },
                        "v": {
                          "type": "integer"
                        }
                      },
                      "required": [
                        "v",
                        "kid",
                        "sub",
                        "plan",
                        "iat",
                        "exp",
                        "sig"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "active",
                    "plan",
                    "current_period_end"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Entitlement for this API key. ticket is optional."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The cloak API key is missing or invalid (invalid_api_key)."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "too_many_requests. Limit is 30 requests per minute for the API key's user. An edge rate limit may return an HTML error page."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "entitlement_not_configured. Signing is not configured for an otherwise active matching licence. Retry-After is 3600."
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Read Unlimited entitlement",
        "tags": [
          "Extension"
        ]
      }
    },
    "/api/v1/grc/connectors": {
      "get": {
        "description": "Manage a governance, risk, and compliance connector for the authenticated organisation.",
        "operationId": "GetGrcConnectors",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get connectors",
        "tags": [
          "GRC"
        ]
      }
    },
    "/api/v1/grc/connectors/{platform}": {
      "delete": {
        "description": "Manage a governance, risk, and compliance connector for the authenticated organisation.",
        "operationId": "DeleteGrcConnectorsId",
        "parameters": [
          {
            "in": "path",
            "name": "platform",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "deleted": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "deleted"
                  ]
                }
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete item",
        "tags": [
          "GRC"
        ]
      },
      "put": {
        "description": "Manage a governance, risk, and compliance connector for the authenticated organisation.",
        "operationId": "PutGrcConnectorsId",
        "parameters": [
          {
            "in": "path",
            "name": "platform",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcGrcConnectorUpsert"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Put item",
        "tags": [
          "GRC"
        ]
      }
    },
    "/api/v1/grc/connectors/{platform}/push": {
      "post": {
        "description": "Manage a governance, risk, and compliance connector for the authenticated organisation.",
        "operationId": "PostGrcConnectorsIdPush",
        "parameters": [
          {
            "in": "path",
            "name": "platform",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post push",
        "tags": [
          "GRC"
        ]
      }
    },
    "/api/v1/keys/scopes": {
      "get": {
        "description": "Returns scope names and the default scope list.",
        "operationId": "privacyGetApiV1KeysScopes",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyScopes"
                }
              }
            },
            "description": "Scope catalog."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [],
        "summary": "List API key scopes",
        "tags": [
          "API keys"
        ]
      }
    },
    "/api/v1/local-mode/entitlements": {
      "get": {
        "description": "Returns feature gates for the tenant's current subscription tier.\nResponse should be cached client-side for 1 hour (cache_ttl_seconds).\n",
        "operationId": "v1LocalModeEntitlements",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntitlementsResponse"
                }
              }
            },
            "description": "Entitlements"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Get subscription tier feature entitlements",
        "tags": [
          "local-mode"
        ]
      }
    },
    "/api/v1/local-mode/heartbeat": {
      "post": {
        "description": "Desktop sends a signed nonce every hour. Returns current subscription\ntier entitlements. 60-second acceptance window enforced server-side.\n",
        "operationId": "v1LocalModeHeartbeat",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "issued_at_unix": {
                    "type": "integer"
                  },
                  "licence_hash": {
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  },
                  "nonce": {
                    "pattern": "^[a-f0-9]{64}$",
                    "type": "string"
                  }
                },
                "required": [
                  "nonce",
                  "issued_at_unix",
                  "licence_hash"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HeartbeatResponse"
                }
              }
            },
            "description": "Heartbeat verified"
          },
          "422": {
            "description": "Nonce expired or invalid",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Licence nonce heartbeat",
        "tags": [
          "local-mode"
        ]
      }
    },
    "/api/v1/local-mode/receipt": {
      "post": {
        "description": "Called by the desktop gateway-lite after a local model inference.\nNo prompt or response content is sent or stored: prompt, response, tool\nand RAG material arrive as SHA-256 hashes. Metadata such as the model name,\nruntime, session id and tool names is stored as sent.\nECDSA signature verified against the device public key.\nNonce replay window: 60 seconds.\n",
        "operationId": "v1LocalModeStoreReceipt",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LocalReceiptRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LocalReceiptResponse"
                }
              }
            },
            "description": "Receipt recorded"
          },
          "422": {
            "description": "Validation error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Authentication is required or the supplied credentials are not accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ApiKeyUnauthorized"
                    },
                    {
                      "type": "object",
                      "additionalProperties": false,
                      "properties": {
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "message"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "409": {
            "description": "The receipt cannot be recorded because no device is paired or the receipt already exists.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "device_not_paired",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "error",
                        "message"
                      ]
                    },
                    {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "error": {
                          "const": "duplicate_receipt",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "error",
                        "message"
                      ]
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "message"
                  ]
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "The API key is restricted to a different source IP.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "ip_not_allowed",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Record a local-inference receipt in the audit chain",
        "tags": [
          "local-mode"
        ]
      }
    },
    "/api/v1/me/permissions": {
      "get": {
        "description": "Returns the authenticated portal user's role and permission names for interface gating. The route requires a verified Sanctum session and accepted legal terms, and is limited to 60 requests per minute. Authorization for each protected operation remains server-side.",
        "operationId": "v1MePermissions",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "permissions": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "roles": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Roles and permissions"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get current user RBAC roles and permissions",
        "tags": [
          "authentication"
        ],
        "x-internal": false
      }
    },
    "/api/v1/messages": {
      "post": {
        "description": "Anthropic-compatible messages endpoint. Supported clients attempt\nbest-effort detection and tokenisation on-device before sending. The\ngateway receives and relays request bytes, but does not inspect message\ncontent for personal data or verify that detection ran. The receipt is returned in the\n`X-CloakAPI-Receipt-V2` response header (non-streaming) or an\n`event: receipt-v2` frame after `data: [DONE]` (streaming); it is not part of\nthe JSON body.\n",
        "operationId": "v1Messages",
        "parameters": [
          {
            "$ref": "#/components/parameters/PrivacyMode"
          },
          {
            "description": "Client-declared version of the on-device CloakAPI tokeniser associated with this request. The gateway checks it against the minimum (currently 1.6.0) and answers 426 when lower; this does not prove that version ran. Leave it out, together with `X-Cloak-Engine-Hash`, only on a declared rules-only send (see `X-CloakAPI-Tokenized`); any other request without it is answered 428 `engine_identity_required`.",
            "in": "header",
            "name": "X-Cloak-Engine-Version",
            "required": false,
            "schema": {
              "example": "1.6.0",
              "type": "string"
            }
          },
          {
            "description": "Client-declared SHA-256 of the engine binary claimed for this request. The gateway checks whether the hash is on its published allowlist and answers 403 `engine_untrusted` when missing or unknown; this does not prove that binary ran. Leave it out, together with `X-Cloak-Engine-Version`, only on a declared rules-only send.",
            "in": "header",
            "name": "X-Cloak-Engine-Hash",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "description": "Client-declared detection coverage, written `true;coverage=full`, `true;coverage=rules_and_names` or `true;coverage=rules_only`. A client that ran rule-based detection without an engine sends exactly `true;coverage=rules_only`, sends neither `X-Cloak-Engine-Version` nor `X-Cloak-Engine-Hash`, and still sends `X-Cloak-Pretokenised` and `X-Cloak-Client-MAC`. The gateway then relays the request without an engine identity, answers with the response header `X-Cloak-Coverage` set to `rules_only`, and signs a receipt that records `x-cloakapi-detection` with `engine_identity` set to `not_declared` and `genuine_engine` set to false. If an engine version or hash is sent, the engine checks apply whatever coverage is declared. The gateway does not read the body and does not verify the declared coverage.",
            "in": "header",
            "name": "X-CloakAPI-Tokenized",
            "required": false,
            "schema": {
              "example": "true;coverage=rules_only",
              "type": "string"
            }
          },
          {
            "description": "Client assertion that the request body was tokenised on-device. The gateway requires this header and verifies the tenant-bound MAC, but cannot verify that detection ran. Missing header answers 428 `pretokenised_required`.",
            "in": "header",
            "name": "X-Cloak-Pretokenised",
            "required": true,
            "schema": {
              "enum": [
                "1"
              ],
              "type": "string"
            }
          },
          {
            "description": "MAC over the exact request body, obtained from `POST /api/v1/pretokenised/mac`. Missing or wrong answers 403 `pretokenised_mac_invalid`.",
            "in": "header",
            "name": "X-Cloak-Client-MAC",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MessagesRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MessagesResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "description": "Server-Sent Events stream",
                  "type": "string"
                }
              }
            },
            "description": "Messages response"
          },
          "401": {
            "$ref": "#/components/responses/ApiKeyUnauthorized"
          },
          "402": {
            "$ref": "#/components/responses/InsufficientBalance"
          },
          "403": {
            "description": "Engine not recognised (`engine_untrusted`) or client MAC missing/invalid (`pretokenised_mac_invalid`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "An idempotency conflict or a stale client model catalogue. `model_unknown_refresh_catalogue` remains HTTP 409 for compatibility with existing SDKs and includes `error.suggested_model` when a current alternative is available.",
            "content": {
              "application/json": {
                "schema": {
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/IdempotencyError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayCatalogueStaleError"
                    }
                  ]
                }
              }
            }
          },
          "415": {
            "description": "Request body must use `Content-Type: application/json` (`unsupported_media_type`).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "An unrecognised message key can result in HTTP 422 with `error.code=untokenisable_content_part`. A model that does not support the chat endpoint also returns HTTP 422 with `error.code=model_endpoint_unsupported` and `error.suggested_model` (nullable).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError",
                  "anyOf": [
                    {
                      "$ref": "#/components/schemas/GenericError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayModelEndpointUnsupportedError"
                    }
                  ]
                }
              }
            }
          },
          "426": {
            "description": "Engine version below the minimum (`min_engine_version` in the body).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "428": {
            "description": "Either no engine identity was declared: `X-Cloak-Engine-Version` is missing and the request is not a declared rules-only send (`engine_identity_required`; the body carries `min_engine_version` and `upgrade_url`). Or the required client pre-tokenisation assertion was missing (`pretokenised_required`). Response header `X-Cloak-Pretokenised-Required: 1`.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "$ref": "#/components/responses/GatewayServiceUnavailable"
          },
          "400": {
            "description": "Invalid request or unavailable chat model. Model selection failures use `model_not_priced`, `model_retired`, or `model_unavailable` and include `error.suggested_model` when a current alternative is available.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/GenericError"
                    },
                    {
                      "$ref": "#/components/schemas/GatewayModelSelectionError"
                    }
                  ]
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Anthropic-compatible messages endpoint",
        "tags": [
          "messages"
        ]
      }
    },
    "/api/v1/meter": {
      "post": {
        "description": "Accepts token counts and model metadata from a client. The beacon does not receive a receipt signature. A receipt hash supplied without signature proof is stored as unverified and is not counted in public transparency totals. The public receipt-inclusion endpoint reports `pending` unless a verified record exists for that hash.",
        "operationId": "v1Meter",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "beacon_nonce": {
                    "maxLength": 128,
                    "pattern": "^[A-Za-z0-9_.:-]+$",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "input_tokens": {
                    "maximum": 20000000,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "model": {
                    "maxLength": 80,
                    "pattern": "^[A-Za-z0-9][A-Za-z0-9._:/+\\-]{0,79}$",
                    "type": "string"
                  },
                  "nonce": {
                    "maxLength": 128,
                    "minLength": 8,
                    "pattern": "^[A-Za-z0-9_.:-]+$",
                    "type": "string"
                  },
                  "output_tokens": {
                    "maximum": 20000000,
                    "minimum": 0,
                    "type": "integer"
                  },
                  "provider": {
                    "maxLength": 40,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "receipt_hash": {
                    "pattern": "^[A-Fa-f0-9]{64}$",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "surface": {
                    "enum": [
                      "extension",
                      "desktop",
                      "proxy",
                      "proxy-direct",
                      null
                    ],
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "ts": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "model",
                  "input_tokens",
                  "output_tokens",
                  "ts",
                  "nonce"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "anchoring": {
                      "properties": {
                        "anchored": {
                          "type": "boolean"
                        },
                        "beacon_nonce": {
                          "type": "string"
                        },
                        "inclusion_state": {
                          "enum": [
                            "pending",
                            "anchored"
                          ],
                          "type": "string"
                        },
                        "receipt_hash": {
                          "pattern": "^[a-f0-9]{64}$",
                          "type": "string"
                        },
                        "seed_hash": {
                          "pattern": "^[a-f0-9]{64}$",
                          "type": "string"
                        },
                        "verified": {
                          "const": false,
                          "type": "boolean"
                        }
                      },
                      "type": "object"
                    },
                    "balance_cents": {
                      "type": "integer"
                    },
                    "billed": {
                      "type": "boolean"
                    },
                    "fee_cents": {
                      "type": "integer"
                    },
                    "metered": {
                      "type": "boolean"
                    },
                    "balance_micros": {
                      "description": "Exact wallet balance in USD micro-dollars after the metered call.",
                      "type": "integer"
                    }
                  },
                  "type": "object"
                }
              }
            },
            "description": "Meter result. If `anchoring` is present, `verified` is false because this beacon request carries no signature proof."
          },
          "401": {
            "description": "The API key is missing or invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "402": {
            "description": "The prepaid balance does not cover the metering fee.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "The beacon body must use application/json.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The counts-only beacon fields are invalid or the model has no price reference.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "The metering beacon could not be recorded; retry with the same nonce.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Report token counts to the metering beacon",
        "tags": [
          "billing"
        ]
      }
    },
    "/api/v1/metrics/receipt-verifier": {
      "post": {
        "description": "Records a public receipt-verifier usage result without returning a response body.",
        "operationId": "PostMetricsReceiptVerifier",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "client": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "error_class": {
                    "maxLength": 64,
                    "type": "string"
                  },
                  "ok": {
                    "type": "boolean"
                  },
                  "version": {
                    "enum": [
                      1,
                      2
                    ],
                    "type": "integer"
                  }
                },
                "required": [
                  "version",
                  "ok"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "204": {
            "description": "The verifier metric was accepted without a response body."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMetricsValidationError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "POST metrics/receipt-verifier",
        "tags": [
          "metrics"
        ]
      }
    },
    "/api/v1/models": {
      "get": {
        "description": "Returns an OpenAI-style model list for active providers whose models pass the gateway's canonical-ID and routability checks. Each listed model may include provider, context-window, and capability metadata; the endpoint uses API-key gateway middleware.",
        "operationId": "v1Models",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "properties": {
                          "capabilities": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "context_window": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "created": {
                            "type": "integer"
                          },
                          "id": {
                            "type": "string"
                          },
                          "object": {
                            "const": "model",
                            "type": "string"
                          },
                          "owned_by": {
                            "type": "string"
                          },
                          "provider": {
                            "type": "string"
                          },
                          "provider_name": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "trial_locked": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "id",
                          "object",
                          "created",
                          "owned_by",
                          "provider",
                          "provider_name",
                          "trial_locked"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "object": {
                      "const": "list",
                      "type": "string"
                    },
                    "trial": {
                      "type": "object",
                      "properties": {
                        "is_trial": {
                          "type": "boolean"
                        },
                        "enforced": {
                          "type": "boolean"
                        },
                        "allowed_models": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        },
                        "minimum_top_up_cents": {
                          "type": [
                            "integer",
                            "null"
                          ]
                        }
                      },
                      "required": [
                        "is_trial",
                        "enforced",
                        "allowed_models",
                        "minimum_top_up_cents"
                      ]
                    }
                  },
                  "required": [
                    "object",
                    "data",
                    "trial"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Active, routable canonical models in the OpenAI list shape; cached for up to 30 minutes."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing, invalid, expired, or account-bound API key."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The API key does not allow requests from this source IP address."
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyConflict"
          },
          "410": {
            "$ref": "#/components/responses/GatewayModelUnavailable"
          },
          "400": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "402": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "List available models across all providers",
        "tags": [
          "providers"
        ]
      }
    },
    "/api/v1/onboarding-state": {
      "get": {
        "description": "Returns the authenticated user’s Terms of Service and Privacy Policy acceptance timestamps and version identifiers.",
        "operationId": "getLegalOnboardingState",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegalOnboardingState"
                }
              }
            },
            "description": "Current legal acceptance state. Values are null until accepted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "too_many_attempts",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "scope": {
                          "const": "route",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The route limit of 60 requests per minute was exceeded. An edge rate limit may return an HTML error page.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "minimum": 1,
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "const": "route",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Read legal acceptance state",
        "tags": [
          "onboarding"
        ]
      },
      "post": {
        "description": "Records the authenticated user’s acceptance of the Terms of Service and Privacy Policy. Both timestamps must be valid dates and both version identifiers are required. The submitted timestamps are validated but the server records the acceptance time when it handles the request.",
        "operationId": "recordLegalOnboardingAcceptance",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RecordLegalOnboardingAcceptance"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LegalOnboardingState"
                }
              }
            },
            "description": "Legal acceptance recorded."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "unauthenticated",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Authentication is missing or invalid."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "fields": {
                              "additionalProperties": {
                                "items": {
                                  "type": "string"
                                },
                                "type": "array"
                              },
                              "type": "object"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        },
                        {
                          "additionalProperties": true,
                          "properties": {
                            "code": {
                              "type": "string"
                            },
                            "message": {
                              "type": "string"
                            }
                          },
                          "required": [],
                          "type": "object"
                        }
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "One or more required values are missing or invalid."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "additionalProperties": true,
                      "properties": {
                        "code": {
                          "const": "too_many_attempts",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "minimum": 1,
                          "type": "integer"
                        },
                        "scope": {
                          "const": "route",
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The route limit of 60 requests per minute was exceeded. An edge rate limit may return an HTML error page.",
            "headers": {
              "Retry-After": {
                "description": "Seconds to wait before retrying.",
                "schema": {
                  "minimum": 1,
                  "type": "integer"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "const": "route",
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Record legal acceptance",
        "tags": [
          "onboarding"
        ]
      }
    },
    "/api/v1/organisation": {
      "delete": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "DeleteOrganisation",
        "parameters": [],
        "responses": {
          "202": {
            "description": "Deletion scheduled (or already scheduled)."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete organisation",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/cancel-deletion": {
      "post": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "PostOrganisationCancelDeletion",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post cancel-deletion",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/invitations": {
      "get": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "GetOrganisationInvitations",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get invitations",
        "tags": [
          "Organisation"
        ]
      },
      "post": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "PostOrganisationInvitations",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationInvite"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "invitation": {
                      "additionalProperties": true,
                      "type": "object"
                    },
                    "email_sent": {
                      "description": "Whether the mail send call completed without throwing; this does not confirm inbox delivery.",
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "email_sent",
                    "invitation",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Pending invitations return 200. `email_sent` reports whether the mail send call completed; the invitation remains pending if it did not."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "invite_limit_reached when the organisation has created 150 invitations in the last 24 hours. The body is {\"error\":\"invite_limit_reached\",\"message\":\"Daily invitation limit reached. Try again later.\"}. Other 429 responses on this route may still be the shared error object. An edge rate limit may return an HTML error page."
          },
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "invitation": {
                      "additionalProperties": true,
                      "type": "object"
                    },
                    "email_sent": {
                      "description": "Whether the mail send call completed without throwing; this does not confirm inbox delivery.",
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "email_sent",
                    "invitation",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "A new invitation was created. `email_sent` reports whether the mail send call completed; the invitation remains pending if it did not."
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post invitations",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/invitations/accept": {
      "post": {
        "description": "Accepts an organisation invitation. The body does not include seat_limit.",
        "operationId": "PostOrganisationInvitationsAccept",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationAcceptInvitation"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post accept",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/invitations/lookup/{id}": {
      "get": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "GetOrganisationInvitationsLookupId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get item",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/invitations/{id}": {
      "delete": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "DeleteOrganisationInvitationsId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete item",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/me": {
      "get": {
        "description": "Returns the authenticated user's organisation. The body does not include seat_limit.",
        "operationId": "GetOrganisationMe",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get me",
        "tags": [
          "Organisation"
        ]
      },
      "patch": {
        "description": "Updates the authenticated user's organisation. The body does not include seat_limit.",
        "operationId": "PatchOrganisationMe",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationUpdate"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "500": {
            "description": "The operation failed because of a server error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Patch me",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/members": {
      "get": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "GetOrganisationMembers",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get members",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/members/{id}": {
      "delete": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "DeleteOrganisationMembersId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Deleted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete item",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/members/{id}/role": {
      "patch": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "PatchOrganisationMembersIdRole",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationMemberRole"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Patch role",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/notifications": {
      "patch": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "PatchOrganisationNotifications",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationNotifications"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Patch notifications",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/organisation/security": {
      "get": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "GetOrganisationSecurity",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get security",
        "tags": [
          "Organisation"
        ]
      },
      "patch": {
        "description": "Manage the authenticated user’s organisation profile, members, invitations, or deletion schedule.",
        "operationId": "PatchOrganisationSecurity",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OrggrcOrganisationSecurity"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Patch security",
        "tags": [
          "Organisation"
        ]
      }
    },
    "/api/v1/personas/keys": {
      "post": {
        "description": "Creates a persona key and returns the desktop share and optional vault share. Nextcloud recovery was not tested end to end before launch. Test a restore before relying on it.",
        "operationId": "privacyPostApiV1PersonasKeys",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "threshold": 2,
                "vault_passphrase": "demo-passphrase-123",
                "vault_provider": "internxt"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "threshold": {
                    "enum": [
                      2,
                      3
                    ],
                    "type": "integer"
                  },
                  "vault_passphrase": {
                    "maxLength": 512,
                    "minLength": 12,
                    "type": "string"
                  },
                  "vault_provider": {
                    "enum": [
                      "internxt",
                      "proton-drive",
                      "tresorit",
                      "self-host-nextcloud",
                      "desktop-only"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaKey"
                }
              }
            },
            "description": "Persona key created."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "An active persona key already exists."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "An unexpected key operation failure."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Enroll a persona key",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/active": {
      "get": {
        "description": "Returns active persona key metadata, or null when no active key exists.",
        "operationId": "privacyGetApiV1PersonasKeysActive",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaActive"
                }
              }
            },
            "description": "Active key metadata."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "additionalProperties": false
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page.",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "string",
                  "pattern": "^[1-9][0-9]*$"
                }
              },
              "X-RateLimit-Scope": {
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get active persona key metadata",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/audit-decode": {
      "post": {
        "description": "Records a decode event for the supplied key and receipt identifiers.",
        "operationId": "privacyPostApiV1PersonasKeysAuditDecode",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "kid": "example-value",
                "receipt_jti": "example-value"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "kid": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "receipt_jti": {
                    "maxLength": 128,
                    "type": "string"
                  }
                },
                "required": [
                  "kid",
                  "receipt_jti"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyAuditDecode"
                }
              }
            },
            "description": "Decode event recorded."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Persona key not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Record a persona decode event",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/rotate": {
      "post": {
        "description": "Rotates the authenticated tenant’s persona key with an optional overlap window.",
        "operationId": "privacyPostApiV1PersonasKeysRotate",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "overlap_days": 1,
                "vault_passphrase": "demo-passphrase-123"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "overlap_days": {
                    "maximum": 365,
                    "minimum": 1,
                    "type": "integer"
                  },
                  "vault_passphrase": {
                    "maxLength": 512,
                    "minLength": 12,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaKey"
                }
              }
            },
            "description": "Rotated persona key."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "An unexpected key operation failure."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Rotate the persona key",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/share-fetch": {
      "post": {
        "description": "Fetches the requested share for the authenticated tenant.",
        "operationId": "privacyPostApiV1PersonasKeysShareFetch",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "kid": "example-value"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "kid": {
                    "maxLength": 128,
                    "type": "string"
                  }
                },
                "required": [
                  "kid"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyShare"
                }
              }
            },
            "description": "Fetched share."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "No retrievable share exists for that key identifier."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Fetch persona share 2",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/threshold": {
      "patch": {
        "description": "Updates the recovery threshold in the caller’s privacy panel state.",
        "operationId": "privacyPatchApiV1PersonasKeysThreshold",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "threshold": "3-of-3"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "threshold": {
                    "enum": [
                      "3-of-3",
                      "2-of-3"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "threshold"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaThreshold"
                }
              }
            },
            "description": "Threshold result."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update recovery threshold",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/vault-enrol": {
      "post": {
        "description": "Stores the selected provider and threshold in the caller’s privacy panel state. Nextcloud recovery was not tested end to end before launch. Test a restore before relying on it.",
        "operationId": "privacyPostApiV1PersonasKeysVaultEnrol",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "provider": "proton-drive",
                "threshold": "3-of-3"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "provider": {
                    "enum": [
                      "proton-drive",
                      "internxt",
                      "tresorit",
                      "self-host-nextcloud",
                      "none"
                    ],
                    "type": "string"
                  },
                  "threshold": {
                    "enum": [
                      "3-of-3",
                      "2-of-3"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "provider",
                  "threshold"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaVaultEnrol"
                }
              }
            },
            "description": "Enrollment result."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Enroll a recovery vault",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/personas/keys/vault-providers": {
      "get": {
        "description": "Returns the controller’s provider catalog.",
        "operationId": "privacyGetApiV1PersonasKeysVaultProviders",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaVaultProviders"
                }
              }
            },
            "description": "Provider catalog."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List recovery vault providers",
        "tags": [
          "Persona keys"
        ]
      }
    },
    "/api/v1/pretokenised/mac": {
      "post": {
        "description": "Calculates a request MAC for an already-tokenized body.",
        "operationId": "PostPretokenisedMac",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {}
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMac"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMacAuthError"
                }
              }
            },
            "description": "A valid tenant credential is required."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMacAuthError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "POST pretokenised/mac",
        "tags": [
          "pretokenised"
        ]
      }
    },
    "/api/v1/privacy/cancel": {
      "post": {
        "description": "Clears the pending tier preview and returns current state.",
        "operationId": "privacyPostApiV1PrivacyCancel",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after clearing pending preview."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Cancel a privacy tier preview",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/commit": {
      "post": {
        "description": "Applies the pending tier selection and clears the preview.",
        "operationId": "privacyPostApiV1PrivacyCommit",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after commit."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "No preview is pending."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Commit a privacy tier preview",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/onboarding": {
      "get": {
        "description": "Returns the caller’s persisted onboarding fields.",
        "operationId": "privacyGetApiV1PrivacyOnboarding",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyOnboarding"
                }
              }
            },
            "description": "Onboarding state."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get privacy onboarding state",
        "tags": [
          "Privacy"
        ]
      },
      "patch": {
        "description": "Updates supplied onboarding fields; retired tier picks may be normalized by the controller.",
        "operationId": "privacyPatchApiV1PrivacyOnboarding",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "desktop_offered": true,
                "first_test_call_completed": true,
                "tier_picked_during_onboarding": "max"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "desktop_offered": {
                    "type": "boolean"
                  },
                  "first_call_modal_seen_at": {
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "first_test_call_completed": {
                    "type": "boolean"
                  },
                  "tier_picked_during_onboarding": {
                    "enum": [
                      "max",
                      "balanced",
                      "custom",
                      "continuity",
                      "off",
                      null
                    ],
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyOnboarding"
                }
              }
            },
            "description": "Updated onboarding state."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update privacy onboarding state",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/preview": {
      "post": {
        "description": "Stores a pending tier selection for the authenticated user. This endpoint does not accept sample message content.",
        "operationId": "privacyPostApiV1PrivacyPreview",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "base_tier": "max",
                "source": "preset",
                "tier": "max",
                "tier_id": "max"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "base_tier": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  },
                  "source": {
                    "enum": [
                      "preset",
                      "custom"
                    ],
                    "type": "string"
                  },
                  "tier": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  },
                  "tier_id": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "Updated state with pending preview."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Preview a privacy tier change",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state": {
      "get": {
        "description": "Returns the caller’s active tier and stored privacy panel preferences.",
        "operationId": "privacyGetApiV1PrivacyState",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "Privacy panel state."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get privacy panel state",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state/active-tier": {
      "patch": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPatchActiveTier",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "source": "preset",
                "tier": "balanced"
              },
              "schema": {
                "additionalProperties": false,
                "anyOf": [
                  {
                    "properties": {
                      "source": {
                        "enum": [
                          "preset",
                          "custom"
                        ],
                        "type": "string"
                      },
                      "tier": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      },
                      "tier_id": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "tier"
                    ]
                  },
                  {
                    "properties": {
                      "source": {
                        "enum": [
                          "preset",
                          "custom"
                        ],
                        "type": "string"
                      },
                      "tier": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      },
                      "tier_id": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "tier_id"
                    ]
                  }
                ],
                "properties": {
                  "source": {
                    "enum": [
                      "preset",
                      "custom"
                    ],
                    "type": "string"
                  },
                  "tier": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  },
                  "tier_id": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update active tier",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPostActiveTier",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "source": "preset",
                "tier": "balanced"
              },
              "schema": {
                "additionalProperties": false,
                "anyOf": [
                  {
                    "properties": {
                      "source": {
                        "enum": [
                          "preset",
                          "custom"
                        ],
                        "type": "string"
                      },
                      "tier": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      },
                      "tier_id": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "tier"
                    ]
                  },
                  {
                    "properties": {
                      "source": {
                        "enum": [
                          "preset",
                          "custom"
                        ],
                        "type": "string"
                      },
                      "tier": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      },
                      "tier_id": {
                        "enum": [
                          "max",
                          "balanced"
                        ],
                        "type": "string"
                      }
                    },
                    "required": [
                      "tier_id"
                    ]
                  }
                ],
                "properties": {
                  "source": {
                    "enum": [
                      "preset",
                      "custom"
                    ],
                    "type": "string"
                  },
                  "tier": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  },
                  "tier_id": {
                    "enum": [
                      "max",
                      "balanced"
                    ],
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update active tier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state/classifier": {
      "patch": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPatchClassifier",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "mode": "standard"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "mode": {
                    "enum": [
                      "off",
                      "standard",
                      "power",
                      "light"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "mode"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update classifier",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPostClassifier",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "mode": "standard"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "mode": {
                    "enum": [
                      "off",
                      "standard",
                      "power",
                      "light"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "mode"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update classifier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state/hardware-backed": {
      "patch": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPatchHardwareBacked",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "device_name": "Test laptop",
                "enabled": true
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "authenticator_attachment": {
                    "enum": [
                      "platform",
                      "cross-platform",
                      null
                    ],
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "credential_id": {
                    "maxLength": 1024,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "detected_platform": {
                    "maxLength": 120,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "device_name": {
                    "maxLength": 120,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update hardware backed",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPostHardwareBacked",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "device_name": "Test laptop",
                "enabled": true
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "authenticator_attachment": {
                    "enum": [
                      "platform",
                      "cross-platform",
                      null
                    ],
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "credential_id": {
                    "maxLength": 1024,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "detected_platform": {
                    "maxLength": 120,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "device_name": {
                    "maxLength": 120,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "enabled": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "enabled"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update hardware backed",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state/rotation": {
      "patch": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPatchRotation",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "per_chat": {
                    "type": "boolean"
                  },
                  "schedule": {
                    "enum": [
                      "never",
                      "daily",
                      "weekly",
                      "monthly",
                      "quarterly",
                      "yearly"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "schedule",
                  "per_chat"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "description": "The privacy state request is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update rotation",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPostRotation",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "per_chat": {
                    "type": "boolean"
                  },
                  "schedule": {
                    "enum": [
                      "never",
                      "daily",
                      "weekly",
                      "monthly",
                      "quarterly",
                      "yearly"
                    ],
                    "type": "string"
                  }
                },
                "required": [
                  "schedule",
                  "per_chat"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "State after the requested operation.",
            "example": {
              "active_tier": "balanced",
              "active_tier_source": "preset",
              "classifier_mode": "standard",
              "classifier_model_id": "classifier-v1",
              "committed": {
                "source": "preset",
                "tier": "balanced"
              },
              "hardware_backed": {
                "enabled": false
              },
              "preview": null,
              "recovery_vault": {},
              "rotation": {
                "per_chat": true,
                "schedule": "monthly"
              },
              "transparency_log": {
                "enrolled": null,
                "mutable": false,
                "mutable_reason": "not configured",
                "publish_seed_hmac": null,
                "source": "unknown",
                "stored_preference": true
              }
            }
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "422": {
            "description": "The privacy state request is invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "validation_error"
                        },
                        "message": {
                          "type": "string"
                        },
                        "fields": {
                          "type": "object",
                          "additionalProperties": {
                            "type": "array",
                            "items": {
                              "type": "string"
                            }
                          }
                        }
                      },
                      "additionalProperties": false,
                      "required": [
                        "code",
                        "message",
                        "fields"
                      ]
                    }
                  },
                  "additionalProperties": false,
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update rotation",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/state/transparency-log": {
      "patch": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPatchTransparencyLog",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "publish_seed_hmac": false
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "publish_seed_hmac": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "publish_seed_hmac"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "The preference is stored but the public log action has not been applied."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update transparency log",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Updates the caller privacy state through the configured privacy control.",
        "operationId": "privacyPostTransparencyLog",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "publish_seed_hmac": false
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "publish_seed_hmac": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "publish_seed_hmac"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The caller lacks a required ability or permission."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPrivacyState"
                }
              }
            },
            "description": "The preference is stored but the public log action has not been applied."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update transparency log",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers": {
      "get": {
        "description": "Returns base tier descriptors and the caller’s custom tiers.",
        "operationId": "privacyGetApiV1PrivacyTiers",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyTierList"
                }
              }
            },
            "description": "Tier catalog."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List available privacy tiers",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/active": {
      "get": {
        "description": "Returns the resolved base/custom tier and resolution metadata.",
        "operationId": "privacyGetApiV1PrivacyTiersActive",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyActiveTier"
                }
              }
            },
            "description": "Resolved tier."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get the resolved privacy tier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/custom": {
      "get": {
        "description": "Returns custom tiers owned by the authenticated user and the per-user limit.",
        "operationId": "privacyGetApiV1PrivacyTiersCustom",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyCustomTierList"
                }
              }
            },
            "description": "Custom tier list."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List custom privacy tiers",
        "tags": [
          "Privacy"
        ]
      },
      "post": {
        "description": "Creates a custom tier from the supplied name, optional description, and rules.",
        "operationId": "privacyPostApiV1PrivacyTiersCustom",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "name": "Demo integration",
                "rules": {
                  "email": "balanced"
                }
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "description": {
                    "maxLength": 255,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "maxLength": 80,
                    "type": "string"
                  },
                  "rules": {
                    "additionalProperties": {
                      "enum": [
                        "max",
                        "balanced"
                      ],
                      "type": "string"
                    },
                    "example": {
                      "email": "balanced",
                      "phone": "max"
                    },
                    "minProperties": 1,
                    "propertyNames": {
                      "pattern": "^[a-z0-9._\\-]{1,64}$",
                      "type": "string"
                    },
                    "type": "object"
                  }
                },
                "required": [
                  "name",
                  "rules"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyTierEnvelope"
                }
              }
            },
            "description": "Created tier."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create a custom privacy tier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/custom/{id}": {
      "delete": {
        "description": "Deletes a custom tier belonging to the authenticated user.",
        "operationId": "privacyDeleteApiV1PrivacyTiersCustomId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyDeleteTier"
                }
              }
            },
            "description": "Deletion result."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Tier not found."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete a custom privacy tier",
        "tags": [
          "Privacy"
        ]
      },
      "get": {
        "description": "Returns a custom tier belonging to the authenticated user.",
        "operationId": "privacyGetApiV1PrivacyTiersCustomId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyTierEnvelope"
                }
              }
            },
            "description": "Custom tier."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Tier not found."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get a custom privacy tier",
        "tags": [
          "Privacy"
        ]
      },
      "patch": {
        "description": "Updates supplied fields on a custom tier belonging to the authenticated user.",
        "operationId": "privacyPatchApiV1PrivacyTiersCustomId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "name": "Demo integration",
                "rules": {
                  "email": "balanced"
                }
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "description": {
                    "maxLength": 255,
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "name": {
                    "maxLength": 80,
                    "type": "string"
                  },
                  "rules": {
                    "additionalProperties": {
                      "enum": [
                        "max",
                        "balanced"
                      ],
                      "type": "string"
                    },
                    "example": {
                      "email": "balanced",
                      "phone": "max"
                    },
                    "minProperties": 1,
                    "propertyNames": {
                      "pattern": "^[a-z0-9._\\-]{1,64}$",
                      "type": "string"
                    },
                    "type": "object"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyTierEnvelope"
                }
              }
            },
            "description": "Updated tier."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Tier not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update a custom privacy tier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/custom/{id}/preview-change": {
      "post": {
        "description": "Returns a summary of changes for the requested target tier and source.",
        "operationId": "privacyPostApiV1PrivacyTiersCustomIdPreviewChange",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "source": "preset",
                "to": "example-value"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "source": {
                    "enum": [
                      "preset",
                      "custom"
                    ],
                    "type": "string"
                  },
                  "to": {
                    "maxLength": 80,
                    "type": "string"
                  }
                },
                "required": [
                  "to",
                  "source"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPreviewChange"
                }
              }
            },
            "description": "Tier-change summary."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Preview a custom tier change",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/custom/{id}/rotate-chat": {
      "post": {
        "description": "Rotates the per-chat seed for the supplied chat identifier.",
        "operationId": "privacyPostApiV1PrivacyTiersCustomIdRotateChat",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "chat_id": "example-value"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "chat_id": {
                    "maxLength": 128,
                    "type": "string"
                  }
                },
                "required": [
                  "chat_id"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyChatRotation"
                }
              }
            },
            "description": "Rotation result."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Rotate a custom tier chat seed",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/custom/{id}/rotate-personas": {
      "post": {
        "description": "Rotates all persona seeds for the authenticated user.",
        "operationId": "privacyPostApiV1PrivacyTiersCustomIdRotatePersonas",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPersonaRotateAll"
                }
              }
            },
            "description": "Rotation result."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Rotate persona seeds for a custom tier",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/presets": {
      "get": {
        "description": "Returns preset descriptors and benchmark provenance.",
        "operationId": "privacyGetApiV1PrivacyTiersPresets",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPresetList"
                }
              }
            },
            "description": "Preset descriptors."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List preset privacy tiers",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/privacy/tiers/preview-change": {
      "get": {
        "description": "Returns a tier-change summary for the supplied target and source.",
        "operationId": "privacyGetApiV1PrivacyTiersPreviewChange",
        "parameters": [
          {
            "description": "Target tier identifier.",
            "in": "query",
            "name": "to",
            "required": true,
            "schema": {
              "maxLength": 80,
              "type": "string"
            }
          },
          {
            "description": "Target tier source.",
            "in": "query",
            "name": "source",
            "required": true,
            "schema": {
              "enum": [
                "preset",
                "custom"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyPreviewChange"
                }
              }
            },
            "description": "Tier-change summary."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Authentication is required."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The required target tier or source failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Preview a preset or custom tier change",
        "tags": [
          "Privacy"
        ]
      }
    },
    "/api/v1/probe/upstream/{id}": {
      "get": {
        "description": "Retrieve a captured upstream request payload for the reserved synthetic privacy probe account.",
        "operationId": "GetProbeUpstreamId",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "400": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          }
        ],
        "summary": "Get item",
        "tags": [
          "Probe"
        ]
      }
    },
    "/api/v1/providers/route": {
      "post": {
        "description": "Resolve the available provider routing options for the authenticated request.",
        "operationId": "PostProvidersRoute",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Operation completed successfully."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "Authentication is required or invalid."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The authenticated user is not permitted to perform this operation."
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The requested resource was not found."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorWithCode"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request was rate limited. An edge rate limit may return an HTML error page."
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Post route",
        "tags": [
          "Providers"
        ]
      }
    },
    "/api/v1/providers/routing": {
      "get": {
        "description": "Returns provider routing configuration for the authenticated tenant. Saved provider-routing rules are not applied to requests yet. No usage is logged.\n",
        "operationId": "v1ProvidersRouting",
        "responses": {
          "200": {
            "description": "Routing table"
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get current provider routing table",
        "tags": [
          "providers"
        ]
      }
    },
    "/api/v1/receipt/chain-status": {
      "get": {
        "description": "Returns the cached receipt-chain status derived from the latest client-submitted chain claim. The gateway does not independently verify the client's chain; a result may remain `never_verified` until a claim is submitted. The route accepts an API key or bearer token and caches the result for five minutes. This operation is also available under the versioned path.",
        "operationId": "receiptChainStatusV1Alias",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "active_key_fingerprint": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "break_detected_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "chain_ok": {
                      "type": [
                        "boolean",
                        "null"
                      ]
                    },
                    "entries_verified": {
                      "type": "integer"
                    },
                    "last_verified_at": {
                      "format": "date-time",
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "verification_state": {
                      "enum": [
                        "never_verified",
                        "client_claimed",
                        "verified",
                        "break_detected"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "chain_ok",
                    "verification_state",
                    "last_verified_at",
                    "break_detected_at",
                    "entries_verified",
                    "active_key_fingerprint"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Cached receipt-chain state based on the latest client claim; the gateway does not verify the chain."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid API key or bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Get receipt chain health status",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipt/chain-verify": {
      "post": {
        "description": "Records the caller's reported chain result and invalidates the cached status. This is a client claim, not gateway verification; the response echoes the submitted `chain_ok` value and does not attest that the claim is true. This operation is also available under the versioned path.",
        "operationId": "submitChainClaimV1Alias",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "break_detected_at": null,
                  "chain_ok": true,
                  "entries_verified": 42
                },
                "properties": {
                  "break_detected_at": {
                    "format": "date-time",
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "chain_ok": {
                    "type": "boolean"
                  },
                  "entries_verified": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "chain_ok",
                  "entries_verified"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "chain_ok": {
                      "type": "boolean"
                    },
                    "recorded": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "recorded",
                    "chain_ok"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Client claim recorded."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid API key or bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "422": {
            "description": "Claim fields failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "Verify a receipt chain segment",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts": {
      "get": {
        "description": "Lists receipts visible to the authenticated user or API key.",
        "operationId": "GetReceipts",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "per_page",
            "required": false,
            "schema": {
              "default": 20,
              "example": 20,
              "maximum": 100,
              "minimum": 1,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "provider",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "chain_id",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "surface",
            "required": false,
            "schema": {
              "enum": [
                "chat",
                "api",
                "extension",
                "desktop-local"
              ],
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "properties": {
                          "chain_seq": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "created_at": {
                            "format": "date-time",
                            "type": "string"
                          },
                          "jti": {
                            "type": "string"
                          },
                          "mode": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "model": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "provider": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "surface": {
                            "enum": [
                              "chat",
                              "api",
                              "extension",
                              "desktop-local"
                            ],
                            "type": "string"
                          },
                          "tier": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "tokens_in": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "tokens_out": {
                            "type": [
                              "integer",
                              "null"
                            ]
                          },
                          "verifiable": {
                            "type": "boolean"
                          }
                        },
                        "type": "object"
                      },
                      "type": "array"
                    },
                    "links": {
                      "properties": {
                        "next": {
                          "format": "uri",
                          "type": [
                            "string",
                            "null"
                          ]
                        },
                        "prev": {
                          "format": "uri",
                          "type": [
                            "string",
                            "null"
                          ]
                        }
                      },
                      "type": "object"
                    },
                    "meta": {
                      "properties": {
                        "current_page": {
                          "type": "integer"
                        },
                        "last_page": {
                          "type": "integer"
                        },
                        "per_page": {
                          "type": "integer"
                        },
                        "surfaces": {
                          "additionalProperties": false,
                          "properties": {
                            "chat_api": {
                              "type": "integer"
                            },
                            "desktop_local": {
                              "type": "integer"
                            },
                            "extension": {
                              "type": "integer"
                            }
                          },
                          "required": [
                            "chat_api",
                            "extension",
                            "desktop_local"
                          ],
                          "type": "object"
                        },
                        "total": {
                          "type": "integer"
                        }
                      },
                      "type": "object"
                    }
                  },
                  "required": [
                    "data",
                    "meta",
                    "links"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "A receipt filter has an invalid value.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "GET receipts",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/by-jti/{jti}": {
      "get": {
        "description": "Looks up a published receipt envelope by JTI.",
        "operationId": "GetReceiptsByJti",
        "parameters": [
          {
            "in": "path",
            "name": "jti",
            "required": true,
            "schema": {
              "pattern": "^[0-9A-Za-z-]+$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsByJti"
                }
              }
            },
            "description": "Successful response."
          },
          "404": {
            "description": "The referenced resource was not found.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "503": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET receipts/by-jti/{}",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/chain/export": {
      "get": {
        "description": "Exports the authenticated account’s receipt chain for local verification.",
        "operationId": "GetReceiptsChainExport",
        "parameters": [
          {
            "in": "query",
            "name": "format",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsChainManifest"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsApiError"
                }
              }
            },
            "description": "The authenticated principal lacks the required permission."
          },
          "422": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "500": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "GET receipts/chain/export",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/chain/report-break": {
      "post": {
        "description": "Records a report when the browser verifier detects a receipt-chain integrity break.",
        "operationId": "PostReceiptsChainReportBreak",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "actual_prev": {
                    "maxLength": 256,
                    "type": "string"
                  },
                  "chain_id": {
                    "maxLength": 128,
                    "type": "string"
                  },
                  "expected_prev": {
                    "maxLength": 256,
                    "type": "string"
                  },
                  "jti": {
                    "maxLength": 128,
                    "minLength": 8,
                    "type": "string"
                  },
                  "reporter_ua": {
                    "maxLength": 512,
                    "type": "string"
                  },
                  "seq": {
                    "minimum": 0,
                    "type": "integer"
                  }
                },
                "required": [
                  "chain_id",
                  "seq",
                  "jti",
                  "expected_prev",
                  "actual_prev"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "logged": {
                      "const": true,
                      "type": "boolean"
                    },
                    "ref": {
                      "maxLength": 12,
                      "minLength": 12,
                      "type": "string"
                    }
                  },
                  "required": [
                    "logged",
                    "ref"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The report was accepted for logging."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsChainBreakError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "POST receipts/chain/report-break",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/countersign": {
      "post": {
        "description": "POST /api/v1/receipts/countersign. Accepts a desktop_receipt with device pairing fields, or a self-contained v3 receipt envelope; returns a gateway-countersigned envelope.",
        "operationId": "PostReceiptsCountersign",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "properties": {
                      "desktop_receipt": {
                        "properties": {
                          "signature": {
                            "type": "string"
                          },
                          "signed_fields": {
                            "additionalProperties": true,
                            "description": "JSON object describing the desktop receipt fields covered by its signature. The gateway checks that security-relevant receipt fields are included; other field names and values are not schema-validated.",
                            "type": "object"
                          }
                        },
                        "required": [
                          "signature",
                          "signed_fields"
                        ],
                        "type": "object"
                      },
                      "device_id": {
                        "format": "uuid",
                        "type": "string"
                      },
                      "gateway_claims": {
                        "additionalProperties": true,
                        "description": "Optional JSON object. The endpoint reads request_id, provider, model, input_tokens, and output_tokens when those values have the expected scalar types; other fields are passed through without schema validation.",
                        "type": "object"
                      },
                      "hash_upstream_response": {
                        "pattern": "^[a-f0-9]{64}$",
                        "type": "string"
                      }
                    },
                    "required": [
                      "device_id",
                      "desktop_receipt",
                      "hash_upstream_response"
                    ],
                    "type": "object"
                  },
                  {
                    "properties": {
                      "claims": {
                        "additionalProperties": true,
                        "description": "JSON object from the OpenReceipt v3 envelope. The endpoint reads tokenisation.tier and selected provider, model, tokens_in, and tokens_out values; other claim fields are retained as receipt payload.",
                        "type": "object"
                      },
                      "sig": {
                        "type": "string"
                      },
                      "v": {
                        "type": "integer"
                      }
                    },
                    "required": [
                      "v",
                      "sig",
                      "claims"
                    ],
                    "type": "object"
                  }
                ]
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsCountersignResponse"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsCountersignError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "413": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "415": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "POST receipts/countersign",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/errata": {
      "get": {
        "description": "Lists signed receipt errata attestations for independent verification.",
        "operationId": "GetReceiptsErrata",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "attestations": {
                      "items": {
                        "$ref": "#/components/schemas/OpenReceiptEnvelope"
                      },
                      "type": "array"
                    },
                    "count": {
                      "type": "integer"
                    },
                    "how_to_verify": {
                      "type": "string"
                    },
                    "jwks": {
                      "format": "uri",
                      "type": "string"
                    },
                    "lookup_key": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "count",
                    "lookup_key",
                    "jwks",
                    "how_to_verify",
                    "attestations"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET receipts/errata",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/verify": {
      "post": {
        "description": "Verifies the ECDSA P-256 signature, the chain linkage, and the claim\nschema. Does not require a logged-in user; verification is public.\n",
        "operationId": "v1ReceiptsVerify",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ReceiptsVerifyRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsVerifyResponse"
                }
              }
            },
            "description": "Verification result"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "error": {
                      "properties": {
                        "code": {
                          "enum": [
                            "invalid_payload"
                          ],
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The request body does not contain a recognised receipt payload."
          },
          "422": {
            "description": "Malformed receipt",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "410": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Verify a receipt envelope",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/receipts/{jti}": {
      "get": {
        "description": "Returns a receipt visible to the authenticated user or API key.",
        "operationId": "getReceiptByJti",
        "parameters": [
          {
            "in": "path",
            "name": "jti",
            "required": true,
            "schema": {
              "pattern": "^[0-9A-Za-z-]+$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsReceiptDetail"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsApiError"
                }
              }
            },
            "description": "The referenced resource was not found."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "ApiKey": []
          },
          {
            "BearerToken": []
          }
        ],
        "summary": "GET receipts/{}",
        "tags": [
          "receipts"
        ]
      }
    },
    "/api/v1/self-service/key": {
      "post": {
        "description": "Creates a free-tier account and returns a newly issued API key. Email and name are optional.",
        "operationId": "privacyPostApiV1SelfServiceKey",
        "requestBody": {
          "content": {
            "application/json": {
              "example": {
                "email": "dev@example.test",
                "name": "Demo integration"
              },
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "email": {
                    "format": "email",
                    "maxLength": 255,
                    "type": "string"
                  },
                  "name": {
                    "maxLength": 100,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacySelfServiceKey"
                }
              }
            },
            "description": "Issued API key."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Organisation sign-in is required."
          },
          "409": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "An account already exists for the supplied email."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "The request rate limit was exceeded. An edge rate limit may return an HTML error page."
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PrivacyError"
                }
              }
            },
            "description": "Signups are temporarily paused."
          }
        },
        "security": [],
        "summary": "Issue a self-service API key",
        "tags": [
          "Self-service"
        ]
      }
    },
    "/api/v1/signedreceipts/submit": {
      "post": {
        "description": "POST /api/v1/signedreceipts/submit. Submits product conformance and JWKS URLs for badge evaluation.",
        "operationId": "PostSignedreceiptsSubmit",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "additionalProperties": false,
                "properties": {
                  "conformance_url": {
                    "format": "uri",
                    "maxLength": 1024,
                    "type": "string"
                  },
                  "contact": {
                    "format": "email",
                    "maxLength": 255,
                    "type": "string"
                  },
                  "jwks_url": {
                    "format": "uri",
                    "maxLength": 1024,
                    "type": "string"
                  },
                  "language": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "licence": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "notes": {
                    "maxLength": 2000,
                    "type": "string"
                  },
                  "product": {
                    "maxLength": 255,
                    "type": "string"
                  },
                  "product_id": {
                    "maxLength": 255,
                    "pattern": "^[a-z0-9]+(-[a-z0-9]+)*$",
                    "type": "string"
                  },
                  "vendor": {
                    "maxLength": 255,
                    "type": "string"
                  }
                },
                "required": [
                  "product",
                  "vendor",
                  "language",
                  "licence",
                  "conformance_url",
                  "jwks_url",
                  "product_id",
                  "contact"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "contact": {
                      "format": "email",
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    },
                    "submission_id": {
                      "type": "integer"
                    },
                    "verdict": {
                      "enum": [
                        "pass",
                        "fail"
                      ],
                      "type": "string"
                    }
                  },
                  "required": [
                    "verdict",
                    "contact",
                    "submission_id"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsSignedSubmitValidationError"
                }
              }
            },
            "description": "The request failed validation."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "POST signedreceipts/submit",
        "tags": [
          "signedreceipts"
        ]
      }
    },
    "/api/v1/tokens/count": {
      "post": {
        "deprecated": true,
        "description": "This endpoint is removed. Estimate tokens on the client; do not send message content for counting.",
        "operationId": "v1TokensCountRemoved",
        "responses": {
          "410": {
            "description": "Endpoint removed; token estimates must be computed on the client.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "401": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Retired token count endpoint",
        "tags": [
          "tokens"
        ]
      }
    },
    "/api/v1/transparency/inclusion": {
      "get": {
        "description": "GET /api/v1/transparency/inclusion. Reads the transparency feed or inclusion status for a receipt hash.",
        "operationId": "GetTransparencyInclusion",
        "parameters": [
          {
            "in": "query",
            "name": "receipt_hash",
            "required": true,
            "schema": {
              "maxLength": 64,
              "minLength": 64,
              "pattern": "^[a-f0-9]{64}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "algorithm": {
                      "type": "string"
                    },
                    "included": {
                      "type": "boolean"
                    },
                    "inclusion_state": {
                      "enum": [
                        "included",
                        "pending"
                      ],
                      "type": "string"
                    },
                    "merkle_root": {
                      "type": "string"
                    },
                    "path": {
                      "items": {
                        "$ref": "#/components/schemas/ReceiptsPublicInclusionPath"
                      },
                      "type": "array"
                    },
                    "receipt_hash": {
                      "pattern": "^[a-f0-9]{64}$",
                      "type": "string"
                    },
                    "seed_hash": {
                      "type": "string"
                    },
                    "seed_index": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "receipt_hash",
                    "included",
                    "inclusion_state",
                    "algorithm"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "422": {
            "description": "receipt_hash is missing or is not a SHA-256 hexadecimal digest.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET transparency/inclusion",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/leaves": {
      "get": {
        "description": "Returns public Merkle leaf records and the canonical bytes used for hashing.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleLeaves",
        "parameters": [
          {
            "in": "query",
            "name": "start",
            "required": false,
            "schema": {
              "default": 0,
              "example": 0,
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "example": 100,
              "maximum": 1000,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleLeaves"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns public Merkle leaf records and the canonical bytes used for hashing.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/proof/consistency": {
      "get": {
        "description": "Returns a consistency proof between the requested tree sizes.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleProofConsistency",
        "parameters": [
          {
            "in": "query",
            "name": "first",
            "required": true,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "second",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleConsistency"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns a consistency proof between the requested tree sizes.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/proof/inclusion": {
      "get": {
        "description": "Returns an inclusion proof for a leaf hash or index at the selected tree size. Supply either leaf_hash or leaf_index; tree_size is optional.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleProofInclusion",
        "parameters": [
          {
            "in": "query",
            "name": "leaf_hash",
            "required": false,
            "schema": {
              "example": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
              "pattern": "^[a-fA-F0-9]{64}$",
              "type": "string"
            }
          },
          {
            "in": "query",
            "name": "leaf_index",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "tree_size",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleInclusion"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns an inclusion proof for a leaf hash or index at the selected tree size.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/spec": {
      "get": {
        "description": "Returns the Merkle algorithm and canonicalisation parameters used by the public log.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleSpec",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleSpec"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns the Merkle algorithm and canonicalisation parameters used by the public log.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/tree-head": {
      "get": {
        "description": "Returns the current signed tree head, or a published head selected by tree_size.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleTreeHead",
        "parameters": [
          {
            "in": "query",
            "name": "tree_size",
            "required": false,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleTreeHead"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns the current signed tree head, or a published head selected by tree_size.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/merkle/tree-heads": {
      "get": {
        "description": "Returns the published signed tree head history.\n\nThe public Merkle endpoints return tree metadata and proofs. Query limits are clamped by the handler.",
        "operationId": "getTransparencyMerkleTreeHeads",
        "parameters": [
          {
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 100,
              "example": 100,
              "maximum": 1000,
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsMerkleTreeHeads"
                }
              }
            },
            "description": "The requested transparency log data."
          },
          "404": {
            "description": "The selected tree head or leaf is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "The log proof could not be produced consistently.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "The query parameters are invalid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "The server-side proof verification failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Returns the published signed tree head history.",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/seeds": {
      "get": {
        "description": "GET /api/v1/transparency/seeds. Reads the transparency feed or inclusion status for a receipt hash.",
        "operationId": "GetTransparencySeeds",
        "parameters": [
          {
            "in": "query",
            "name": "page",
            "required": false,
            "schema": {
              "minimum": 1,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsPublicSeeds"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET transparency/seeds",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/seeds.jsonl": {
      "get": {
        "description": "GET /api/v1/transparency/seeds.jsonl. Reads the transparency feed or inclusion status for a receipt hash.",
        "operationId": "GetTransparencySeedsJsonl",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/x-ndjson": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "description": "Successful response."
          },
          "429": {
            "description": "The route throttle limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "GET transparency/seeds.jsonl",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/state": {
      "get": {
        "description": "GET /api/v1/transparency/state. Reads the transparency feed or inclusion status for a receipt hash.",
        "operationId": "GetTransparencyState",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "latest_seed": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "seed_count": {
                      "type": "integer"
                    }
                  },
                  "required": [
                    "enabled",
                    "latest_seed",
                    "seed_count"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "404": {
            "description": "The authenticated account has no organisation record.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "GET transparency/state",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/transparency/toggle": {
      "post": {
        "description": "POST /api/v1/transparency/toggle. Reads the transparency feed or inclusion status for a receipt hash.",
        "operationId": "PostTransparencyToggle",
        "parameters": [],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "enabled": {
                      "type": "boolean"
                    },
                    "message": {
                      "enum": [
                        "Transparency log enabled.",
                        "Transparency log disabled."
                      ],
                      "type": "string"
                    },
                    "public_feed_updated": {
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "enabled",
                    "public_feed_updated",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Successful response."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Authentication is required or the supplied credentials are not accepted."
          },
          "403": {
            "description": "The authenticated principal lacks the required permission.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "502": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptsTransparencyToggleFailure"
                }
              }
            },
            "description": "The organisation setting was saved but the public transparency feed was not updated."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "POST transparency/toggle",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/v1/webhooks/deliveries": {
      "get": {
        "description": "Lists the most recent 100 delivery attempts for the authenticated organisation. Each row includes the parent endpoint id and the response-status alias.",
        "operationId": "v1WebhookDeliveriesList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/WebhookDeliveryListItem"
                      },
                      "maxItems": 100,
                      "type": "array"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Up to 100 recent delivery attempts."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "An authenticated user with an unverified email address receives 403."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List the last 100 delivery attempts across all of the organisation's endpoints",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/deliveries/{deliveryId}": {
      "get": {
        "description": "Returns the full delivery record for a delivery belonging to the authenticated organisation, with endpoint and response-status aliases. A missing or other-organisation delivery returns 404.",
        "operationId": "v1WebhookDeliveriesShow",
        "parameters": [
          {
            "in": "path",
            "name": "deliveryId",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookDeliveryC6b"
                }
              }
            },
            "description": "Full delivery record."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "An authenticated user with an unverified email address receives 403."
          },
          "404": {
            "description": "Delivery was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get a single webhook delivery attempt",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/deliveries/{deliveryId}/replay": {
      "post": {
        "description": "Dispatches a new delivery row using an existing delivery's event and payload. Requires `webhooks.manage` and the write ability; it does not rewrite the original row. A missing or out-of-organisation delivery returns 404.",
        "operationId": "v1WebhookDeliveriesReplay",
        "parameters": [
          {
            "in": "path",
            "name": "deliveryId",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "ok": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Replay dispatched as a new delivery."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "404": {
            "description": "Delivery was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Replay a past delivery as a fresh attempt",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/endpoints": {
      "get": {
        "description": "Lists the authenticated organisation's webhook endpoints with ID, URL, subscribed events, active state, and creation time. The endpoint secret is not returned.",
        "operationId": "v1WebhookEndpointsList",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "data": {
                      "items": {
                        "$ref": "#/components/schemas/WebhookEndpoint"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "data"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Organisation's webhook endpoints."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "An authenticated user with an unverified email address receives 403."
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List webhook endpoints for the calling tenant",
        "tags": [
          "webhooks"
        ]
      },
      "post": {
        "description": "Creates an active webhook endpoint for the authenticated organisation. Requires `webhooks.manage` and the write ability. `url` must be a publicly reachable HTTPS endpoint on port 443 without URL credentials; private, loopback, reserved, and metadata destinations return 422. Redirects are not followed during delivery. `url` is limited to 512 characters. `events` is optional; when supplied it must be a non-empty list of registered event names, `*`, or a registered namespace wildcard such as `receipt.*`. The HMAC secret is returned once and must be stored by the caller.",
        "operationId": "v1WebhookEndpointsCreate",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "events": [
                    "receipt.signed"
                  ],
                  "url": "https://hooks.example.com/cloakapi"
                },
                "properties": {
                  "events": {
                    "items": {
                      "enum": [
                        "*",
                        "receipt.signed",
                        "chain.broken",
                        "chain.repaired",
                        "user.created",
                        "user.deleted",
                        "org.member_added",
                        "key.created",
                        "key.revoked",
                        "key.rotated",
                        "billing.low_balance",
                        "billing.credit_added",
                        "billing.invoice_paid",
                        "subscriber.bounced",
                        "subscriber.unsubscribed",
                        "webhook.test",
                        "receipt.*",
                        "chain.*",
                        "user.*",
                        "org.*",
                        "key.*",
                        "billing.*",
                        "subscriber.*",
                        "webhook.*"
                      ],
                      "maxLength": 64,
                      "type": "string"
                    },
                    "minItems": 1,
                    "type": "array"
                  },
                  "url": {
                    "description": "Publicly reachable HTTPS URL on port 443; private, loopback, reserved, and metadata targets are rejected.",
                    "format": "uri",
                    "maxLength": 512,
                    "type": "string"
                  }
                },
                "required": [
                  "url"
                ],
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "201": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "events": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "is_active": {
                      "const": true,
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string",
                      "writeOnly": true
                    },
                    "url": {
                      "format": "uri",
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "url",
                    "events",
                    "is_active",
                    "secret",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Endpoint created; secret is returned once."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "422": {
            "description": "Validation failed or the destination URL is unsafe.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Create a webhook endpoint",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/endpoints/{id}": {
      "delete": {
        "description": "Deletes an endpoint owned by the authenticated organisation. Requires `webhooks.manage` and the write ability. The handler returns `{ok: true}`; an endpoint outside that organisation returns 404.",
        "operationId": "v1WebhookEndpointsDelete",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "ok": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Endpoint deleted."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "404": {
            "description": "Endpoint was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Delete a webhook endpoint",
        "tags": [
          "webhooks"
        ]
      },
      "get": {
        "description": "Returns one webhook endpoint belonging to the authenticated organisation, without its HMAC secret. A missing or other-organisation endpoint returns 404.",
        "operationId": "v1WebhookEndpointsShow",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebhookEndpoint"
                }
              }
            },
            "description": "Webhook endpoint metadata."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "An authenticated user with an unverified email address receives 403."
          },
          "404": {
            "description": "Endpoint was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Get a webhook endpoint by ID",
        "tags": [
          "webhooks"
        ]
      },
      "patch": {
        "description": "Updates the URL, subscribed events, or active state of an endpoint owned by the authenticated organisation. Requires `webhooks.manage` and the write ability. Changed URLs pass the outbound URL safety check; validation or an unsafe destination returns 422, and an endpoint outside the organisation returns 404.",
        "operationId": "v1WebhookEndpointsUpdate",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "example": {
                  "is_active": false
                },
                "properties": {
                  "events": {
                    "items": {
                      "maxLength": 64,
                      "type": "string"
                    },
                    "type": "array"
                  },
                  "is_active": {
                    "type": "boolean"
                  },
                  "url": {
                    "format": "uri",
                    "maxLength": 512,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "events": {
                      "items": {
                        "type": "string"
                      },
                      "type": "array"
                    },
                    "id": {
                      "type": "integer"
                    },
                    "is_active": {
                      "type": "boolean"
                    },
                    "url": {
                      "format": "uri",
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "url",
                    "events",
                    "is_active"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Endpoint settings updated."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "404": {
            "description": "Endpoint was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "422": {
            "description": "Validation failed or the destination URL is unsafe.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Update a webhook endpoint",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/endpoints/{id}/rotate": {
      "post": {
        "description": "Replaces the HMAC secret for an endpoint owned by the authenticated organisation. Requires `webhooks.manage` and the write ability. The new secret is returned once; a missing or out-of-organisation endpoint returns 404.",
        "operationId": "v1WebhookEndpointsRotateSecret",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "id": {
                      "type": "integer"
                    },
                    "message": {
                      "type": "string"
                    },
                    "secret": {
                      "type": "string",
                      "writeOnly": true
                    }
                  },
                  "required": [
                    "id",
                    "secret",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "New endpoint secret issued once."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "404": {
            "description": "Endpoint was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Rotate the HMAC secret for an endpoint",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/v1/webhooks/endpoints/{id}/test": {
      "post": {
        "description": "Dispatches a synthetic `webhook.test` event to the configured endpoint. Requires `webhooks.manage` and the write ability. The delivery is visible in the organisation's delivery list; a missing or out-of-organisation endpoint returns 404.",
        "operationId": "v1WebhookEndpointsTest",
        "parameters": [
          {
            "in": "path",
            "name": "id",
            "required": true,
            "schema": {
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "ok": {
                      "const": true,
                      "type": "boolean"
                    }
                  },
                  "required": [
                    "ok",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Test event dispatched."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The authenticated user has not verified their email or accepted the Terms of Service and Privacy Policy, or lacks the required write ability or webhooks.manage permission."
          },
          "404": {
            "description": "Endpoint was not found in this organisation.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "409": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "Fire a synthetic `webhook.test` event at the endpoint",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/api/webhooks/stripe": {
      "post": {
        "description": "Accepts a Stripe event using the raw request body and required `Stripe-Signature` header. The signature is verified before handling; invalid signatures or malformed events return 400, successful and duplicate deliveries are acknowledged with 200, and processing failures return 500 so Stripe can retry. The route is limited to 120 requests per minute.",
        "operationId": "webhooksStripe",
        "parameters": [
          {
            "in": "header",
            "name": "Stripe-Signature",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "description": "Stripe event object; accepted fields depend on the event type and are verified against Stripe-Signature.",
                "type": "object"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Event handled or duplicate event acknowledged."
          },
          "400": {
            "description": "Signature verification or event parsing failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          },
          "429": {
            "description": "Route rate limit exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Event could not be recorded or handled; Stripe may retry.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Stripe webhook event receiver",
        "tags": [
          "webhooks"
        ]
      }
    },
    "/slo": {
      "get": {
        "description": "Returns the cached 30-day availability and latency snapshot. The response is cached for up to 60 seconds; fields without a valid measurement can be null.",
        "operationId": "slo",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SloMetricsResponse"
                }
              }
            },
            "description": "SLO metrics"
          },
          "429": {
            "description": "Error response. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenericError"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "SLO metrics snapshot",
        "tags": [
          "metrics"
        ]
      }
    },
    "/api/gdpr/confirm/{request_id}": {
      "post": {
        "description": "Confirms a data-subject request using the emailed verification token. Provide `email` in the JSON body or query string, and provide `verification_token` in the JSON body or `X-Verification-Token` header. The email and token are required; the token is not read from the query string. The request ID alone does not authorize the action. This route is limited to ten requests per minute.",
        "operationId": "gdprConfirm",
        "parameters": [
          {
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "pattern": "^[a-z0-9-]+$",
              "type": "string"
            }
          },
          {
            "description": "Email address used to look up the data-subject request; may also be supplied in the JSON body.",
            "in": "query",
            "name": "email",
            "required": false,
            "schema": {
              "format": "email",
              "maxLength": 254,
              "type": "string"
            }
          },
          {
            "description": "Use this header or `verification_token` in the JSON body.",
            "in": "header",
            "name": "X-Verification-Token",
            "required": false,
            "schema": {
              "maxLength": 256,
              "minLength": 8,
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "format": "email",
                    "maxLength": 254,
                    "type": "string",
                    "description": "Email address used to look up the data-subject request; may instead be supplied in the query string."
                  },
                  "verification_token": {
                    "maxLength": 256,
                    "minLength": 8,
                    "type": "string"
                  }
                },
                "type": "object"
              }
            }
          },
          "required": false
        },
        "responses": {
          "202": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "properties": {
                    "deadline": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "message": {
                      "type": "string"
                    },
                    "request_id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "request_id",
                    "status",
                    "message"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The request confirmation was accepted; status can describe a pending, scheduled, or processing request."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "detail": {
                      "type": "string"
                    },
                    "error": {
                      "const": "verification_failed",
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "The email and verification token did not confirm the request."
          },
          "409": {
            "description": "The request was verified, but erasure could not be scheduled because other account members remain.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "type": "string",
                      "const": "deletion_not_scheduled"
                    },
                    "detail": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "error",
                    "detail",
                    "message"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "The email or verification token failed validation.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "errors": {
                      "additionalProperties": false,
                      "properties": {
                        "email": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        },
                        "verification_token": {
                          "items": {
                            "type": "string"
                          },
                          "type": "array"
                        }
                      },
                      "required": [],
                      "type": "object"
                    }
                  },
                  "required": [
                    "message",
                    "errors"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "The route rate limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until another request may be made.",
                "schema": {
                  "pattern": "^[1-9][0-9]*$",
                  "type": "string"
                }
              },
              "X-RateLimit-Scope": {
                "description": "The request route and its origin share this limit.",
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          },
          "503": {
            "description": "Confirmation could not be completed because scheduling or dispatch is unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "error": {
                          "type": "string",
                          "const": "deletion_not_scheduled"
                        },
                        "detail": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "error",
                        "detail",
                        "message"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "error": {
                          "type": "string",
                          "const": "dispatch_unavailable"
                        },
                        "request_id": {
                          "type": "string"
                        },
                        "status": {
                          "type": "string",
                          "const": "pending"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "error",
                        "request_id",
                        "status",
                        "message"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Confirm a data-subject request",
        "tags": [
          "compliance"
        ]
      }
    },
    "/api/transparency/seeds/recent": {
      "get": {
        "description": "Returns the most recent public transparency seed, or an empty-chain response when no public seeds exist. The response includes the seed index, timestamp, root, and signature when a seed exists. Limited to 120 requests per minute.",
        "operationId": "getPublicTransparencySeedRecent",
        "parameters": [],
        "responses": {
          "200": {
            "description": "The latest signed seed, or the empty-chain response when there are no public seeds.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "additionalProperties": false,
                      "properties": {
                        "seed_index": {
                          "type": "integer",
                          "minimum": 0
                        },
                        "seed_at": {
                          "format": "date-time",
                          "type": "string"
                        },
                        "merkle_root": {
                          "type": "string",
                          "minLength": 1
                        },
                        "leaf_count": {
                          "type": "integer",
                          "minimum": 1
                        },
                        "previous_seed_index": {
                          "type": [
                            "integer",
                            "null"
                          ],
                          "minimum": 0
                        },
                        "signature": {
                          "type": "string",
                          "minLength": 1
                        },
                        "alg": {
                          "type": "string",
                          "const": "ES256"
                        },
                        "kid": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "seed_index",
                        "seed_at",
                        "merkle_root",
                        "leaf_count",
                        "previous_seed_index",
                        "signature",
                        "alg",
                        "kid"
                      ],
                      "type": "object"
                    },
                    {
                      "additionalProperties": false,
                      "properties": {
                        "seed_index": {
                          "type": "null"
                        },
                        "seed_at": {
                          "type": "null"
                        },
                        "merkle_root": {
                          "type": "null"
                        },
                        "leaf_count": {
                          "type": "integer",
                          "const": 0
                        },
                        "previous_seed_index": {
                          "type": "null"
                        },
                        "note": {
                          "type": "string",
                          "const": "transparency seed chain is empty"
                        }
                      },
                      "required": [
                        "seed_index",
                        "seed_at",
                        "merkle_root",
                        "leaf_count",
                        "previous_seed_index",
                        "note"
                      ],
                      "type": "object"
                    }
                  ]
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "description": "The signed response may be cached for 30 seconds and must be revalidated.",
                "schema": {
                  "type": "string",
                  "const": "public, max-age=30, must-revalidate"
                }
              },
              "X-CloakAPI-Transparency-Kid": {
                "description": "Identifier of the key used to sign this response.",
                "schema": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "X-Content-Type-Options": {
                "description": "Prevents browsers from interpreting the response as another media type.",
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              }
            }
          },
          "429": {
            "description": "The route rate limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until another request may be made.",
                "schema": {
                  "pattern": "^[1-9][0-9]*$",
                  "type": "string"
                }
              },
              "X-RateLimit-Scope": {
                "description": "The request route and its origin share this limit.",
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Get the latest public transparency seed",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/transparency/seeds/{index}": {
      "get": {
        "description": "Returns a public transparency seed by its numeric index. Limited to 120 requests per minute.",
        "operationId": "getPublicTransparencySeed",
        "parameters": [
          {
            "in": "path",
            "name": "index",
            "required": true,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The signed seed at this index.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "seed_index": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "seed_at": {
                      "format": "date-time",
                      "type": "string"
                    },
                    "merkle_root": {
                      "type": "string",
                      "minLength": 1
                    },
                    "leaf_count": {
                      "type": "integer",
                      "minimum": 1
                    },
                    "previous_seed_index": {
                      "type": [
                        "integer",
                        "null"
                      ],
                      "minimum": 0
                    },
                    "signature": {
                      "type": "string",
                      "minLength": 1
                    },
                    "alg": {
                      "type": "string",
                      "const": "ES256"
                    },
                    "kid": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "seed_index",
                    "seed_at",
                    "merkle_root",
                    "leaf_count",
                    "previous_seed_index",
                    "signature",
                    "alg",
                    "kid"
                  ],
                  "type": "object"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "description": "The signed response may be cached for 30 seconds and must be revalidated.",
                "schema": {
                  "type": "string",
                  "const": "public, max-age=30, must-revalidate"
                }
              },
              "X-CloakAPI-Transparency-Kid": {
                "description": "Identifier of the key used to sign this response.",
                "schema": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "X-Content-Type-Options": {
                "description": "Prevents browsers from interpreting the response as another media type.",
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              }
            }
          },
          "404": {
            "description": "No public seed exists at this index.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "not_found"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "The route rate limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until another request may be made.",
                "schema": {
                  "pattern": "^[1-9][0-9]*$",
                  "type": "string"
                }
              },
              "X-RateLimit-Scope": {
                "description": "The request route and its origin share this limit.",
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Get a public transparency seed by index",
        "tags": [
          "transparency"
        ]
      }
    },
    "/api/transparency/seeds/{index}/proof": {
      "get": {
        "description": "Returns the hash-chain inclusion path for a leaf hash at the selected seed index. `leaf` must be a SHA-256 hexadecimal digest. Limited to 120 requests per minute.",
        "operationId": "getPublicTransparencySeedProof",
        "parameters": [
          {
            "in": "path",
            "name": "index",
            "required": true,
            "schema": {
              "minimum": 0,
              "type": "integer"
            }
          },
          {
            "in": "query",
            "name": "leaf",
            "required": true,
            "schema": {
              "pattern": "^[a-fA-F0-9]{64}$",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The signed hash-chain inclusion path and whether the leaf is included.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "seed_index": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "merkle_root": {
                      "type": "string",
                      "minLength": 1
                    },
                    "leaf": {
                      "pattern": "^[a-fA-F0-9]{64}$",
                      "type": "string"
                    },
                    "included": {
                      "type": "boolean"
                    },
                    "algorithm": {
                      "type": "string",
                      "const": "sha256-chain-v1"
                    },
                    "path": {
                      "items": {
                        "additionalProperties": false,
                        "properties": {
                          "seed_hash": {
                            "pattern": "^[a-fA-F0-9]{64}$",
                            "type": "string"
                          },
                          "parent_hash": {
                            "type": [
                              "string",
                              "null"
                            ]
                          }
                        },
                        "required": [
                          "seed_hash",
                          "parent_hash"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "seed_index",
                    "merkle_root",
                    "leaf",
                    "included",
                    "algorithm",
                    "path"
                  ],
                  "type": "object"
                }
              }
            },
            "headers": {
              "Cache-Control": {
                "description": "The signed response may be cached for 30 seconds and must be revalidated.",
                "schema": {
                  "type": "string",
                  "const": "public, max-age=30, must-revalidate"
                }
              },
              "X-CloakAPI-Transparency-Kid": {
                "description": "Identifier of the key used to sign this response.",
                "schema": {
                  "type": "string",
                  "minLength": 1
                }
              },
              "X-Content-Type-Options": {
                "description": "Prevents browsers from interpreting the response as another media type.",
                "schema": {
                  "type": "string",
                  "const": "nosniff"
                }
              }
            }
          },
          "404": {
            "description": "No public seed exists at this index.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "not_found"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "422": {
            "description": "The leaf value is missing or is not a SHA-256 hexadecimal digest.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "invalid_leaf"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "code",
                        "message"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "description": "The route rate limit was exceeded. An edge rate limit may return an HTML error page.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "error": {
                      "additionalProperties": false,
                      "properties": {
                        "code": {
                          "type": "string",
                          "const": "too_many_attempts"
                        },
                        "scope": {
                          "type": "string",
                          "const": "route"
                        },
                        "message": {
                          "type": "string"
                        },
                        "retry_after_s": {
                          "type": "integer",
                          "minimum": 1
                        }
                      },
                      "required": [
                        "code",
                        "scope",
                        "message",
                        "retry_after_s"
                      ],
                      "type": "object"
                    }
                  },
                  "required": [
                    "error"
                  ],
                  "type": "object"
                }
              },
              "text/html": {
                "schema": {
                  "type": "string"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Seconds until another request may be made.",
                "schema": {
                  "pattern": "^[1-9][0-9]*$",
                  "type": "string"
                }
              },
              "X-RateLimit-Scope": {
                "description": "The request route and its origin share this limit.",
                "schema": {
                  "type": "string",
                  "const": "route"
                }
              }
            }
          }
        },
        "security": [],
        "summary": "Get a public transparency seed proof",
        "tags": [
          "transparency"
        ]
      }
    },
    "/keys/portal/{kid}": {
      "get": {
        "operationId": "getPortalAttesterKey",
        "summary": "Get self-attested portal key status",
        "description": "Returns a self-attested status for any well-formed portal kid. The response does not register or publish a browser-instance key. A matching embedded key and fingerprint show that the same key signed the envelope; gateway authenticity comes only from a valid gateway countersignature bound to the receipt hash.",
        "tags": [
          "Receipt verification"
        ],
        "security": [],
        "parameters": [
          {
            "name": "kid",
            "in": "path",
            "required": true,
            "description": "Portal key id: `portal-` followed by 16 lowercase hexadecimal characters.",
            "schema": {
              "type": "string",
              "pattern": "^portal-[0-9a-f]{16}$"
            },
            "example": "portal-0123456789abcdef"
          }
        ],
        "responses": {
          "200": {
            "description": "Self-attested browser-instance status. No key is registered or published.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "status",
                    "keys",
                    "docs",
                    "message"
                  ],
                  "properties": {
                    "status": {
                      "type": "string",
                      "const": "self-attested"
                    },
                    "keys": {
                      "type": "array",
                      "maxItems": 0,
                      "items": {}
                    },
                    "docs": {
                      "type": "string",
                      "format": "uri"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Malformed portal key id.",
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": false,
                  "properties": {
                    "keys": {
                      "items": {},
                      "maxItems": 0,
                      "type": "array"
                    }
                  },
                  "required": [
                    "keys"
                  ],
                  "type": "object"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        }
      }
    },
    "/api/providers/byok": {
      "get": {
        "description": "Returns active BYOK providers for the authenticated user. Inactive providers are omitted; Perplexity is currently inactive in the gateway catalogue. Provider-key secrets are not part of this response.",
        "operationId": "providersByok",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "properties": {
                    "markup_pct": {
                      "type": "number"
                    },
                    "mode": {
                      "const": "cloakapi_keys",
                      "type": "string"
                    },
                    "providers": {
                      "items": {
                        "properties": {
                          "connected": {
                            "type": "boolean",
                            "description": "True only when the saved user key has a successful provider verification."
                          },
                          "last_verified_at": {
                            "format": "date-time",
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "markup_pct": {
                            "type": "number"
                          },
                          "masked_key": {
                            "type": [
                              "string",
                              "null"
                            ]
                          },
                          "models": {
                            "items": {
                              "type": "string"
                            },
                            "type": "array"
                          },
                          "name": {
                            "type": "string"
                          },
                          "pricing": {
                            "additionalProperties": {
                              "properties": {
                                "input": {
                                  "type": "number"
                                },
                                "output": {
                                  "type": "number"
                                }
                              },
                              "type": "object"
                            },
                            "type": "object"
                          },
                          "slug": {
                            "type": "string"
                          },
                          "saved": {
                            "type": "boolean",
                            "description": "Whether a key row is saved, including a rejected key."
                          },
                          "byok_active": {
                            "type": "boolean",
                            "description": "Whether a saved user key is currently selected for routing."
                          },
                          "verification_status": {
                            "enum": [
                              "not_connected",
                              "verified",
                              "not_verified",
                              "rejected"
                            ],
                            "type": "string"
                          },
                          "offered": {
                            "type": "boolean"
                          },
                          "requires_own_key": {
                            "type": "boolean"
                          }
                        },
                        "required": [
                          "slug",
                          "name",
                          "models",
                          "connected",
                          "masked_key",
                          "last_verified_at",
                          "markup_pct",
                          "pricing",
                          "saved",
                          "byok_active",
                          "verification_status",
                          "offered"
                        ],
                        "type": "object"
                      },
                      "type": "array"
                    }
                  },
                  "required": [
                    "providers",
                    "mode",
                    "markup_pct"
                  ],
                  "type": "object"
                }
              }
            },
            "description": "Offered provider catalogue, connected-key metadata, model pricing, mode, and configured markup field."
          },
          "401": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "Missing or invalid bearer token."
          },
          "403": {
            "content": {
              "application/json": {
                "schema": {
                  "additionalProperties": true,
                  "type": "object"
                }
              }
            },
            "description": "The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy."
          },
          "503": {
            "description": "Provider availability could not be loaded.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true,
                  "properties": {
                    "error": {
                      "type": "object",
                      "additionalProperties": true,
                      "properties": {
                        "type": {
                          "const": "server_error",
                          "type": "string"
                        },
                        "code": {
                          "const": "provider_lookup_unavailable",
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "code",
                        "message"
                      ]
                    }
                  },
                  "required": [
                    "error"
                  ]
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimited"
          }
        },
        "security": [
          {
            "BearerToken": []
          }
        ],
        "summary": "List active providers available for BYOK",
        "tags": [
          "providers"
        ]
      }
    }
  },
  "servers": [
    {
      "description": "Production",
      "url": "https://api.cloakapi.io"
    }
  ],
  "tags": [
    {
      "description": "Service health and readiness probes",
      "name": "health"
    },
    {
      "description": "SLO and Prometheus metrics",
      "name": "metrics"
    },
    {
      "description": "OIDC/OAuth discovery and public-key endpoints",
      "name": "well-known"
    },
    {
      "description": "Register, login, logout, current-user",
      "name": "authentication"
    },
    {
      "description": "Anthropic-compatible messages endpoint (v1)",
      "name": "messages"
    },
    {
      "description": "OpenAI-compatible chat completions endpoint (v1)",
      "name": "chat"
    },
    {
      "description": "Embedding endpoint (relayed to the upstream provider)",
      "name": "embeddings"
    },
    {
      "description": "Image generation endpoint",
      "name": "images"
    },
    {
      "description": "Audio transcription and speech (local-alternative)",
      "name": "audio"
    },
    {
      "description": "File modality pipeline (process)",
      "name": "files"
    },
    {
      "description": "Token counting without upstream forwarding",
      "name": "tokens"
    },
    {
      "description": "OpenReceipt verification and chain management",
      "name": "receipts"
    },
    {
      "description": "Tenant-scoped audit log",
      "name": "audit"
    },
    {
      "description": "Balance, usage, invoices, checkout, and subscriptions",
      "name": "billing"
    },
    {
      "description": "Compliance pack management (HIPAA, FINRA, PCI-DSS, GDPR, etc.)",
      "name": "compliance"
    },
    {
      "description": "SCIM v2 user and group provisioning",
      "name": "scim"
    },
    {
      "description": "Complete-local-mode – gateway-lite receipt recording, heartbeat, entitlements",
      "name": "local-mode"
    },
    {
      "description": "Stripe webhook ingestion",
      "name": "webhooks"
    },
    {
      "description": "API key management (dashboard and v1)",
      "name": "api-keys"
    },
    {
      "description": "Provider routing and key management",
      "name": "providers"
    },
    {
      "description": "Backup device pairing and management",
      "name": "devices"
    },
    {
      "description": "Guided onboarding wizard",
      "name": "onboarding"
    },
    {
      "description": "SAML 2.0 and OIDC single-sign-on",
      "name": "sso"
    }
  ]
}
