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

# Idempotency

> Retry safely with Idempotency-Key.

Send an `Idempotency-Key` header (8–200 printable ASCII characters) to make a retry return the first result instead of running again.

```bash theme={null}
curl https://api.antarah.dev/v1/organization/projects \
  -H "Authorization: Bearer $ANTARA_ADMIN_KEY" \
  -H "Idempotency-Key: create-project-checkout-1" \
  -H "Content-Type: application/json" \
  -d '{"name": "Checkout"}'
```

| Rule | Detail |
| - | - |
| Required on | Creating policies, projects, project API keys, and Admin API keys. Without the header these answer `422 validation_error` with `param: "Idempotency-Key"` |
| Optional on | Every other `POST`, `PATCH`, and `DELETE`, inference included. `POST /v1/messages/count_tokens` ignores it |
| Scope | Your organization. Another organization can use the same key |
| Same key, same request | Within 24 hours: the stored status and body, with `Idempotent-Replayed: true` |
| Same key, different request | `409 idempotency_conflict`. A request is the same when its method, path, caller, and JSON body (key order ignored) match |
| Same key, still running | `409 idempotency_in_progress` with `Retry-After: 1`. The SDKs retry it |
| Older than 24 hours | `409 idempotency_expired` for 7 days, then the key can be reused |
| What's stored | `2xx` and `4xx` results. `5xx` and `429` aren't stored, so a retry runs again |

## Inference

On non-streaming inference, a replay returns the stored response without calling the model or charging again. Stored responses are encrypted and deleted after 24 hours; this is the only time Antara keeps response content.

Streams can't be replayed. A key reused after a streamed request finished gets `409 idempotency_replay_unavailable`; use a new key for a new request.


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