# HTTP headers: what the API reads and what it sends back

> Six headers do all the work: one to authenticate, two you can send to make calls traceable and safe to retry, and the rest come back telling you where you stand against your limits.

Source: https://astronode.dev/reference/http-headers · Updated: 2026-12-04

Everything below is behaviour recorded from the API itself; each row links the page with the full detail.

## Request headers

| Header | When | Detail |
| --- | --- | --- |
| `Authorization` | Every call | `Bearer <key>`. Checked before the body: no key or a bad key gets `401` even when the body is also invalid. |
| `Content-Type` | POST | `application/json`. Bodies are validated strictly; unknown fields are a `400`. |
| `Idempotency-Key` | Optional, POST | Up to 255 characters. The response is stored for 24 hours per API key; a retry with the same key and body replays it, a different body gets `409 IDEMPOTENCY_KEY_REUSED`. |
| `x-request-id` | Optional | `req_` plus at least 20 letters or digits: the API adopts it instead of minting its own, so one id traces a call across your services. Anything else is ignored. |

## Response headers

| Header | When | Detail |
| --- | --- | --- |
| `x-request-id` | Every response | Also `request_id` in the body. On a replayed response the header is new while the body keeps the first call's id. |
| `x-ratelimit-limit` | Successful responses and limiter 429s | Calls allowed per minute for the key. |
| `x-ratelimit-remaining` | Successful responses and limiter 429s | Calls left in the current one-minute window. Throttle on it before it reaches zero. |
| `x-ratelimit-reset` | Successful responses and limiter 429s | Unix seconds at which the window next frees a slot: the oldest call in it plus 60 seconds. |
| `Retry-After` | 429 | Seconds. For `RATE_LIMITED`, the wait for a slot; for `QUOTA_EXCEEDED`, the time until the next UTC month - do not sleep on it. |
| `idempotent-replayed` | Replays | `true` when the response is a stored answer to an earlier call with the same `Idempotency-Key`. |

## Things to watch

- A request rejected by schema validation (`400`) is answered before the rate limiter, so it carries no `x-ratelimit-*` headers and does not count toward any limit.
- A replayed response is a `2xx`, so it passes the rate limiter and is billed like any successful call. Refused and failed calls are not billed.
- The chat API takes the same `Authorization` header and keys.

## Example: POST /v1/charts/birth

Recorded replay of `POST /v1/charts/birth` with `Idempotency-Key: order-8812-chart` (other headers omitted).

```http
HTTP/1.1 200 OK
x-request-id: req_01M8RK47T0DX2ECGJRXDKMN3QF
idempotent-replayed: true
x-ratelimit-remaining: 5993
```

## Questions

**Which endpoints does this page apply to?**

Every endpoint: this page describes behaviour common to the whole API.
