# quotas (/docs/reference/api/quotas)

> A quota caps how much of one resource a tenant may hold in one pool at the same time, as a `max` and a `used` counter per tenant, pool and resource. A missing row grants 0; `pools.create` and `pools.offer` create the rows, and admissions charge them with `QUOTA_EXCEEDED` when a request does not fit. See [Quotas and usage](/docs/guides/capacity/quotas-and-usage).



A quota caps how much of one resource a tenant may hold in one pool at the same time, as a `max` and a `used` counter per tenant, pool and resource. A missing row grants 0; `pools.create` and `pools.offer` create the rows, and admissions charge them with `QUOTA_EXCEEDED` when a request does not fit. See [Quotas and usage](/docs/guides/capacity/quotas-and-usage).

All 2 methods are served by this release.

| Method        | Kind     | Authorization                             | Phase | Status     |
| ------------- | -------- | ----------------------------------------- | ----- | ---------- |
| [`get`](#get) | read     | `compute:quotas:read` @ `compute-tenant`  | v0.1  | registered |
| [`set`](#set) | mutation | `compute:quotas:manage` @ `compute-fleet` | v0.2  | registered |

## get [#get]

`POST /api/compute/quotas/get`

Returns the tenant's quota rows, each with `max`, `used` and `available`, optionally only those of one pool.

Rows are ordered by pool, then resource. `available` is `max` minus `used`, never below 0.

* **Kind:** read
* **Authorization:** `compute:quotas:read` @ `compute-tenant`
* **Module:** `capacity`
* **Phase:** v0.1 (registered)

**Input**

| Field      | Type   | Required | Constraints                                                       |
| ---------- | ------ | -------- | ----------------------------------------------------------------- |
| `tenantId` | string | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`        |
| `poolId`   | string |          | at most 57 characters; matches `^pool_[0-9a-hjkmnp-tv-z]{26,52}$` |

## set [#set]

`POST /api/compute/quotas/set`

Sets one tenant's maximum for one resource in one pool, creating the row if needed, and returns the row with the maximum that took effect.

* It is decided as `compute:quotas:manage` on `compute-fleet`, which resolves only in the root tenant, so only callers in the root tenant get past the tenant pre-check. `tenantId` names the tenant whose quota is set.
* A maximum below the current `used` is raised to `used`. To shrink a quota under live reservations, set it again once they have released.
* `NOT_FOUND` when the pool does not exist.

Emits `quota.updated` with the resource and the requested `max`.

* **Kind:** mutation
* **Authorization:** `compute:quotas:manage` @ `compute-fleet`
* **Module:** `capacity`
* **Phase:** v0.2 (registered)

**Input**

| Field      | Type    | Required | Constraints                                                       |
| ---------- | ------- | -------- | ----------------------------------------------------------------- |
| `tenantId` | string  | yes      | at most 128 characters; matches `^[A-Za-z0-9._:-]{1,128}$`        |
| `poolId`   | string  | yes      | at most 57 characters; matches `^pool_[0-9a-hjkmnp-tv-z]{26,52}$` |
| `resource` | string  | yes      | at most 64 characters; matches `^[A-Za-z][A-Za-z0-9._-]{0,63}$`   |
| `max`      | integer | yes      | at least 0                                                        |
