# Spend limits

> Spend limits per person and calendar month (UTC), checked with the organization's balance when every call reserves (chat completions, the agent gateway, module runs, chat sessions). The organization sets a default limit per person and overrides per person, both stored at the organization; no default means no person limit. Owners and admins also cap a team per UTC day, week or month (`PUT /v1/teams/{slug}/budget`): the cap is a pool for the team and every team under it. A call that would go over a person limit, a team cap or the organization's budget is refused with 402 `budget_exceeded`, naming the level, and counted as an overspend prevented. The 402 says what is left for the caller; only a person's 402 also names its limit. Person limits reset on the 1st at 00:00 UTC.

## Get person budget

`GET /v1/people/{userId}/budget`

One person's spend limit this month: their limit and where it comes from (override, default or none), month-to-date spend, what is left and whether they are at it. Yours (`me`) for anyone; anyone's for owners and admins.

Permission: `spend.read_own` (Every member).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `userId` | path | string | yes | A user id, or `me` |

### Responses

- `200` OK (application/json, PersonBudget)
  - `userId` (string, required)
  - `email` (string)
  - `name` (string)
  - `role` ("owner" | "admin" | "member", required)
  - `limitManager` (boolean): An admin an owner allowed to set person spend limits
  - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
  - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
  - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit
  - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9).
  - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`.
  - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
  - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
  - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
  - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
  - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
  - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
  - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused
  - `overspendsPrevented` (integer, required): Calls a spend limit refused this month
- `403` A member asking for another person's limit (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` No member with this user id in the organization (`not_found`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No member with this user id in the organization (`not_found`) |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/people/user_123/budget" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.personBudget();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fpeople%2F%7BuserId%7D%2Fbudget)

## Set person budget

`PUT /v1/people/{userId}/budget`

Set one person's monthly limit in USD, above or below the organization's default (owners, and admins an owner allowed: `grantLimitManager`; an owner's limit: owners only), or null to remove the override so the default applies again. Stored at the organization, naming the person; audited as budget.person_limit_changed, before and after. 403 `limit_grant_required` for an admin without the grant, and `role_required` for an owner's limit set by an allowed admin (both gateways). The amount is `monthlyUsd` (a number, deprecated, or a decimal string) or `monthlyUsdDecimal`, read exactly. 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`.

Permission: `budgets.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `userId` | path | string | yes | A user id, or `me` |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `monthlyUsd` (number | string | null): This person's monthly limit, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly; null removes the override. Send `monthlyUsdDecimal` instead to send only a string.
- `monthlyUsdDecimal` (string | null): This person's monthly limit as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null removes the override. With `monthlyUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$]

### Responses

- `200` OK (application/json, PersonBudget)
  - `userId` (string, required)
  - `email` (string)
  - `name` (string)
  - `role` ("owner" | "admin" | "member", required)
  - `limitManager` (boolean): An admin an owner allowed to set person spend limits
  - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
  - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
  - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit
  - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9).
  - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`.
  - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
  - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
  - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
  - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
  - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
  - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
  - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused
  - `overspendsPrevented` (integer, required): Calls a spend limit refused this month
- `400` `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin setting an owner's limit (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` No member with this user id in the organization (`not_found`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) |
| 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch` |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 403 | `limit_grant_required` | 403 `limit_grant_required` for an admin without the grant, and `role_required` for an owner's limit set by an allowed admin (both gateways) |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No member with this user id in the organization (`not_found`) |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/people/user_123/budget" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPersonBudget("<user id>", 200);
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fpeople%2F%7BuserId%7D%2Fbudget)

## List budgets

`GET /v1/budgets`

Spend limits this month: the organization's default per person and, for owners and admins, every person's limit (override or default), month-to-date spend, what is left, whether they are at their limit and the overspends prevented. Members see only their own row. `canManage`: you may set a person's limit (an owner, or an admin an owner allowed); `canGrant`: you may set the default per person and allow admins to set person limits (owners).

Permission: `spend.read_own` (Every member).

### Responses

- `200` OK (application/json, Budgets)
  - `period` (string, required): The calendar month (UTC)
  - `periodStart` (string (date-time), required)
  - `resetsAt` (string (date-time), required): The 1st of next month, 00:00 UTC
  - `personDefault` (object, required)
    - `monthlyUsd` (number | null, required): Deprecated: read `monthlyUsdDecimal`, the exact decimal string (root rule 9).
    - `monthlyUsdDecimal` (string | null): `monthlyUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `monthlyUsd`.
    - `updatedAt` (string (date-time))
    - `updatedBy` (string)
  - `scope` ("org" | "own", required): Org: everyone (owners and admins); own: only you
  - `people` (array of PersonBudget, required)
    - `userId` (string, required)
    - `email` (string)
    - `name` (string)
    - `role` ("owner" | "admin" | "member", required)
    - `limitManager` (boolean): An admin an owner allowed to set person spend limits
    - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
    - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
    - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit
    - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9).
    - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`.
    - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
    - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
    - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
    - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
    - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
    - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
    - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused
    - `overspendsPrevented` (integer, required): Calls a spend limit refused this month
  - `canManage` (boolean, required): You may set a person's limit: an owner, or an admin an owner allowed (both gateways)
  - `canGrant` (boolean): You may set the default per person and allow admins to set person limits: owners
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/budgets" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.budgets();
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets)

## Set person default budget

`PUT /v1/budgets/person-default`

Set the organization's default monthly limit per person in USD (owners only), or null to clear it: then people without an override have no limit of their own. Audited as budget.person_default_changed, before and after. 403 `role_required` for an admin an owner allowed (only an owner changes the default per person), and `limit_grant_required` for an admin without the grant (both gateways). The amount is `monthlyUsd` (a number, deprecated, or a decimal string) or `monthlyUsdDecimal`, read exactly. 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch`.

