# Errors

> Every error the API can return, with its HTTP status and what to do about it.

Source: https://docs.b55.online/errors

Every error has the same JSON shape. Branch on `code`; `message` is for people and may change.

```json
{
  "name": "role_not_supported",
  "message": "Role \"recruiter\" is not supported. Call GET /v0/roles for the list.",
  "code": "role_not_supported",
  "docs": "https://docs.b55.ai/errors#role_not_supported"
}
```

`docs` links to the entry on this page. This list is complete: a test fails if the code can return an error that is not here or not in `openapi.json`. Codes marked *live* come from the hosted server (real candidates, `b55_live_` keys); the local sandbox never sends them.

| Status | Codes |
|---|---|
| 400 | `invalid_json` |
| 401 | `unauthorized`, `live_keys_unavailable`, `token_malformed`, `token_bad_signature`, `token_expired`, `token_wrong_candidate`, `token_unknown`, `token_revoked`, `token_identity_mismatch` |
| 404 | `not_found`, `job_not_found`, `candidate_not_found`, `report_not_found` |
| 409 | `job_closed`, `candidate_finished`, `consent_required`, `scan_replayed`, `token_used` |
| 413 | `payload_too_large` |
| 422 | `invalid_query`, `invalid_description`, `invalid_title`, `invalid_company`, `invalid_client_id`, `invalid_email`, `invalid_role`, `role_not_supported`, `invalid_seniority`, `invalid_ai_usage`, `invalid_github`, `consent_missing`, `invalid_scan`, `scan_integrity_failed`, `nonce_mismatch`, `demo_scan`, `sandbox_fictional_only`, `sandbox_demo_only`, `embed_live_only` |
| 429 | `rate_limited` |
| 500 | `internal_error` |

## 400

### `invalid_json`

The request body is missing, is not valid JSON, or is not a JSON object. Sent by every `POST` that takes a body. Send `content-type: application/json` and an object body.

## 401

### `unauthorized`

No `Authorization` header, a value that is not a B55 key, or a live key the server does not know (wrong, or revoked in the console; a revoked key stops working on the next request). Sandbox keys are `Authorization: Bearer b55_test_…` (letters, digits and `_` after the prefix); live keys are `b55_live_…`, created in the console and shown once. The local sandbox accepts only `b55_test_` keys. Copy a key from the console's [API keys](http://localhost:3100/api-keys) page. Two candidate-facing routes take no key: `POST /v0/jobs/{job_id}/apply` and `POST /v0/candidates/{candidate_id}/scan`.

### `live_keys_unavailable`

*Live.* A `b55_live_` key was sent to a server that runs the sandbox only (for example the console running locally without a database, or the docs playground). Use a `b55_test_` key there, or send the live key to the hosted API.

The token codes below come from a live scan upload (`POST /v0/candidates/{candidate_id}/scan` with `Authorization: Bearer b55ct_…`). The token is the command shown on the apply page: single use, valid for two hours, and bound to the GitHub account the candidate signed in with. The fix is always the same: open the apply page again and copy the current command. Nothing changed on the server.

### `token_malformed`

*Live.* The value after `Bearer` is not a B55 candidate token (`b55ct_…`), for example because the command was cut off when it was copied.

### `token_bad_signature`

*Live.* The token was not issued by this server, or a character in it was changed.

### `token_expired`

*Live.* The token is older than two hours.

### `token_wrong_candidate`

*Live.* The token belongs to another application than the `candidate_id` in the URL.

### `token_unknown`

*Live.* The server has no record of this token (for example it was issued before the application was deleted).

### `token_revoked`

*Live.* A newer command replaced this one. Only the latest command on the apply page works.

### `token_identity_mismatch`

*Live.* The token is bound to a different GitHub sign-in than the one now on the application.

## 404

### `not_found`

`not_found` (404) is returned for an unknown path under `/v0/`, or the wrong method on a known path (for example `GET …/candidates/{candidate_id}/advance`).

In the sandbox, methods other than GET, POST and DELETE get a bare 405 from the console before reaching the API, and the key is checked before routing: an unknown `/v0/` path with no key returns 401, not 404.

### `job_not_found`

The `job_id` does not exist. Sandbox data is in memory, so jobs disappear when the console restarts.

### `candidate_not_found`

The `candidate_id` does not exist. For the scan upload: check the command's `--sandbox-url` points at the sandbox that has this candidate.

### `report_not_found`

The `report_id` does not exist. Reports exist only once the candidate is `ready` or `insufficient_evidence`; read `report_id` from the candidate.

## 409

### `job_closed`

The job is closed, so it takes no new candidates, by email or through the apply link. Existing candidates are unchanged and adding someone already on the job still returns them.

### `candidate_finished`

`POST …/advance` or a scan upload for a candidate that already has a report (`ready` or `insufficient_evidence`). Nothing changed.

### `consent_required`

A scan upload (`POST /v0/candidates/{candidate_id}/scan`) for a candidate who is still `invited` or `opened`. The candidate must open the apply link and consent first; the CLI cannot skip that. Nothing changed.

### `scan_replayed`

