> 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