Permission: `budgets.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `monthlyUsd` (number | string | null): The default monthly limit per person, in US dollars, at most 1000000: a JSON number (deprecated) or a decimal string with at most 6 decimals (`"12.245"`), read exactly; null clears it. Send `monthlyUsdDecimal` instead to send only a string.
- `monthlyUsdDecimal` (string | null): The default monthly limit per person as a decimal string in US dollars, at most 6 decimals, never below 0; read exactly into micro-dollars, never through a float. null clears it. With `monthlyUsd` too, both must name the same amount (400 `amount_mismatch`). [pattern ^[0-9]+(\.[0-9]{1,6})?$]

### Responses

- `200` OK (application/json, Budgets)
  - `period` (string, required): The calendar month (UTC)
  - `periodStart` (string (date-time), required)
  - `resetsAt` (string (date-time), required): The 1st of next month, 00:00 UTC
  - `personDefault` (object, required)
    - `monthlyUsd` (number | null, required): Deprecated: read `monthlyUsdDecimal`, the exact decimal string (root rule 9).
    - `monthlyUsdDecimal` (string | null): `monthlyUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `monthlyUsd`.
    - `updatedAt` (string (date-time))
    - `updatedBy` (string)
  - `scope` ("org" | "own", required): Org: everyone (owners and admins); own: only you
  - `people` (array of PersonBudget, required)
    - `userId` (string, required)
    - `email` (string)
    - `name` (string)
    - `role` ("owner" | "admin" | "member", required)
    - `limitManager` (boolean): An admin an owner allowed to set person spend limits
    - `limitUsd` (number | null, required): Their limit this month; null: no limit of their own. Deprecated: read `limitUsdDecimal`, the exact decimal string (root rule 9).
    - `limitUsdDecimal` (string | null): `limitUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `limitUsd`.
    - `source` ("override" | "default" | "none", required): Override: set for them; default: the organization's default per person; none: no limit
    - `overrideUsd` (number | null, required): Their override, when they have one. Deprecated: read `overrideUsdDecimal`, the exact decimal string (root rule 9).
    - `overrideUsdDecimal` (string | null): `overrideUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `overrideUsd`.
    - `spentUsd` (number, required): Settled since the 1st, 00:00 UTC, across every team they spend through. Deprecated: read `spentUsdDecimal`, the exact decimal string (root rule 9).
    - `spentUsdDecimal` (string): `spentUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `spentUsd`.
    - `reservedUsd` (number, required): Held by their calls in flight. Deprecated: read `reservedUsdDecimal`, the exact decimal string (root rule 9).
    - `reservedUsdDecimal` (string): `reservedUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `reservedUsd`.
    - `remainingUsd` (number | null, required): Deprecated: read `remainingUsdDecimal`, the exact decimal string (root rule 9).
    - `remainingUsdDecimal` (string | null): `remainingUsd` as an exact decimal string in US dollars with six decimals (`"12.245000"`), from the micro-dollars. Prefer it to `remainingUsd`.
    - `atLimit` (boolean, required): Spent and reserved reach the limit: their next call is refused
    - `overspendsPrevented` (integer, required): Calls a spend limit refused this month
  - `canManage` (boolean, required): You may set a person's limit: an owner, or an admin an owner allowed (both gateways)
  - `canGrant` (boolean): You may set the default per person and allow admins to set person limits: owners
