# Errors

> Every error has an HTTP status, a type, often a stable code, and a message that says what to do.

Errors from the Nexus API share one shape:

```json
{
  "error": {
    "message": "there is already a team platform in this organization",
    "type": "invalid_request_error",
    "code": "slug_taken"
  }
}
```

- `message` is written for people: it names what is wrong and, where it can, what to do next.
- `type` is the broad class, by status.
- `code` is stable: match on it in code, never on the message. Every `4xx` carries one, and a `5xx` only when it
  names a cause.

The agent gateway (`/v1/anthropic/…`, `/v1/openai/…`) answers errors in the provider's own error format instead, so
Claude Code, Codex and the providers' SDKs understand them. So are model refusals on chat completions; see
[Models and policies](/docs/concepts/models-and-policies#when-a-model-is-refused).

## By status

| Status | Type | Meaning |
| --- | --- | --- |
| `400` | `invalid_request_error` | A field is missing or not valid; the message names it |
| `401` | `authentication_error` | No token, or a token Gateway does not accept: sign in again |
| `402` | `billing_error` | The call's maximum cost is more than the budget, the free start, the credits or the usage limit left, or a payment did not go through; see the code |
| `403` | `permission_error` | Your role or your key may not do this |
| `404` | `not_found` | Nothing matches in your organization |
| `405` | `invalid_request_error` | The method is not allowed on this path |
| `409` | `invalid_request_error` | The request conflicts with the current state; see the code |
| `413` | `invalid_request_error` | The request body is too large |
| `422` | `invalid_request_error` | An idempotency key was reused for a different request |
| `426` | `invalid_request_error` | The `nexus` CLI is older than this Gateway supports (`cli_too_old`): run `nexus update` |
| `429` | `rate_limit_error` | Too many requests from this key in a minute: wait and retry |
| `500` | `server_error` | Something unexpected failed on Gateway; the cause is in its logs, not in the answer |
| `501` | `not_implemented` | Not built yet (`not_ported`) |
| `502` | `api_error`, `module_unavailable`, `connector_error` | A provider, product or outside service behind Gateway did not answer |
| `503` | `not_configured`, `server_error` | Not configured on this Gateway, or the database is busy (`database_busy`): retry |
| `504` | `api_error` | The request passed Gateway's deadline (`timeout`), or a product's module did not answer in time (`module_timeout`) |

## Codes

| Code | Status | What to do |
| --- | --- | --- |
| `role_required` | `403` | Ask an owner or admin; the message says which roles may |
| `not_in_team` | `403` | Name a team you belong to, or ask to be added |
| `model_not_allowed` | `403` | Use a model your policies allow: `nexus models`; `nexus policy test` names the rule |
| `model_not_found` | `404` | Check the name: `nexus models --all` lists the catalog |
| `model_not_supported` | `400` | The model is coming soon, or not served on this API |
| `cli_too_old` | `426` | Run `nexus update` |
| `module_key` | `403` | A product's scoped key can only call models and connectors |
| `module_unavailable` | `502` | The product's module failed or could not be reached; the message names it. Retry later |
| `module_timeout` | `504` | The product's module did not answer within 28 s and may have started the work. Check its state before you retry. With the same `Idempotency-Key`, a retry gets `idempotency_interrupted` |
| `nexus_ui_only` | `403` | Do this in Nexus UI |
| `unknown_team` | `404` | Check the slug: `nexus team list` |
| `budget_exceeded` | `402` | Check `nexus spend`; an owner or admin can raise the budget |
| `limit_grant_required` | `403` | You may not set person spend limits. Ask an owner to set the limit, or to allow you to: `nexus budgets managers add` |
| `payment_past_due` | `402` | An invoice is unpaid past its grace period, so Nexus does not pay for the call: ask an owner to pay the month the message names, or use your own provider key |
| `subsidy_exhausted` | `402` | The free start is used up, or pays only for cheaper models. Set up billing (`nexus billing`), pick a cheaper model, or add your own provider key |
| `credit_exhausted` | `402` | The Nexus credits are used up: buy more with `nexus billing credits buy`, or add your own provider key |
| `usage_limit_reached` | `402` | What is left of this month's usage limit does not cover the call's cost at most (`details.requestedUsd` and `details.remainingUsd`): an owner raises the limit, or buys credits, in `nexus billing` |
| `payment_failed` | `402` | The last card charge failed: an owner replaces the card with `nexus billing card add`. When the bank wants the cardholder to confirm it (3-D Secure), an owner approves that same charge with `nexus billing confirm` |
| `charge_processing` | `402` | A charge for usage is still going through, such as a bank debit, and the card pays for no more calls until it is paid (`details.chargeUsd`, `details.unpaidUsd`, `details.capUsd`). Credits and your own provider keys still pay |
| `provider_key_required` | `403` | Your organization has no key for this provider: an owner or admin adds one with `nexus keys add` |
| `subscriptions_disabled` | `403` | Your organization turned off agents on personal plans: run the agent through Gateway (`--api`). Antigravity does not run until an owner or admin allows personal plans again: `nexus org settings set agentSubscriptions true` |
| `route_unsupported` | `400` | The agent runs only on your own plan, so `--api` is not available. Run it on your plan: `nexus agy --subscription` for Antigravity |
| `slug_taken` | `409` | Choose another slug |
| `team_cycle`, `too_deep` | `409` | A team can't be under itself, or more than 10 levels deep |
| `has_children` | `409` | Delete with `cascade=1`, or move the child teams first |
| `plan_changed` | `409` | Run the import's dry run again and review the new plan |
| `confirmation_required` | `400` | Send `expect` with the number of invitations you confirmed |
| `count_changed` | `409` | The number of invitations changed; review it again |
| `not_a_clerk_org` | `409` | This organization has no sign-in through Nexus UI, so there is no one to invite to it |
| `owner_role` | `409` | Transfer ownership first |
| `not_an_admin` | `409` | Only an admin can be allowed to set person spend limits: check the person's role with `nexus members` |
| `code_used` | `409` | Start `nexus auth login` again |
| `installation_taken` | `409` | That GitHub installation is linked to another organization |
| `api_key_limit` | `409` | You hold 100 live API keys in this organization: revoke one first |
| `idempotency_in_progress` | `409` | The first request with this key is still running: retry in a moment |
| `idempotency_interrupted` | `409` | The first request with this key was cut off and may have run in part: check the state, then use a new key |
| `idempotency_key_reused` | `422` | Use a new key for a different request |
| `idempotency_stream_replay` | `409` | A finished streamed call is not replayed: use a new key |
| `idempotency_already_charged` | `409` | That call was already charged: use a new key to run it again |
| `invalid_idempotency_key` | `400` | Keys are 1 to 255 printable ASCII characters |
| `invalid_cursor` | `400` | Start the listing again without `cursor` |
| `database_busy` | `503` | Nothing was written: retry |

## In the CLI

The CLI prints an error as one line and the fix, and exits non-zero: `1` for a failure, `2` for a usage error.
With `--json`, it prints `{"error": {"message", "hint"}}` on stderr. `NEXUS_DEBUG=1` adds the stack trace.
