# Every error code

> Every error code the gateway can return, what it means, and whether you were charged.

Source: https://www.nexus402.dev/docs/developers/errors/

> **This table is generated from the gateway's own source**
>
> The codes are extracted from the gateway’s own source — both the error registry and the handlers that write a code by hand. A code nobody documented **fails our tests**, and so does prose for a code the gateway no longer emits, so this list cannot quietly fall behind the thing it describes.

## The codes

| Code | HTTP | Charged | `X-Nexus-Error` | What happened | What to do |
| --- | --- | --- | --- | --- | --- |
| `Budget_Exhausted` | 402 | No | Set | The wallet cannot cover this call, or the key's rolling 24-hour cap would be exceeded. Both are reported the same way, deliberately: either way you have hit a ceiling you set. | X-Nexus-Required-Amount (and the body's required) is the call's full price in decimal dollars, not the shortfall. Add funds or raise that key's cap. |
| `Rate_Limited` | 429 | No | Set | Reserved: nothing in the gateway sends this code today. A 429 that a creator returns is relayed with the creator's own status and body, carries no X-Nexus-Error, and is refunded. The 429 the gateway sends is key_rate_limited. | Honour Retry-After wherever a 429 carries one. Retrying sooner meets the same window and wastes the attempt. |
| `Upstream_Unavailable` | 502 | No | Set | The creator's endpoint failed, timed out before its first byte, answered in a shape we refuse to relay, or has failed often enough that we stopped dialling it for a cooldown. This 502 is sent only after the charge is voided, or before any was taken. | Retry. A failure after the response began is not a 502: the status stays 200, the payload_truncated trailer is sent, and the charge stands. |
| `Lock_Unavailable` | 503 | No | Set | Our own infrastructure could not authorize the call, so we failed closed rather than guess. A metering system that cannot read its own state must refuse, not assume. | Retry with backoff. A 503 is never a silent debit. |
| `Idempotency_Conflict` | 422 | No | Set | This Idempotency-Key is already bound to a call. A retry of the same request is refused unless that call was refunded, and a different request under the key is always refused. Nothing is replayed, because payloads are never stored. | Check your call log for the first attempt. Use a fresh key for a new request; a key whose call was refunded may be retried. |
| `Authorization_Rejected` | 400 | No | Set | Your pass-through Authorization header carried an nx_dev_ token, which would have handed your Nexus key to a creator who could then spend your wallet. | Put the tool's own credential there, never your Nexus key. |
| `Unknown_Version` | 404 | No | Not set | The tool exists but the version you pinned does not, or it has been retired. A published version is immutable, so a new price or endpoint ships as a new version instead of changing the one you pinned. | Drop the @v pin to resolve the highest published version, or pin one that GET /v1/tools still lists. |
| `Unknown_Tool` | 404 | No | Not set | Nothing is published under that name. A tool name is creator-handle/mcp-name/tool-name, with an optional @v pin on the middle segment, and it resolves against the published catalogue rather than against anything you called before. | Check the name against GET /v1/tools. An unpublished tool is not listed there, and neither is a retired version. |
| `Method_Not_Allowed` | 405 | No | Not set | The method is not implemented on that route — in practice a GET on /v1/mcp. The gateway opens no server-initiated stream, because it has nothing to push that is not the answer to a paid POST. | Read the Allow header and use the method it names. |
| `key_rate_limited` | 429 | No | Set | Too many requests for this key inside its window, counted after your key is verified and before anything is deducted. This is the rate limit you will actually meet. | Honour Retry-After, which is the seconds left in the window. Spread load across keys only if that reflects real separate workloads. |

## The shape of a refusal

Every code is in the body. Most are also in the `X-Nexus-Error` header, so you can branch on them without parsing JSON; the exceptions are the `404`s, the `405` and the `401`, which carry the code in the body only, as the table says.

On a `402`, `required` and `X-Nexus-Required-Amount` are the **full price of the call** you tried, in decimal US dollars — not the shortfall. This one call cost five cents:

```
HTTP/1.1 402 Payment Required
X-Nexus-Error: Budget_Exhausted
X-Nexus-Required-Amount: 0.05
X-Nexus-Currency: USD
X-Correlation-ID: 7f3a9c12-4e5b-4d8a-9f01-2b3c4d5e6f70

{"error":{"code":"Budget_Exhausted","required":"0.05","currency":"USD"}}
```

## Refusals outside this table

The table covers the gateway’s named error codes. A request can also be turned away in one of these ways, and none of them is charged:

- **`401` `{"error":{"code":"unauthorized"}}`** — the key is missing, unknown, revoked or expired, or too many failed attempts came from your address. Body only, no `X-Nexus-Error`. A creator key (`nx_crt_`) in the key header gets the same 401 with a message saying so.
- **`413`** `{"error":"request body too large"}`, **`408`** when the body does not arrive in time, and **`400`** when it cannot be read at all.
- **`415`** when the declared `Content-Type` is not JSON in UTF-8.
- **A JSON-RPC error at HTTP `200`**: `-32602 Invalid params` for a body that is not a JSON-RPC request, a request with no `id`, a method the gateway does not serve, or a tool name that does not parse. It is a JSON-RPC answer rather than an HTTP refusal, so check the body’s `error` as well as the status.

