# Retry requests safely with idempotency keys

Attach an Idempotency-Key header to supported POST endpoints so network retries never create duplicate records.

Include an `Idempotency-Key` header on supported `POST` requests. If a network error forces a retry, sending the same key returns the original response instead of running the operation twice.

```bash
curl https://trydimmi.com/api/v1/contacts \
  -H "Authorization: Bearer <api_token>" \
  -H "Idempotency-Key: <key>" \
  -H "Content-Type: application/json" \
  -d '{"email": "ada@example.com", "name": "Ada Lovelace"}'
```

Use a unique value per operation (such as a UUID, up to 255 characters) and replace `<api_token>` with your [API token](/developers/api/authentication/).

## Supported endpoints

Other endpoints ignore `Idempotency-Key`.

| Method and path |
| --- |
| `POST /contacts` |
| `POST /conversations` |
| `POST /conversations/{conversation}/messages` |
| `POST /conversations/{conversation}/replies` |
| `POST /conversations/{conversation}/notes` |
| `POST /widget-settings` |
| `POST /ai/actions` |
| `POST /ai/action-connections` |
| `POST /ai/keys` |

## How keys behave

- **24-hour storage:** keys and their responses are stored for 24 hours per token owner and workspace.
- **Replayed responses:** return the original status code and body along with `Idempotent-Replayed: true`.
- **Server errors (`5xx`):** never cached, so retrying executes the request again.
- **Key reuse with a different payload:** returns `422` (`idempotency_key_reused`) if path, query, or body differs.
- **Concurrent retries:** returns `409` (`idempotency_key_in_use`) if the first call is still running. After 5 minutes with no response, a retry can take over.
- **Key length:** keys longer than 255 characters return `422` (`invalid_idempotency_key`).

The [Go](/developers/sdks/go/), [PHP](/developers/sdks/php/), and [Python](/developers/sdks/python/) SDKs attach idempotency keys automatically on `POST` calls. In the [TypeScript SDK](/developers/sdks/typescript/), pass `autoIdempotency: true`.

---

Index of all dimmi docs: https://trydimmi.com/llms.txt (full text: https://trydimmi.com/llms-full.txt)
