> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentonboard.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors & Status Codes

> All 11 failure codes, what triggers each one, and the HTTP status code to return.

Every failed call to `verifyAgentToken`, `verifyAgentAccount`, or `createAgentAccount` returns `{ ok: false, code, error }`.

* **`code`** is a frozen string union for branching in your code and guiding agents.
* **`error`** is a human-readable description. You can also import descriptions at runtime via `VERIFY_ERROR_DESCRIPTIONS`:

```ts theme={null}
import { VERIFY_ERROR_DESCRIPTIONS } from "@agentonboard/sdk";

console.warn(VERIFY_ERROR_DESCRIPTIONS.EXPIRED);
```

***

## HTTP status code mapping

All `@agentonboard/sdk` and `agentonboard-sdk` framework bindings apply this status mapping automatically. Use the same mapping when calling core functions directly:

| Error Codes | HTTP Status | Why |
| - | - | - |
| `EXPIRED`, `INVALID_SIGNATURE`, `AUDIENCE_MISMATCH`, `ISSUER_MISMATCH`, `MALFORMED_TOKEN`, `UNKNOWN_KEY`, `KEY_SOURCE_UNAVAILABLE`, `MISSING_EMAIL` | **401 Unauthorized** | All token and key failures return `401` uniformly so callers cannot distinguish malformed tokens from signature or key failures. |
| `ACCOUNT_REQUIRED` | **403 Forbidden** | The token signature and claims are valid, and the User has no App Account in your database. Returning `403` prevents agents from re-minting tokens in a loop and triggers your `auth.md` instructions. |
| `CONFIG_ERROR`, `RESOLVER_ERROR` | **500 Internal Server Error** | Your server configuration or database callback failed. The token is valid, so the agent should retry after a short delay. |

By default, framework bindings return `{ "code": "...", "error": "..." }` in the JSON body so agents can read `code` and follow your `auth.md`. Pass an `onFailure` callback to customize responses (see [Framework Overview](https://docs.agentonboard.xyz/frameworks.md#custom-failure-responses-onfailure)).

***

## Token verification codes (`VerifyErrorCode`)

These 9 codes can be returned by `verifyAgentToken` and every function built on top of it:

| Code | HTTP Status | Cause | Recommended Action |
| - | - | - | - |
| `EXPIRED` | `401` | The token's `exp` claim is in the past beyond `clockToleranceSeconds` (default 5s). Tokens live 5 minutes. | Return `401`. The agent calls `get_token` for your Domain and retries once. |
| `INVALID_SIGNATURE` | `401` | Signature verification failed against the public key, or the JWT header specified an unsupported algorithm (`alg: none` or `HS256`). | Return `401`. |
| `AUDIENCE_MISMATCH` | `401` | The token's `aud` claim does not match your normalized `audience` option, or `aud` is missing. | Return `401`. Check that `## Audience` in `auth.md` matches the `audience` string in your code. |
| `ISSUER_MISMATCH` | `401` | The token's `iss` claim does not match the configured `issuer` (default `https://agentonboard.xyz`). | Return `401`. Set `AON_ISSUER` or pass `issuer` when testing against a non-production issuer. |
| `MALFORMED_TOKEN` | `401` | The token is empty, not a valid 3-part JWS, or missing a required claim (`exp`, `jti`, `sub`, `email`). | Return `401`. |
| `UNKNOWN_KEY` | `401` | The JWT header has no `kid`, or its `kid` does not match any key in the JWKS after refetching. | Return `401`. See [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md) for key rotation behavior. |
| `KEY_SOURCE_UNAVAILABLE` | `401` | The JWKS endpoint could not be fetched on a cold cache, returned invalid JSON/keys (\< 2048-bit RSA), or contained duplicate `kid` entries. | Return `401` and alert your team. Warm processes fall back to their last valid cached key set. |
| `MISSING_EMAIL` | `401` | The signature verified, and the `email` claim is missing or empty. | Return `401`. |
| `CONFIG_ERROR` | `500` | Invalid SDK options passed by your server (empty `audience`, invalid `jwksUrl`, or negative `clockToleranceSeconds`). | Fix the options passed to the SDK in your server code. |

***

## Account resolution codes (`AccountErrorCode`)

`verifyAgentAccount` and `createAgentAccount` return `VerifyErrorCode` plus two account-layer codes:

| Code | HTTP Status | Cause | Recommended Action |
| - | - | - | - |
| `ACCOUNT_REQUIRED` | `403` | The token verified, and `resolveAccount` returned `null` or `undefined`. (Never returned by `createAgentAccount`.) | Return `403`. Point agents in `auth.md` to your connect URL or `POST /api/signup`. |
| `RESOLVER_ERROR` | `500` | Your `resolveAccount` or `createAccount` callback threw an exception. The raw exception is hidden to avoid leaking database details. | Log the exception inside your callback and return `500`. |

***

## Safe logging rules

Log `result.code` and (on success) `result.jti`. Never log raw JWT strings or `Authorization` headers:

```ts theme={null}
// Safe
console.warn(`Agent auth failed: ${result.code}`);

// Unsafe - leaks a live bearer token into logs
console.warn(`Auth failed for ${token}: ${result.error}`);
```

***

> [card] [Publishing auth.md](https://docs.agentonboard.xyz/auth-md.md)
>
> Map 401, 403, and 500 responses to agent instructions in auth.md.

> [card] [Testing & Production](https://docs.agentonboard.xyz/testing-and-production.md)
>
> JWKS caching, stale fallback, and the six curl verification checks.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.