## The correlation id

`X-Correlation-ID` is on every response, success or failure. Log it. It is the one thing that lets us answer a question about a specific call — we do not store your payloads, so it is the handle on a request rather than a copy of it.

## The rule for charges

> **If we did not authorize it, we did not bill it**
>
> A 400, 401, 402, 422, 429 or 503 is never charged. There is no partial charge for a refused request and no fee for being rate limited.
>
> The only case where a failure costs you is a tool that failed *after* its first byte reached you — the work was done and partly delivered. See [when you are charged](https://www.nexus402.dev/docs/developers/billing/).

## Ask your agent

When a call fails, paste the prompt for its code into the agent that wrote the call. Each one is built from this page's table, so it says what the code means, whether you were charged, and what to do, and it tells the agent never to print your key.

**`402 Budget_Exhausted`**

**Prompt for Budget_Exhausted**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 402 Budget_Exhausted.
Nexus402 says: The wallet cannot cover this call, or the key's rolling 24-hour cap would be exceeded. Both are reported the same way, deliberately: either way you have hit a ceiling you set.
Charged: No. What to do: X-Nexus-Required-Amount (and the body's required) is the call's full price in decimal dollars, not the shortfall. Add funds or raise that key's cap.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`429 Rate_Limited`**

**Prompt for Rate_Limited**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 429 Rate_Limited.
Nexus402 says: Reserved: nothing in the gateway sends this code today. A 429 that a creator returns is relayed with the creator's own status and body, carries no X-Nexus-Error, and is refunded. The 429 the gateway sends is key_rate_limited.
Charged: No. What to do: Honour Retry-After wherever a 429 carries one. Retrying sooner meets the same window and wastes the attempt.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`502 Upstream_Unavailable`**

**Prompt for Upstream_Unavailable**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 502 Upstream_Unavailable.
Nexus402 says: The creator's endpoint failed, timed out before its first byte, answered in a shape we refuse to relay, or has failed often enough that we stopped dialling it for a cooldown. This 502 is sent only after the charge is voided, or before any was taken.
Charged: No. What to do: Retry. A failure after the response began is not a 502: the status stays 200, the payload_truncated trailer is sent, and the charge stands.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`503 Lock_Unavailable`**

**Prompt for Lock_Unavailable**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 503 Lock_Unavailable.
Nexus402 says: Our own infrastructure could not authorize the call, so we failed closed rather than guess. A metering system that cannot read its own state must refuse, not assume.
Charged: No. What to do: Retry with backoff. A 503 is never a silent debit.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`422 Idempotency_Conflict`**

**Prompt for Idempotency_Conflict**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 422 Idempotency_Conflict.
Nexus402 says: This Idempotency-Key is already bound to a call. A retry of the same request is refused unless that call was refunded, and a different request under the key is always refused. Nothing is replayed, because payloads are never stored.
Charged: No. What to do: Check your call log for the first attempt. Use a fresh key for a new request; a key whose call was refunded may be retried.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`400 Authorization_Rejected`**

**Prompt for Authorization_Rejected**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 400 Authorization_Rejected.
Nexus402 says: Your pass-through Authorization header carried an nx_dev_ token, which would have handed your Nexus key to a creator who could then spend your wallet.
Charged: No. What to do: Put the tool's own credential there, never your Nexus key.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`404 Unknown_Version`**

**Prompt for Unknown_Version**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 404 Unknown_Version.
Nexus402 says: The tool exists but the version you pinned does not, or it has been retired. A published version is immutable, so a new price or endpoint ships as a new version instead of changing the one you pinned.
Charged: No. What to do: Drop the @v pin to resolve the highest published version, or pin one that GET /v1/tools still lists.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`404 Unknown_Tool`**

**Prompt for Unknown_Tool**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 404 Unknown_Tool.
Nexus402 says: Nothing is published under that name. A tool name is creator-handle/mcp-name/tool-name, with an optional @v pin on the middle segment, and it resolves against the published catalogue rather than against anything you called before.
Charged: No. What to do: Check the name against GET /v1/tools. An unpublished tool is not listed there, and neither is a retired version.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`405 Method_Not_Allowed`**

**Prompt for Method_Not_Allowed**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 405 Method_Not_Allowed.
Nexus402 says: The method is not implemented on that route — in practice a GET on /v1/mcp. The gateway opens no server-initiated stream, because it has nothing to push that is not the answer to a paid POST.
Charged: No. What to do: Read the Allow header and use the method it names.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```

**`429 key_rate_limited`**

**Prompt for key_rate_limited**

```text
A tool call through the Nexus402 MCP gateway (https://api.nexus402.dev/v1/mcp) failed with HTTP 429 key_rate_limited.
Nexus402 says: Too many requests for this key inside its window, counted after your key is verified and before anything is deducted. This is the rate limit you will actually meet.
Charged: No. What to do: Honour Retry-After, which is the seconds left in the window. Spread load across keys only if that reflects real separate workloads.
Find where my code or client config makes this call, explain which of those causes applies here, and fix it.
Do not print or log my NEXUS402_API_KEY key. Reference: https://www.nexus402.dev/docs/developers/errors/
```