- `400` `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` A member (`role_required`), an admin an owner has not allowed (`limit_grant_required`), or an allowed admin (`role_required`: only an owner changes the default per person) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | `monthlyUsd` and `monthlyUsdDecimal` both missing (`invalid_request`), a decimal string with more than 6 decimals (`too_many_decimals`), an amount that is not one, is below 0 or is above 1000000 (`invalid_amount`), or a number and its `Decimal` twin that name different amounts, or `null` beside an amount (`amount_mismatch`) |
| 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `amount_mismatch` |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/budgets/person-default" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.setPersonDefaultBudget(50);
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Fperson-default)

## Get product budget

`GET /v1/budgets/products/{product}/{capability}`

The monthly cap on one module capability, such as Nexus Review's `robustness` / `review` (owners and admins): its limit, the UTC month's spend of every call attributed to it (whoever paid the provider), what open calls hold, what is left and when it resets. Every amount is a decimal string. `cap` is null when the capability has none. 400 `invalid_product`.

Permission: `spend.read_all` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `product` | path | string | yes | The module's product, as its calls are attributed (`robustness` for Nexus Review). |
| `capability` | path | string | yes | The capability within it (`review`). |

### Responses

- `200` OK (application/json, ProductBudget)
  - `product` (string, required)
  - `capability` (string, required)
  - `cap` (object | null, required)
    - `limitUsd` (string, required): The budget's amount for its period. [pattern ^[0-9]+\.[0-9]{6}$]
    - `every` ("day" | "week" | "month", required): The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month.
    - `monthlyUsd` (string, required): The budget's amount whatever its period; read `limitUsd` and `every` instead. [pattern ^[0-9]+\.[0-9]{6}$]
    - `period` (string, required): The period: `YYYY-MM-DD` for a day, `YYYY-Www` for a week, `YYYY-MM` for a month.
    - `spentUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `feesUsd` (string, required): The product's own fees this month (`POST /v1/budgets/usage`), part of `spentUsd`. [pattern ^[0-9]+\.[0-9]{6}$]
    - `reservedUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `remainingUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `resetsAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)
  - `canManage` (boolean, required)
- `400` Not a product or capability slug (`invalid_product`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Only owners and admins read a product's cap (`role_required`): a member without `spend.read_all` (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 |  | Not a product or capability slug (`invalid_product`) |
| 400 | `invalid_product` | 400 `invalid_product` |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/budgets/products/<product>/<capability>" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets%2Fproducts%2F%7Bproduct%7D%2F%7Bcapability%7D)

## Set product budget

`PUT /v1/budgets/products/{product}/{capability}`

Set or remove the monthly cap on one module capability (owners and admins). `monthlyUsd` is a decimal string in US dollars, or null to remove the cap. The ledger refuses a call that would take the capability's UTC month past it with 402 `budget_exceeded`, `details.level: product`; a cap cut below what the month used refuses the next call and leaves calls in progress alone. Audited as budget.product_changed, before and after. 400 `invalid_amount`, `too_many_decimals`, `invalid_product`.

Permission: `budgets.manage` (Owner, Admin).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `product` | path | string | yes | The module's product, as its calls are attributed (`robustness` for Nexus Review). |
| `capability` | path | string | yes | The capability within it (`review`). |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Request body (application/json, required)

- `limitUsd` (string | null) [pattern ^[0-9]+(\.[0-9]{1,6})?$]
- `every` ("day" | "week" | "month"): Required with `limitUsd`.
- `monthlyUsd` (string | null): A monthly budget. Not with `limitUsd`. [pattern ^[0-9]+(\.[0-9]{1,6})?$]

### Responses

- `200` OK (application/json, ProductBudgetChange)
  - `product` (string, required)
  - `capability` (string, required)
  - `before` (object, required)
    - `limitUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `every` ("day" | "week" | "month" | null, required)
    - `monthlyUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$]
  - `after` (object, required)
    - `limitUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `every` ("day" | "week" | "month" | null, required)
    - `monthlyUsd` (string | null, required) [pattern ^[0-9]+\.[0-9]{6}$]
- `400` Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Members: only owners and admins set a cap (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | Not a valid cap (`invalid_amount`), a decimal string with more than 6 decimals (`too_many_decimals`), or not a slug (`invalid_product`) |
| 400 | `invalid_amount` | 400 `invalid_amount`, `too_many_decimals`, `invalid_product` |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 402 | `budget_exceeded` | The ledger refuses a call that would take the capability's UTC month past it with 402 `budget_exceeded`, `details.level: product`; a cap cut below what the month used refuses the next call and leaves calls in progress alone |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/budgets/products/<product>/<capability>" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "limitUsd": "<limitUsd>",
    "every": "day",
    "monthlyUsd": "<monthlyUsd>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Fproducts%2F%7Bproduct%7D%2F%7Bcapability%7D)

## Get product usage

`GET /v1/budgets/usage`

A module's product cap this UTC month and the price of each unit it records (a module's scoped key only). The product and capability are the key's. `cap` is null without a cap, else as `GET /v1/budgets/products/{product}/{capability}` shows it. Nexus Review reads it before its first model call and pauses a run the cap has no room for.

Permission: `models.use` (Every member, module keys).

### Responses

- `200` OK (application/json, ProductUsageMonth)
  - `product` (string, required)
  - `capability` (string, required)
  - `cap` (object | null, required): Null without a cap, else as `GET /v1/budgets/products/{product}/{capability}` shows it.
    - `limitUsd` (string, required): The budget's amount for its period. [pattern ^[0-9]+\.[0-9]{6}$]
    - `every` ("day" | "week" | "month", required): The budget's period, in UTC: a day, an ISO week from Monday, or a calendar month.
    - `monthlyUsd` (string, required): The budget's amount whatever its period; read `limitUsd` and `every` instead. [pattern ^[0-9]+\.[0-9]{6}$]
    - `period` (string, required): The period: `YYYY-MM-DD` for a day, `YYYY-Www` for a week, `YYYY-MM` for a month.
    - `spentUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `feesUsd` (string, required): The product's own fees this month (`POST /v1/budgets/usage`), part of `spentUsd`. [pattern ^[0-9]+\.[0-9]{6}$]
    - `reservedUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `remainingUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
    - `resetsAt` (string (date-time), required)
    - `updatedAt` (string (date-time), required)
  - `unitPricesUsd` (object, required): The price of one of each unit the product records (`review` for Nexus Review).