This exact scan (same `integrityHash`) was already accepted, for this or another candidate. One scan answers one candidate. Run the command again: each run is a new scan.

### `token_used`

*Live.* The candidate token in the command was already used for an accepted scan. Each command uploads once; get a new one from the apply page. A scan that failed (for example `invalid_scan` or `scan_replayed`) does not use the token up.

## 413

### `payload_too_large`

*Live.* The request body is over the size limit (256 KB). A scan from the CLI is far smaller; check you are sending the payload the CLI produced.

## 422

### `invalid_query`

A query parameter has a value outside its list: `status` on `GET /v0/jobs` (`open`, `closed`), or `sort` (`ranked`, `newest`, `oldest`), `status` (a candidate status) or `verdict` (a report verdict) on `GET /v0/jobs/{job_id}/candidates`. Statuses are snake_case (`insufficient_evidence`); verdicts are kebab-case (`insufficient-evidence`).

### `invalid_description`

`POST /v0/roles/suggest` without a non-empty string `description`, or a job or suggestion `description` longer than 4000 characters (or not a string).

### `invalid_title`

`POST /v0/jobs` without a non-empty string `title`, or a title longer than 200 characters.

### `invalid_company`

`company` on `POST /v0/jobs` is not a string, or is longer than 200 characters.

### `invalid_client_id`

`client_id` is present but not a string (for example a number). Send your id as a string, or leave it out.

### `invalid_email`

`email` is missing or does not look like `name@domain.tld`.

### `invalid_role`

`role` is neither a role id string nor an object with a string `base`, or `must` / `nice` are not arrays of strings.

### `role_not_supported`

The role id (or `role.base`) is not in the catalog. Call `GET /v0/roles` or see [Roles](/roles). B55 never builds a report for a role it cannot assess.

### `invalid_seniority`

`role.seniority` is not one of `intern`, `junior`, `mid`, `senior`, `staff`.

### `invalid_ai_usage`

`role.ai_usage` is not one of `expected`, `neutral`, `discouraged`.

### `invalid_github`

Sandbox: `github` on `POST /v0/jobs/{job_id}/apply` is not one of the eight fictional developers (see [Candidates](/candidates#sandbox-candidates)). Production plan: the apply page signs the candidate in with GitHub instead.

### `consent_missing`

`POST /v0/jobs/{job_id}/apply` without `"consent": true`. The apply page shows what is shared and what never is; nothing is created until the candidate agrees.

### `invalid_scan`

The scan upload's body is not a valid signed `ScanPayload` (schema version 2), or it has a top-level field the payload does not have. The message names up to three problems. Update the CLI and run the command again.

### `scan_integrity_failed`

The payload's `integrityHash` does not match its contents: something changed it after the CLI signed it. Send the payload exactly as the CLI produced it.

### `nonce_mismatch`

*Live.* The scan was signed for a different command: its `evidence.nonce` is not the id of the token in the `Authorization` header. A signed scan answers exactly one command. Run the command from the apply page again.

### `demo_scan`

*Live.* A `--demo` scan (fictional history) was sent to a real job. Run the command without `--demo`.

### `sandbox_fictional_only`

The hosted public sandbox only takes made-up email addresses at reserved test domains (`example.com`, `example.org`, `example.net`, `*.test`, `*.example`, `*.invalid`), so no real person's data enters the shared sandbox. Applies to adding a candidate and to the `email` on `POST /v0/jobs/{job_id}/apply`. Use `ada@example.com`, or a live key for real candidates. The local sandbox takes any address.

### `sandbox_demo_only`

The hosted public sandbox only takes `--demo` scans (fictional history), so no real work profile enters it. Real scans go to a live job. The local sandbox takes any scan.

### `embed_live_only`

`POST /v0/reports/{report_id}/embed-token` with a sandbox key. Embed tokens are for live reports; sandbox reports embed without a token (see [Embed](/embed)).

## 429

### `rate_limited`

Too many requests. Wait the number of seconds in the `Retry-After` header, then retry; retrying with the same `client_id` is safe. Live keys are limited per key, sandbox keys on the hosted server per network, and scan uploads per candidate. The local sandbox has no limit.

## 500

### `internal_error`

Something went wrong on the server. The message is generic on purpose. Retrying with the same `client_id` is safe. In the sandbox, the console's terminal shows the cause.

## SDK-only codes

The [SDKs](/quickstart) raise the same `B55Error` (`status`, `code`, `message`, `docs`) for API errors, and these four codes when there is no B55 error body to read. `status` is `0` when no response arrived.

### `missing_api_key`

No `apiKey` / `api_key` was passed and `B55_API_KEY` is not set. Raised when the client is created.

### `connection_error`

The request never got a response: the server is down, the host is wrong, or DNS failed. Check `baseUrl`; for the sandbox it is `http://localhost:3100/api`.

### `timeout`

No response within the timeout (30 seconds by default; `timeout` in milliseconds in TypeScript, seconds in Python).

### `http_error`

A non-2xx response without a B55 error body, for example a proxy's error page, or a `405` from the console for a method the API does not route. `status` is the HTTP status.
