> For the complete documentation index, see [llms.txt](https://docs.tokenbot.com/home/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tokenbot.com/home/api-docs/errors.md).

# Errors

The REST API returns errors as a **flat** JSON object.

## Error Format

```json
{
  "statusCode": 401,
  "code": "UNAUTHENTICATED",
  "message": "Human-readable description",
  "details": {}
}
```

`details` is optional and present only for some errors (e.g. validation, rate limiting).

## HTTP Status Codes

| Status | Code                   | Description                                  |
| ------ | ---------------------- | -------------------------------------------- |
| 400    | `VALIDATION_ERROR`     | Malformed request or invalid parameters      |
| 401    | `UNAUTHENTICATED`      | Invalid or missing authentication            |
| 401    | `CLI_SIG_INVALID`      | Signed-request signature failed verification |
| 401    | `CLI_IDENTITY_UNKNOWN` | The public key is not registered             |
| 403    | `FORBIDDEN`            | Insufficient permissions                     |
| 404    | `NOT_FOUND`            | Resource not found                           |
| 409    | `CONFLICT`             | Resource already exists or state conflict    |
| 429    | `RATE_LIMITED`         | Too many requests                            |
| 500    | `INTERNAL_ERROR`       | Unexpected server error                      |
| 503    | `SERVICE_UNAVAILABLE`  | An upstream dependency is unavailable        |

## Validation Errors

Validation errors include field-level details:

```json
{
  "statusCode": 400,
  "code": "VALIDATION_ERROR",
  "message": "Validation failed",
  "details": [
    { "field": "name", "message": "Required" },
    { "field": "exchange_account_id", "message": "Invalid id format" }
  ]
}
```

## Rate-Limit Errors

```json
{
  "statusCode": 429,
  "code": "RATE_LIMITED",
  "message": "Rate limit exceeded. Please slow down.",
  "details": { "limit": 100, "remaining": 0, "resetMs": 42000 }
}
```

## GraphQL Errors

GraphQL responses use the standard `errors` array:

```json
{
  "data": null,
  "errors": [
    {
      "message": "Not authorized",
      "path": ["me"],
      "errorType": "Unauthorized"
    }
  ]
}
```

Many GraphQL operations also return a `success`/`error` envelope inside `data`:

```json
{
  "data": {
    "create_strategy": {
      "success": false,
      "error": "Exchange account not found",
      "data": null
    }
  }
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.tokenbot.com/home/api-docs/errors.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
