> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.campino.tech/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.campino.tech/_mcp/server.

# Errors

> Every status and code the Partner API returns, and what to do about each.

## Shape

Every failure has the same envelope. Match on `error.code`: the `message` is a fixed text for the
code, and it can change.

```json
{
  "status": "failure",
  "data": null,
  "error": { "code": 4000, "message": "Wallet balance does not cover this operation", "fields": null }
}
```

`error.fields` is `null`, except for request validation (`422`, code `4200`), which lists one entry per rejected field:

```json
{
  "status": "failure",
  "data": null,
  "error": {
    "code": 4200,
    "message": "Request validation failed",
    "fields": [
      { "location": ["body", "objective"], "type": "value_error", "message": "Partner search objective must not be empty" }
    ]
  }
}
```

**Always log `X-Request-ID`.** Every response returns it, and it is what lets us find your exact
request. Send your own as a UUID, or we create one.

## Codes

| Status | `code`         | Meaning                                                         | What to do                                                                        |
| ------ | -------------- | --------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| `400`  | `4000`         | The wallet balance does not cover the charge                    | Top up and send the request again. Nothing was charged                            |
| `401`  | `4012`         | Invalid partner credential                                      | Check the header. See [Authentication](/documentation/get-started/authentication) |
| `403`  | `4031`         | The wallet cannot be spent from                                 | Contact us                                                                        |
| `404`  | `4043`         | Unknown search, not yours, not finished, or its results expired | Check the `request_id`. Searches are kept for 7 days                              |
| `409`  | `4091`         | The `Idempotency-Key` was used for another objective            | Use a new key for a new search                                                    |
| `409`  | `4092`         | Another search of your account is still running                 | Wait for it to finish. Nothing was charged                                        |
| `422`  | `4200`         | The request is malformed                                        | Fix it. See `error.fields`                                                        |
| `429`  | `4290`         | A rate limit was reached                                        | Wait `Retry-After` seconds. See [Rate limits](/documentation/guides/rate-limits)  |
| `500`  | `5000`, `5001` | The request could not be recorded or closed on our side         | Repeat the request. A submission with the same key is safe                        |
| `502`  | `5021`         | The audience service or the stored result cannot be read        | Try again in a few seconds. Nothing is charged                                    |
| `502`  | `5022`         | Billing is unavailable                                          | Try again in a few seconds. A fee already taken is returned                       |
| `503`  | `5030`         | The rate limiter is unavailable                                 | Try again in a few seconds                                                        |
| `503`  | `5031`         | Buy results charged you and could not record the purchase       | Repeat the same request. You are not charged again                                |

`404` is also the answer for another account's search, so one account can never learn that a
`request_id` exists for another.

## A failed search is not an error response

When a search itself fails, the poll answers `200` with `status: "FAILED"` and an `error` object that
holds the code (`5021` or `5000`), a message and `refunded`. See
[How a search works](/documentation/guides/how-a-search-works#what-a-failed-search-shows).

## 422 in detail

A `422` can mean:

* `Idempotency-Key` is missing or is not a UUID.
* `objective` is blank, longer than 2,048 characters or 8,192 bytes, or holds a disallowed control
  character.
* `request_id` is missing or is not a UUID.
* The body holds a field the API does not know.