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

# Idempotency

> Retry Notra API writes safely with the Idempotency-Key header: how keys are scoped, what gets replayed, and the 409 and 422 errors for misused keys.

A network error during a write leaves you unsure whether it ran. Send an `Idempotency-Key` header on any authenticated `POST`, `PUT`, `PATCH` or `DELETE` request and you can retry it without running it twice. This matters most for writes that start paid work, such as `POST /v1/posts/generate` or a GEO scan.

```bash theme={"system"}
curl -X POST https://api.usenotra.com/v1/posts/generate \
  -H "Authorization: Bearer $NOTRA_API_KEY" \
  -H "Idempotency-Key: 3f0c8a52-6a1e-4c55-9d0b-6a2f7e1c9b44" \
  -H "Content-Type: application/json" \
  -d '{"contentType": "changelog"}'
```

Generate one key per operation, for example a UUID, and reuse it only for retries of that operation.

## How it works

The first request with a key runs normally. When it succeeds with a `2xx` status, Notra stores the response for 24 hours. A retry with the same key and the same request gets that stored response back without running the write again, and carries `Idempotent-Replayed: true`.

* **Scope.** Keys belong to the API key (or OAuth user) and workspace that sent them, so two keys never share a stored response.
* **Same request.** A retry must use the same method, path, query string and body. Anything else is a different request and gets `422`.
* **Failures are not stored.** A `4xx` or `5xx` response is not kept, so you can fix the problem and retry with the same key.
* **Format.** 1 to 255 visible ASCII characters, without spaces. Anything else returns `400` with `code: "INVALID_IDEMPOTENCY_KEY"`.
* **Reads ignore it.** `GET` requests and the unauthenticated feedback URL ignore the header.

Streamed responses, such as agent chat sessions, and responses larger than 512 KiB are not stored, so retries of those run again.

## Errors

| Status | `code` | Meaning |
| - | - | - |
| `400` | `INVALID_IDEMPOTENCY_KEY` | The header value is empty, too long or contains characters outside visible ASCII. |
| `409` | `IDEMPOTENCY_KEY_IN_PROGRESS` | The first request with this key is still running. Wait for `Retry-After` seconds and retry with the same key. |
| `422` | `IDEMPOTENCY_KEY_REUSED` | The key was already used for a different request. Use a new key for a new request. |

```json theme={"system"}
{
  "error": "This Idempotency-Key was already used for a different request",
  "code": "IDEMPOTENCY_KEY_REUSED",
  "recovery": "Send a new Idempotency-Key for a new request. A key only replays the request it was first used with."
}
```

> [!NOTE]
>
> `POST /v1/feedback` also accepts an `idempotencyKey` body field with its own deduplication rules. See [Agent feedback](https://www.usenotra.com/docs/feedback/send-feedback.md).

## Next steps

> [card] [Rate limits](https://www.usenotra.com/docs/api/rate-limits.md)
>
> Limits and the headers that report them

> [card] [Versioning](https://www.usenotra.com/docs/api/versioning.md)
>
> Deprecation policy and breaking changes


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