# Spend limits

> A monthly spend limit per person, a default for everyone and overrides for some. Owners set both, and admins an owner allows set each person's limit. Checked on every call before it reaches a provider.

Your organization's budget caps what everyone spends together. A **spend limit** caps what one person spends in a
calendar month, so a single runaway agent session or script can't use up the budget for everyone else.

## How a limit is set

An owner sets two things, both at the organization:

- **A default per person.** Everyone without a limit of their own can spend this much a month. With no default, people
  have no limit of their own; only the organization's budget applies.
- **A limit for one person.** Above or below the default, for one person. It wins over the default for them; remove it
  and the default applies again.

```sh
nexus budgets default 50                 # $50 a month for everyone without a limit of their own
nexus budgets set ada@acme.example 200   # Ada: $200 a month
nexus budgets set ada@acme.example default   # Ada: back to the default
nexus budgets default none               # no default: no person limits
```

Every change is in the [audit log](/docs/concepts/audit-log), with the value before and after
(`budget.person_default_changed`, `budget.person_limit_changed`). When a person is removed, their own limit closes
with them. Recovering them inside 30 days brings it back. This includes a removal by an admin whom no owner has allowed
to set limits.

## Who can set a limit

An owner sets the default per person and each person's limit. An owner can also allow a named admin to set each
person's limit. Team leads and members never set limits: they get `403` with code `role_required`.

Only an owner sets the default per person, and only an owner sets an owner's limit. An allowed admin who tries gets
`403` with code `role_required`. An admin whom no owner has allowed gets `403` with code `limit_grant_required`.

### Allow an admin

An owner allows an admin one person at a time. The admin can then set each person's limit, except an owner's. The
default per person stays with owners.

```sh
nexus budgets managers                           # every owner, then the admins an owner has allowed
nexus budgets managers add dee@acme.example      # allow an admin
nexus budgets managers remove dee@acme.example   # stop them
```

The API is `PUT /v1/budgets/limit-managers/{userId}` to allow an admin and `DELETE` on the same path to stop them. Only
an owner can call either one. Both answer `{ "userId": "…", "limitManager": true }`, with `false` after a `DELETE`.

- An owner does not need to be allowed: an owner can always set limits.
- Only an admin can be allowed. For anyone else the answer is `409` with code `not_an_admin`.
- Allowing an admin who is already allowed, or stopping one who is not, changes nothing and writes no audit event.

The allowance lasts only while the person is an admin. It ends when they become a member, when ownership is
transferred to them, and when they leave the organization. When an owner transfers ownership, the previous owner becomes
an admin with no allowance. A person who becomes an admin again starts without it, so an owner must allow them again.
The limits they set before stay in place.

Allowing and stopping are in the [audit log](/docs/concepts/audit-log) as `budget.limit_manager_granted` and
`budget.limit_manager_revoked`. The event names the admin, and shows `limitManager` before and after. An allowance that
ends with a role change, a transfer or a removal writes no `budget.limit_manager_revoked` event. The event for that role
change, transfer or removal is the record.

## How it's checked

A limit counts everything the person spends in the calendar month, in UTC: every model call they make, their
`nexus claude` and `nexus codex` sessions, the products they run and their chats, through whichever team the spend
goes to. It resets on the 1st at 00:00 UTC.

The check happens when a call [reserves](/docs/concepts/ledger) its maximum cost, together with the organization's
budget and the caps on the call's team: the person's spend this month, plus their calls still running, plus this
call's maximum, must fit in their limit. If it doesn't, the call is refused with `402` and code `budget_exceeded`
before anything is sent to a provider, in the error shape of the API you called (OpenAI's for `/v1/chat/completions` and `nexus codex`, Anthropic's for
`nexus claude`). The error names the level and the limit:

```json
{
  "error": {
    "message": "person limit: this call may cost up to $0.004096, and $0.00 of your $1.00 monthly limit is left (the organization's default per person); it resets on 2026-11-01 (UTC)",
    "type": "billing_error",
    "code": "budget_exceeded",
    "nexus": { "level": "person", "limitUsd": 1, "limitUsdDecimal": "1.000000", "source": "default", "period": "2026-10", "spentUsd": 1, "spentUsdDecimal": "1.000000", "reservedUsd": 0, "reservedUsdDecimal": "0.000000", "requestedUsd": 0.004096, "requestedUsdDecimal": "0.004096", "resetsAt": "2026-11-01T00:00:00.000Z" }
  }
}
```

Each amount comes twice: as a number, which is deprecated, and as its exact decimal string (`requestedUsdDecimal`).
Read the decimal string.

A refused call costs nothing and is recorded as an **overspend prevented**: `nexus spend` and the Spend page show it
among the calls, and `nexus budgets` counts them per person.

Lowering a limit below what a person has already spent stops their next call, never one already running.

## Where to see it

- **Nexus UI → Spend → Spend limits**: the default per person on one line, then a table of everyone with three
  columns: name, spend limit and spend this month. What calls still running hold shows under the spend as "in flight".
  A person at their limit has a warning mark. Owners edit the default and each person's limit there. Admins an owner
  allowed edit each person's limit, except an owner's.
- **`nexus budgets`**: everyone's limit, spend, what is left and the calls a limit refused; `nexus budgets show me` for
  your own month; `nexus budgets managers` for every owner and the admins an owner has allowed.
- **The API**: [`GET /v1/budgets`](/docs/api/budgets), `PUT /v1/budgets/person-default`,
  `GET`/`PUT /v1/people/{userId}/budget` and `PUT`/`DELETE /v1/budgets/limit-managers/{userId}`.

Send a limit as a decimal string in `monthlyUsdDecimal`, with at most 6 decimals. Send `null` to clear it.

```json
{ "monthlyUsdDecimal": "50.00" }
```

A JSON number in `monthlyUsd` still works, but it is deprecated.

`GET /v1/budgets` also says what the caller may do. `canManage` is true for a caller who may set a person's limit: an
owner, or an admin an owner allowed. `canGrant` is true for an owner, who alone sets the default per person and allows
admins. Each person in the answer has `limitManager`, which is true for an allowed admin.

### The table

- **Search** by name or email.
- **Filter** by where the limit comes from: own limit, default limit or no limit.
- **At limit.** When someone is at their limit, a chip counts them ("2 at limit"). Press it to show only those people.
- **Sort** by name, spend limit or spend. Without a sort, the person who spent the most this month is first.
- **Edit in place.** Click a limit to change it, then save. "Use default" removes a person's own limit. The default per
  person has an Edit button for an owner, and "Clear" removes it.
- **Select the amount.** The editor opens with the amount selected. Type to replace it, or press Backspace to clear it.
  Enter saves, and Escape closes the editor.
- **Who can change limits.** An owner sees a switch for each admin above the table. Turn it on to allow the admin to set
  limits, as `nexus budgets managers add` does, and off to stop them. An allowed admin sees a line that says so.

Only a person who may change a limit sees its edit control. An admin an owner allowed sees none on an owner's row, and
none for the default per person. An admin whom no owner has allowed sees the table without any.

Members see only their own limit and spend, and `nexus spend` gives them only what is left for them. Teams have their
own caps: see [Teams](/docs/concepts/teams#model-policies-and-budgets).
