> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Conventions

> What every route has in common: errors, lists and cursors, rate-limit headers, safe retries and request ids.

These rules hold on every route an API key can call.

## Errors

Every error is the same JSON object with an appropriate HTTP status code. `error.code` is stable and meant for your code; `error.message` is for people; `error.param` names the parameter when the error is about one, else it is `null`.

```json theme={null}
{
  "error": {
    "type": "invalid_request_error",
    "code": "parameter_invalid",
    "message": "limit must be an integer between 1 and 200",
    "param": "limit",
    "doc_url": "https://insightchain.ai/docs/errors#parameter_invalid"
  },
  "request_id": "9f3c2b1e-..."
}
```

`type` follows from the status: `invalid_request_error` (400, 404, 405, 409, 413, 415, 422), `authentication_error` (401), `permission_error` (403), `rate_limit_error` (429) and `api_error` (5xx). A 500 says only to quote `request_id`.

`error` used to be a plain string; that text is now `error.message`. The older top-level `code`, `field` and `details` are still sent where a route sent them, and are deprecated.

Every code, with its status and what it means, is in the [error reference](/docs/errors.md).

## Lists and cursors

Every route that returns a collection answers the list object:

```json theme={null}
{ "object": "list", "data": [], "has_more": true, "next_cursor": "eyJ..." }
```

* Lists take `limit`; the default and maximum are per route (often 1 to 200, default 50) and are in the API reference.
* Send `next_cursor` back as `cursor` with the same filters until `has_more` is false. `has_more` is exact, and `next_cursor` is `null` on the last page. Nothing is cut off silently.
* An unknown query parameter is a `400` (`parameter_unknown`). A value outside what the route takes (a `limit` above its maximum, for example) is a `400` whose `error.param` names the parameter; it is never replaced by a default.
* A cursor from another route or other filters is a `400` (`cursor_invalid`), never page one of something else.
* The field each route used before (`alerts`, `recommendations`, `items` and so on) and the `offset` and `page` parameters still work and are deprecated: read `data` and page with `cursor`.

## Rate-limit headers

Every authenticated answer carries:

| Header | Meaning |
| - | - |
| `RateLimit-Limit`, `RateLimit-Remaining`, `RateLimit-Reset` | The per-minute window: its size, what is left, and the seconds until it resets |
| `X-RateLimit-Limit-Day`, `X-RateLimit-Remaining-Day` | The key's daily limit, which resets at 00:00 UTC |
| `X-Model-Budget-Limit`, `X-Model-Budget-Remaining` | On routes that use AI: the organization's daily budget for them |
| `Retry-After` | On every 429: the real wait, in seconds |

A key has 120 requests per minute and its daily limit; see [Authentication](/docs/authentication.md#rate-limits). Past the daily AI budget, a route that has an answer without AI gives that answer; a route whose answer is the AI's answers `429` `model_budget_exceeded`, with `Retry-After` at 00:00 UTC.

## Idempotency-Key

Send an `Idempotency-Key` header (1 to 128 visible ASCII characters, a UUID for example) on any `POST` that creates or changes something. Keys are scoped to your organization and kept for 24 hours, and a key belongs to the route and the exact bytes of the body it was first sent with: re-send the same bytes, not a re-serialized copy.

| A repeat of the key | Answer |
| - | - |
| Same route and body, first request finished | The first answer again, with `Idempotency-Replayed: true`. Nothing runs twice |
| Another route or body | `422` `idempotency_key_reused`. Use a new key for a new body |
| First request still running | `409` `idempotency_key_in_use`. Retry after the `Retry-After` header's seconds |
| First request failed | It runs again under the same key |

Routes whose answer must not be kept, such as the ones that show a secret once, are not replayed.

`POST /v1/ingest/records` follows the same rules with its own details: a finished push is replayed with `replayed: true` and its `original_request_id`, and a push still marked in progress more than 10 minutes after it started is processed again. See [Data ingestion](/docs/ingestion.md#retries-idempotency-key).

## Request ids

Every answer carries our id for the request in the `X-Request-ID` header and in `request_id` of the body. Quote it when you ask about a request.

Send your own id as the `X-Request-ID` request header (1 to 128 visible characters) and it is kept beside ours, echoed back as `X-Client-Request-ID`, and searchable in the [request log](/docs/authentication.md#request-log-and-usage).

Every answer to a test key also carries `X-InsightChain-Sandbox: true`.

## Methods and bodies

`GET` never changes anything. A known path asked with a method it does not take is a `405`, and the `Allow` header lists the ones it takes. A body larger than the route's limit is a `413`, and a `Content-Type` the route does not read is a `415`.

Timestamps are RFC 3339 in UTC; dates are `YYYY-MM-DD`. Input and output are snake\_case.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.