- `403` Not a module's scoped key (`module_key_required`): a use belongs to the module that made it (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl "$NEXUS_URL/v1/budgets/usage" \
  -H "Authorization: Bearer $NEXUS_API_KEY"
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#get%3A%2Fv1%2Fbudgets%2Fusage)

## Record product usage

`POST /v1/budgets/usage`

Record one use of the key's product, such as one pull request Nexus Review reviewed (a module's scoped key only). The Gateway prices it (`NEXUS_PRICE_REVIEW_PR_MICROS` for Nexus Review's `review`, 0 by default), and the month's amounts count in the product cap. The row is append-only and keyed by `usageKey`: a repeat with the same unit and quantity answers the stored row with `recorded: false`, and a repeat that differs is a 409.

Permission: `models.use` (Every member, module keys).

### Request body (application/json, required)

- `usageKey` (string, required): One per use: Nexus Review sends `<owner>/<repo>#<pr>`. [pattern ^[A-Za-z0-9._/#@-]{1,200}$]
- `unit` (string, required): What was used: `review` for Nexus Review.
- `quantity` (integer) [min 1; max 1000; default 1]

### Responses

- `200` OK (application/json, ProductUsage)
  - `id` (string, required)
  - `product` (string, required)
  - `capability` (string, required)
  - `usageKey` (string, required)
  - `unit` (string, required)
  - `quantity` (integer, required)
  - `unitPriceUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
  - `amountUsd` (string, required) [pattern ^[0-9]+\.[0-9]{6}$]
  - `at` (string (date-time), required)
  - `recorded` (boolean, required): False when the usage key was already recorded: this is the stored row.
- `400` Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `403` Not a module's scoped key (`module_key_required`): a use belongs to the module that made it (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `409` The usage key was already recorded with another unit or quantity (`usage_conflict`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | `invalid_request_error` | A field is missing or not valid; the message names it |
| 400 |  | Not a usage key (`invalid_usage_key`), a unit the product records (`unknown_unit`), a quantity from 1 to 1000 (`invalid_quantity`), or an amount over $1,000 (`amount_too_large`) |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 409 |  | The usage key was already recorded with another unit or quantity (`usage_conflict`) |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X POST "$NEXUS_URL/v1/budgets/usage" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "usageKey": "<usageKey>",
    "unit": "<unit>"
  }'
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#post%3A%2Fv1%2Fbudgets%2Fusage)

## Grant limit manager

`PUT /v1/budgets/limit-managers/{userId}`

Allow an admin to set each person's spend limit, but not an owner's and not the default per person (owners only; owners always can). The grant is on the admin's membership: it ends when they stop being an admin or leave, and does not come back when they return. Granting an admin who has it writes nothing. Audited as budget.limit_manager_granted, `limitManager` before and after, ids only. 409 `not_an_admin` for an owner, a team lead or a member.

Permission: `budgets.delegate` (Owner).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `userId` | path | string | yes | A user id, or `me` |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

- `200` OK (application/json, LimitManager)
  - `userId` (string, required)
  - `limitManager` (boolean, required)
- `403` Not an owner (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` No such member (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `409` The person is not an admin (`not_an_admin`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such member |
| 409 |  | The person is not an admin (`not_an_admin`) |
| 409 | `not_an_admin` | 409 `not_an_admin` for an owner, a team lead or a member |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X PUT "$NEXUS_URL/v1/budgets/limit-managers/user_123" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.grantLimitManager("<user id>");
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#put%3A%2Fv1%2Fbudgets%2Flimit-managers%2F%7BuserId%7D)

## Revoke limit manager

`DELETE /v1/budgets/limit-managers/{userId}`

Stop an admin setting person spend limits (owners only). The limits they set stay. Revoking from someone without the grant writes nothing. Audited as budget.limit_manager_revoked, `limitManager` before and after, ids only.

Permission: `budgets.delegate` (Owner).

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `userId` | path | string | yes | A user id, or `me` |
| `Idempotency-Key` | header | string | no | Send the same key again to retry safely: the request runs once. See [Idempotency keys](/docs/concepts/idempotency). |

### Responses

- `200` OK (application/json, LimitManager)
  - `userId` (string, required)
  - `limitManager` (boolean, required)
- `403` Not an owner (`role_required`) (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `404` No such member (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.
- `429` Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). (application/json, Error)
  - `error` (object)
    - `message` (string, required)
    - `type` (string, required): The class of the error: invalid_request_error (400, 405, 408, 409, 413, 422, 426), authentication_error (401), billing_error (402), permission_error (403), not_found (404), rate_limit_error (429), or a 5xx type such as server_error.
    - `code` (string): Stable: branch on it, not on message. Every 4xx carries one: its site's own code, else the default for its status (400 invalid_request, 401 unauthenticated, 402 payment_required, 403 forbidden, 404 not_found, 405 method_not_allowed, 408 request_timeout, 409 conflict, 422 unprocessable, 429 rate_limited, any other 4xx invalid_request). A 502 carries its site's code, else upstream_error. Any other 5xx carries one only when its site sets it. The agent routes (/v1/anthropic/, /v1/openai/) answer in the provider's shape.
    - `param` (string): `model` when the error is a model refusal (a `code` starting with `model_`); absent otherwise.
    - `nexus` (object): Details of the error, when it has any: the policy rule of a model refusal, the seconds of a 408.
    - `minimum` (string): On a 426 `cli_too_old` only: the oldest `nexus` CLI version Gateway supports.

### Errors

| Status | Code | When |
| --- | --- | --- |
| 401 | `authentication_error` | No key, or a key Gateway does not accept |
| 403 | `role_required` | Your role does not have this permission |
| 404 | `not_found` | Nothing matches the path in your organization |
| 404 |  | No such member |
| 409 | `idempotency_in_progress` | A request with the same Idempotency-Key is still running |
| 409 | `idempotency_interrupted` | The first request with this Idempotency-Key was cut off and may have run in part |
| 422 | `idempotency_key_reused` | The Idempotency-Key was used with a different request |
| 429 |  | Over the caller's rate limit (`rate_limit_error`): retry after `Retry-After` seconds. Also a 429 `concurrency_limit`, with `Retry-After: 1`, when the organization already has its most requests in flight (off unless Gateway sets a cap). |
| 429 | `rate_limit_error` | Too many requests from this key in a minute |

### Example

```sh
curl -X DELETE "$NEXUS_URL/v1/budgets/limit-managers/user_123" \
  -H "Authorization: Bearer $NEXUS_API_KEY" \
  -H "Idempotency-Key: $(uuidgen)"
```

```ts
import { createCoreClient } from "@nexus/kit";

const core = createCoreClient({ baseUrl: process.env.NEXUS_URL!, apiKey: process.env.NEXUS_API_KEY });
const result = await core.revokeLimitManager("<user id>");
```

Try it: [API Explorer](/app?next=%2Fapi-explorer#delete%3A%2Fv1%2Fbudgets%2Flimit-managers%2F%7BuserId%7D)
