> For the complete documentation index, see [llms.txt](https://docs.luciq.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.luciq.ai/references/api-access/error-codes.md).

# Error Codes

Error codes returned by the Luciq Query API, what each one means, and whether to fix the request or back off and retry it later.

#### Error Codes <a href="#error-codes" id="error-codes"></a>

Every error has the same structure:

```json
{ "error": { "code": "invalid_request", "message": "…", "query_id": "…", "details": { } } }
```

Error codes are never renamed or reused, so you can safely branch on them in code.

| Code               | HTTP | Retry?           | What to Do                                                                                                                                     |
| ------------------ | ---- | ---------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| `invalid_request`  | 400  | No               | Fix the query. `message` and `details` explain what is wrong, often with a `did_you_mean`.                                                     |
| `unauthorized`     | 401  | No               | The key is missing, unknown, revoked, or expired. `details.reason` tells you which.                                                            |
| `forbidden`        | 403  | No               | The key does not cover this app, entity, or level, or your plan does not include the feature.                                                  |
| `not_found`        | 404  | No               | The entity does not exist. Check `/v1/entities`.                                                                                               |
| `budget_exceeded`  | 422  | Change the query | The query is valid but too expensive to run. Narrow the time range, group by fewer columns, or add filters. `details.cap` names the limit hit. |
| `rate_limited`     | 429  | Back off         | Wait for `Retry-After`.                                                                                                                        |
| `internal`         | 500  | Back off         | Temporary. If it continues, contact support with the `query_id`. It is in `error.query_id` and the `X-Query-Id` header.                        |
| `upstream_failure` | 502  | Back off         | Temporary. Retry with exponential backoff.                                                                                                     |
| `timeout`          | 504  | Once             | Retry once. If it repeats, narrow the query.                                                                                                   |

On a `429`, `details.reason` tells you which limit you hit: `rate_limit` or `concurrency`. By default, you can send 60 requests per minute and 1,000 per hour. An app runs up to 8 queries at once.

#### Error reasons <a href="#error-reasons" id="error-reasons"></a>

Some errors carry `details.reason`, which tells you the exact cause.

| Status | `code`         | `details.reason`  | Meaning and action                                              |
| ------ | -------------- | ----------------- | --------------------------------------------------------------- |
| 401    | `unauthorized` | `unknown`         | The key doesn't exist. Check for typos.                         |
| 401    | `unauthorized` | `revoked`         | The key was revoked. Create a new one.                          |
| 401    | `unauthorized` | `key_expired`     | The key has expired. Create a new one.                          |
| 403    | `forbidden`    | `app_not_allowed` | The key's scope doesn't include this app, or the slug is wrong. |
| 403    | `forbidden`    | `plan_disabled`   | The Query API is turned off for this app or company.            |
| 429    | `rate_limited` | `rate_limit`      | Per-minute or per-hour limit. Wait `Retry-After`.               |
| 429    | `rate_limited` | `concurrency`     | Too many queries at once. Wait `Retry-After`.                   |


---

# 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.luciq.ai/references/api-access/error-codes.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.
