# Quotas API

## List financial organizations and projects

`GET /api/v1/admin/quota-accounts` · operation `quotaAccounts`

Global admin/viewer/operator read; scoped roles denied. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: object |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of [QuotaAccount](/docs/api/schemas/q/#quotaaccount), required, max items 500)
  - `limit` (integer (int64), required, min 0)


## Create financial account with database ID

`POST /api/v1/admin/quota-accounts` · operation `quotaAccountCreate`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaAccountWrite](/docs/api/schemas/q/#quotaaccountwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaAccount](/docs/api/schemas/q/#quotaaccount) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Rename or disable financial account

`PUT /api/v1/admin/quota-accounts/{id}` · operation `quotaAccountUpdate`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `id` | path | string, required |  |

**Request body** (required)

- `application/json`: [QuotaAccountWrite](/docs/api/schemas/q/#quotaaccountwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaAccount](/docs/api/schemas/q/#quotaaccount) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Read explicit managed-key financial bindings

`GET /api/v1/admin/quota-attributions` · operation `quotaAttributions`

Global admin/viewer/operator read; scoped roles denied. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: object |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of [QuotaAttribution](/docs/api/schemas/q/#quotaattribution), required, max items 500)
  - `limit` (integer (int64), required, min 0)


## Bind key to active user and financial accounts

`PUT /api/v1/admin/quota-attributions/{key_id}` · operation `quotaAttributionWrite`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `key_id` | path | string, required |  |

**Request body** (required)

- `application/json`: [QuotaAttributionWrite](/docs/api/schemas/q/#quotaattributionwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaAttribution](/docs/api/schemas/q/#quotaattribution) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Read durable budget threshold alerts

`GET /api/v1/admin/quota-alerts` · operation `quotaAlerts`

Global admin/viewer/operator read; scoped roles denied. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `limit` | query | integer, min 1, max 100 | Most alerts on this page, 1-100. |
| `offset` | query | integer, min 0, max 10000 | Alerts to skip before this page. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: object |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of [QuotaAlert](/docs/api/schemas/q/#quotaalert), required, max items 100)
  - `limit` (integer (int64), min 0)
  - `offset` (integer (int64), min 0)


## Acknowledge a budget alert

`POST /api/v1/admin/quota-alerts/{id}/ack` · operation `quotaAlertAck`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires a quota flag for reads and quota_management for mutations. Financial attribution grants no access or tenancy.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |
| `id` | path | string, required |  |

**Request body** (required)

- `application/json`: [QuotaEmpty](/docs/api/schemas/q/#quotaempty)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Acknowledged idempotently | — |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Report all imported costs with coverage and unmatched totals

`GET /api/v1/admin/quota-finance/report` · operation `quotaFinanceReport`

Global admin/viewer/operator read; scoped roles denied. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `limit` | query | integer, min 1, max 100 | Most report lines on this page. |
| `offset` | query | integer, min 0, max 1000000 | Report lines to skip before this page. |
| `import_id` | query | string |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaFinanceReport](/docs/api/schemas/q/#quotafinancereport) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Import normalized provider cost statement

`POST /api/v1/admin/quota-finance/imports` · operation `quotaFinanceImport`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaBillingWrite](/docs/api/schemas/q/#quotabillingwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaBillingResult](/docs/api/schemas/q/#quotabillingresult) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Import original provider costs

`POST /api/v1/admin/quota-finance/import-native` · operation `quotaFinanceImportNative`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaNativeBillingWrite](/docs/api/schemas/q/#quotanativebillingwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaBillingResult](/docs/api/schemas/q/#quotabillingresult) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Settle unknown reservation using validated immutable protocol measurement

`POST /api/v1/admin/quota-finance/reconcile` · operation `quotaFinanceReconcile`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaReconcileInput](/docs/api/schemas/q/#quotareconcileinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaReconcileResult](/docs/api/schemas/q/#quotareconcileresult) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Attest matched positive provider charge; preserve unproven TPM

`POST /api/v1/admin/quota-finance/reconcile-charge` · operation `quotaFinanceReconcileCharge`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness. When the matched reservation had been released by hand (T220), the charge goes back into the budget instead: state released_charge_reapplied, budget_basis manual_release_charge_attested, and released_charge lists each money window the release gave back with what was added (the charged amount where the window is still the current one; skipped window_rolled_over otherwise). A zero charge is accepted for such a reservation, re-applies nothing and is recorded (skipped zero_charge). Token windows are never re-held. Applied once per reservation and per charge line; a repeat of the same operation is idempotent, another operation on the same line or reservation is a conflict. It writes one trail row (shown as charge on the manual release) and one audit row (quota.reservation.release_charge_reapplied, with the organization).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaChargeReconcileInput](/docs/api/schemas/q/#quotachargereconcileinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaChargeReconcileResult](/docs/api/schemas/q/#quotachargereconcileresult) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Read server measurement and provider receipt proof metadata

`GET /api/v1/admin/quota-finance/evidence` · operation `quotaFinanceEvidence`

Global admin/viewer/operator read; scoped roles denied. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `reservation_id` | query | string, required, pattern `^[a-f0-9]{32}$` | The quota reservation whose settlement evidence to show. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaFinanceEvidence](/docs/api/schemas/q/#quotafinanceevidence) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## List the held unknown reservations a manual release may take

`GET /api/v1/admin/quota-finance/unknown-reservations` · operation `quotaUnknownReservations`

Manual release of an unknown reservation (T220, features.quota_manual_release, which requires quota_finance). Permission quota_reservations:release, held by the global administrator for every organization and by an organization admin for its own. Lists reservations in state unknown, oldest first, with what each one holds (every counter and window) and whether it is releasable: blocked is measurement_available (settle it with POST /quota-finance/reconcile), charge_reconciled (an attested provider charge is its budget) or, for an organization admin, outside_organization (the reservation also holds a tenant ceiling, a global or provider budget in force, a group, a subject list or an account). An organization admin reads only reservations of its organization's teams. Metadata only; private, no-store.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `organization_id` | query | string, max length 256 | Reservations of this organization's teams. An organization admin may name only its own (403 otherwise). |
| `team_id` | query | string, max length 256 |  |
| `key_id` | query | string, max length 256 |  |
| `provider_id` | query | string, max length 256 |  |
| `model` | query | string, max length 256 | The public model alias of the request. |
| `created_after` | query | string (date-time) | Admitted at or after this RFC 3339 instant. |
| `created_before` | query | string (date-time) | Admitted before this RFC 3339 instant. |
| `limit` | query | integer, default `50`, min 1, max 100 |  |
| `offset` | query | integer, default `0`, min 0, max 1000000 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | One page of held unknown reservations | `application/json`: [QuotaUnknownReservationPage](/docs/api/schemas/q/#quotaunknownreservationpage) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | role_forbidden: the session lacks quota_reservations:release. organization_forbidden: an organization admin named another organization, or a reservation that also holds a ceiling set above its organization | — |
| `404` | Feature disabled (quota_finance or quota_manual_release) | — |
| `503` | Required storage unavailable | — |


## Read the finance trail of manual releases

`GET /api/v1/admin/quota-finance/manual-releases` · operation `quotaManualReleases`

The finance trail of manual releases (T220, features.quota_manual_release), newest first: who released which reservation, when, the written reason, the amount and every window given back. Rows are written once and never changed. Permission quota_reservations:release; an organization admin reads only its organization's rows. Private, no-store.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `organization_id` | query | string, max length 256 | Rows of this organization. An organization admin may name only its own (403 otherwise). |
| `limit` | query | integer, default `50`, min 1, max 100 |  |
| `offset` | query | integer, default `0`, min 0, max 1000000 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | One page of the trail | `application/json`: object |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | role_forbidden: the session lacks quota_reservations:release. organization_forbidden: an organization admin named another organization, or a reservation that also holds a ceiling set above its organization | — |
| `404` | Feature disabled (quota_finance or quota_manual_release) | — |
| `503` | Required storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of [QuotaManualRelease](/docs/api/schemas/q/#quotamanualrelease), required)
  - `limit` (integer, required)
  - `offset` (integer, required)
  - `notice` (string, required) — What a manual release does not prove.


## Release unknown reservations by hand, with a written reason

`POST /api/v1/admin/quota-finance/release-unknown` · operation `quotaReleaseUnknown`

Gives back the holds of one unknown reservation or of a reviewed set (T220, features.quota_manual_release, permission quota_reservations:release). Nothing in the gateway calls this by itself: no timer, window end or import releases an unknown reservation. The release proves nothing about the provider, which may still have charged; the answer and every trail row say so. All named reservations are released in one transaction or none is. Each release moves the reservation to released, subtracts its reserved amounts from the counters of its original windows, writes one finance-trail row (actor, time, reason, amount, windows) and one audit row (action quota.reservation.release_unknown, with the organization). Repeating the same id with the same content is idempotent; the same id with other content is a conflict. Refused, with nothing released: a reservation that is not unknown, one with a validated measurement, one with an attested provider charge, and, for an organization admin, one outside its organization or holding a ceiling set above it.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaManualReleaseInput](/docs/api/schemas/q/#quotamanualreleaseinput)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The releases made, or the ones this operation made before | `application/json`: [QuotaManualReleaseResult](/docs/api/schemas/q/#quotamanualreleaseresult) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | role_forbidden: the session lacks quota_reservations:release. organization_forbidden: an organization admin named another organization, or a reservation that also holds a ceiling set above its organization | — |
| `404` | Feature disabled (quota_finance or quota_manual_release) | — |
| `409` | version_conflict (stale finance version, or the id was used with other content), reservation_not_unknown, measurement_available, charge_reconciled or release_count_mismatch; nothing was released | — |
| `422` | invalid_quota_finance (reason outside 10 to 500 characters, both or neither of reservation_ids and filter, an empty filter, more than 100 reservations) or confirmation_required | — |
| `503` | Required storage unavailable | — |


## Preview bounded terminal ledger archival

`GET /api/v1/admin/quota-finance/retention` · operation `quotaFinanceRetentionPreview`

Global admin/viewer/operator read; scoped roles denied. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `retain_days` | query | integer, min 32, max 3650 | Ledger entries newer than this many days stay; older terminal entries are previewed for archiving (32-3650). |
| `limit` | query | integer, min 1, max 1000 | Most entries the preview lists, 1-1000. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaLedgerRetention](/docs/api/schemas/q/#quotaledgerretention) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Archive terminal ledger atomically while preserving proof and unknowns

`POST /api/v1/admin/quota-finance/retention` · operation `quotaFinanceRetentionApply`

Global admin mutation; requires same-origin session, CSRF and version where declared. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaLedgerRetentionWrite](/docs/api/schemas/q/#quotaledgerretentionwrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: [QuotaLedgerRetention](/docs/api/schemas/q/#quotaledgerretention) |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |


## Read preserved terminal ledger archive

`GET /api/v1/admin/quota-finance/archive` · operation `quotaFinanceArchive`

Global admin/viewer/operator read; scoped roles denied. Requires quota_finance and quota management; metadata only. Imported exports are operator attested, never authenticated invoice completeness.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `limit` | query | integer, min 1, max 100 | Most archived imports on this page. |
| `offset` | query | integer, min 0, max 1000000 | Archived imports to skip before this page. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current data or confirmed result | `application/json`: object |
| `400` | Invalid bounded JSON, filter or explicit version | — |
| `401` | Authentication required | — |
| `403` | Role, scope or CSRF denied | — |
| `404` | Feature disabled or resource absent | — |
| `409` | Version, snapshot or identity conflict | — |
| `422` | Invalid profile, attribution or unproven measurement | — |
| `503` | Required storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `items` (array of object, max items 100)
    - `id` (string)
    - `fingerprint` (string)
    - `archived_at` (string (date-time))
    - `ledger` (object)
  - `limit` (integer (int64), min 0)
  - `offset` (integer (int64), min 0)


## GET /api/v1/admin/quota-finance/connectors

`GET /api/v1/admin/quota-finance/connectors` · operation `listBillingConnectors`

Global quotas:read. Lists the YAML provider cost connectors (source, provider, account, credential_configured, finalization_hours, max_days) with their last five runs. Never returns the credential. Requires quota_finance and billing_connectors; no-store.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | billing_connectors: the YAML connectors with their last runs | `application/json`: object |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |

Response `200` fields:

- `application/json`: object
  - `billing_connectors` (array of [BillingConnector](/docs/api/schemas/b/#billingconnector), required)


## POST /api/v1/admin/quota-finance/connectors/{id}/sync

`POST /api/v1/admin/quota-finance/connectors/{id}/sync` · operation `syncBillingConnector`

Global administrator, quotas:manage, quota_management, same origin and CSRF. Reads the provider's organization cost report for [from, to) (UTC dates, at most max_days, ending no later than tomorrow) at the fixed official origin with the connector's administrative key, pages through it completely and imports only what changed since the last read (new rows as charges, revisions as adjustments, withdrawn rows back to zero), in one transaction with the connector line ledger. An unchanged report records a no_change run. The provider's body is never echoed.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,31}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: object
  - `version` (integer (int64), required, min 0)
  - `from` (string (date), required)
  - `to` (string (date), required)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | The run: id, state (imported or no_change), import_id, pages, rows, new_lines, corrected_lines, withdrawn_lines, final_through, source_sha256 | — |
| `400` | invalid_period | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled or connector_not_found | — |
| `409` | Finance version conflict or overlap with a manual import of the same report | — |
| `422` | connector_report_too_large, connector_provider_missing or invalid finance input | — |
| `502` | connector_credential_rejected, connector_unavailable or connector_invalid_report | — |
| `503` | connector_credential_missing, connector_rate_limited (with Retry-After) or storage unavailable | — |


## GET /api/v1/admin/quota-finance/reconciliation

`GET /api/v1/admin/quota-finance/reconciliation` · operation `getFinanceReconciliation`

Global quotas:read. Per UTC day of [from, to) (at most 92 days) for one provider, the provider charge from connector imports beside the gateway's own record (usage events and their known valuations, which are estimates, and budget reservations), with a state per day (not_imported, provisional, incomplete, provider_only, gateway_only, no_activity, comparable) and difference_usd only on comparable days. Requires quota_finance and billing_connectors; no-store.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `provider_id` | query | string, required |  |
| `from` | query | string (date), required |  |
| `to` | query | string (date), required |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | provider_id, from, to, days, coverage (days per state), estimate_basis, provider_basis, currency, time_basis | — |
| `400` | invalid_period | — |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Local concurrency limit reached | `application/json`: [Error](/docs/api/schemas/e/#error) |


## GET /api/v1/admin/quota-policies

`GET /api/v1/admin/quota-policies` · operation `quotaCatalog`

Read the effective quota catalog and connection fingerprints. Global admin/viewer/operator; any quota flag enables reading. T168 (organization_admins): an organization admin reads only the policies whose subject is a team, managed key or team-scoped user of its organization now, with organization_id and empty rates and connections.

**Authentication:** `adminSession`

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaCatalog](/docs/api/schemas/q/#quotacatalog) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## GET /api/v1/admin/quota-policies/status

`GET /api/v1/admin/quota-policies/status` · operation `quotaStatus`

Shared PostgreSQL-clock counters include settled use and outstanding reservations. Not an invoice or a tokenizer guarantee.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `status_version` | query | integer, one of `1`, `2`, `3`, `4`, `5`, default `1` | Omitted or1 preserves legacy response;2 includes calendar snapshots;3 adds nonresetting lifetime with explicit null dates;4 adds DB-observed temporary allowance state and effective ceilings. V1–3 omit USD for policies with configured temporary profiles, retaining applicable token counters. V5 adds global and selected-provider monetary scopes and flags; V1–4 omit their unfamiliar rows. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaStatus](/docs/api/schemas/q/#quotastatus) and any or [QuotaStatusV2](/docs/api/schemas/q/#quotastatusv2) or [QuotaStatusV3](/docs/api/schemas/q/#quotastatusv3) or [QuotaStatusV4](/docs/api/schemas/q/#quotastatusv4) or [QuotaStatusV5](/docs/api/schemas/q/#quotastatusv5) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable or committed YAML base mismatch | — |

Response `200` fields:

- `application/json`: [QuotaStatus](/docs/api/schemas/q/#quotastatus) and any or [QuotaStatusV2](/docs/api/schemas/q/#quotastatusv2) or [QuotaStatusV3](/docs/api/schemas/q/#quotastatusv3) or [QuotaStatusV4](/docs/api/schemas/q/#quotastatusv4) or [QuotaStatusV5](/docs/api/schemas/q/#quotastatusv5)
  - One of (1): [QuotaStatus](/docs/api/schemas/q/#quotastatus) and any
    - All of (1): [QuotaStatus](/docs/api/schemas/q/#quotastatus)
    - All of (2): any
  - One of (2): [QuotaStatusV2](/docs/api/schemas/q/#quotastatusv2)
  - One of (3): [QuotaStatusV3](/docs/api/schemas/q/#quotastatusv3)
  - One of (4): [QuotaStatusV4](/docs/api/schemas/q/#quotastatusv4)
  - One of (5): [QuotaStatusV5](/docs/api/schemas/q/#quotastatusv5)


## GET /api/v1/admin/quota-policies/temporary-increases/history

`GET /api/v1/admin/quota-policies/temporary-increases/history` · operation `quotaTemporaryHistory`

Global quota readers only, authorized before count and filtering. Bounded repeatable-read history, newest identity first. Available for recovery when the temporary allowance flag is off. No prefeature history is invented.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `policy_id` | query | string, pattern `^[a-z][a-z0-9_-]{1,63}$` | Optional exact policy ID. |
| `limit` | query | integer, default `25`, min 1, max 100 |  |
| `offset` | query | integer, default `0`, min 0, max 10000 | History rows to skip before this page (0-10000). |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | One coherent count/page snapshot | `application/json`: [QuotaTemporaryHistory](/docs/api/schemas/q/#quotatemporaryhistory) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable or adopted YAML base mismatch | — |


## GET /api/v1/admin/quota-policies/ledger

`GET /api/v1/admin/quota-policies/ledger` · operation `quotaLedger`

Bounded metadata ledger. Global readers only; no payloads or credentials. Reservations are independent of analytics retention.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `limit` | query | integer, default `50`, min 1, max 100 |  |
| `offset` | query | integer, default `0`, min 0, max 10000 | Rows to skip before this page, for pagination (0-10000). |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaLedger](/docs/api/schemas/q/#quotaledger) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## GET /api/v1/admin/quota-policies/{id}/children

`GET /api/v1/admin/quota-policies/{id}/children` · operation `quotaPolicyChildren`

Current-window use of every child of one per-child template (hierarchical_quotas), highest share of its ceiling first. Children with no use in the current windows are omitted. Global readers only.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,63}$` |  |
| `limit` | query | integer, default `100`, min 1, max 1000 |  |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Child counters of the template | `application/json`: [QuotaChildStatus](/docs/api/schemas/q/#quotachildstatus) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled, or no template policy with this ID | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## PUT /api/v1/admin/quota-policies/{id}

`PUT /api/v1/admin/quota-policies/{id}` · operation `quotaPolicyUpsert`

Create or override a quota policy with quota_management and global admin. Consumed balance is not reset. T168 (organization_admins): an organization admin may also write (and DELETE) a policy whose subject (team, key, user, membership, or every listed subject of a subjects list) belongs to its organization before and after the write, never a tenant ceiling, a gateway-wide, model, provider or YAML policy, nor a per-child template (403 organization_forbidden), and within its tenant ceilings: TPM, TPD, and a budget (with its temporary increase) of the same or a shorter period than a tenant budget (422 exceeds_tenant_ceiling).

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaPolicyWrite](/docs/api/schemas/q/#quotapolicywrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaPolicyResult](/docs/api/schemas/q/#quotapolicyresult) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | Invalid policy, inactive subject or unapproved exact connection | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## DELETE /api/v1/admin/quota-policies/{id}

`DELETE /api/v1/admin/quota-policies/{id}` · operation `quotaPolicyRevert`

Remove a console policy or restore its YAML base. Does not erase counters. Requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `id` | path | string, required, pattern `^[a-z][a-z0-9_-]{1,63}$` |  |
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaVersion](/docs/api/schemas/q/#quotaversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `204` | Override removed and YAML restored if present | — |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | Invalid policy, inactive subject or unapproved exact connection | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## PUT /api/v1/admin/quota-rates

`PUT /api/v1/admin/quota-rates` · operation `quotaRatesReplace`

Replace the reviewed exact connection/model rate catalog, separate from advisory prices. Requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaRatesWrite](/docs/api/schemas/q/#quotarateswrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaRateResult](/docs/api/schemas/q/#quotarateresult) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | Invalid policy, inactive subject or unapproved exact connection | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## DELETE /api/v1/admin/quota-rates

`DELETE /api/v1/admin/quota-rates` · operation `quotaRatesRevert`

Restore YAML quota rates without rewriting captured reservations. Requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaVersion](/docs/api/schemas/q/#quotaversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Approved rate override removed and YAML restored | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | Invalid policy, inactive subject or unapproved exact connection | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |

Response `200` fields:

- `application/json`: object
  - `version` (integer (int64), required, min 0)


## PUT /api/v1/admin/quota-settings

`PUT /api/v1/admin/quota-settings` · operation `quotaSettingsReplace`

Replace the YAML quota settings (limits on protected requests, overrun alert tolerance and dedupe) until reverted. A zero or omitted request-bound field takes its default; both alert controls preserve real zero. Requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaSettingsWrite](/docs/api/schemas/q/#quotasettingswrite)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Settings stored; the effective values with defaults filled in | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | A setting outside its bounds | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |

Response `200` fields:

- `application/json`: object
  - `version` (integer (int64), required, min 0)
  - `settings` ([EffectiveQuotaSettings](/docs/api/schemas/e/#effectivequotasettings), required)


## DELETE /api/v1/admin/quota-settings

`DELETE /api/v1/admin/quota-settings` · operation `quotaSettingsRevert`

Restore the YAML quota settings. Reservations keep the overrun alert settings they were taken under. Requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaVersion](/docs/api/schemas/q/#quotaversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Settings override removed and YAML restored | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |

Response `200` fields:

- `application/json`: object
  - `version` (integer (int64), required, min 0)


## POST /api/v1/admin/quota-policies/adopt-base

`POST /api/v1/admin/quota-policies/adopt-base` · operation `quotaBaseAdopt`

Explicitly adopt the current YAML fingerprint without resetting counters. Drain old replicas; requires quota_management and global admin.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `X-CSRF-Token` | header | string, required | Token returned by admin login/session; required with the same-origin session cookie for writes. |

**Request body** (required)

- `application/json`: [QuotaVersion](/docs/api/schemas/q/#quotaversion)

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Current quota data or committed mutation result | `application/json`: [QuotaVersion](/docs/api/schemas/q/#quotaversion) |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `409` | Version or reviewed base fingerprint changed | — |
| `422` | Invalid policy, inactive subject or unapproved exact connection | — |
| `503` | Storage unavailable or committed YAML base mismatch | — |


## GET /api/v1/admin/fx/budget-conversions

`GET /api/v1/admin/fx/budget-conversions` · operation `listBudgetConversions`

Requires fx_display and quotas:manage. The conversions of budgets entered in another currency for one policy, newest first, each with the USD budget stored, the amount and currency entered and the rate used.

**Authentication:** `adminSession`

**Parameters**

| Name | In | Type | Description |
|---|---|---|---|
| `policy_id` | query | string, required, max length 128 | The budget policy whose currency conversions to list. |

**Responses**

| Status | Description | Body |
|---|---|---|
| `200` | Conversions | `application/json`: object |
| `400` | Invalid input | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `401` | Missing or invalid bearer key | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `403` | Model not allowed | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `404` | Feature disabled | `application/json`: [Error](/docs/api/schemas/e/#error) |
| `503` | Storage unavailable | — |

Response `200` fields:

- `application/json`: object
  - `data` (array of [FXBudgetConversion](/docs/api/schemas/f/#fxbudgetconversion), required, max items 50)

