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

# Idempotency and safe retries

> Retry without sending or paying twice.

A request can succeed on our side while its response is lost on the way back. Retrying is then the right thing to do, as long as the retry cannot repeat the effect.

## Which requests are safe to retry

| Request | Safe to retry? |
| - | - |
| Any `GET`, and the two analytics `POST`s | Yes. They change nothing. |
| `PUT /conversations/{id}/labels` | Yes. It replaces the labels with the list you send. |
| `POST /campaigns/{id}/leads` | Yes. People already in the campaign are skipped and counted in `skipped_existing_count`. |
| `PUT /campaigns/{id}/sequence` | Yes. It replaces the steps with the list you send. |
| `POST /campaigns` | Only with an `Idempotency-Key`. The header is optional; without it a retry creates a second draft. With it, a changed request returns `422 idempotency_key_reused`. |
| `POST /campaigns/{id}/launch` | Only with an `Idempotency-Key`. The header is required. |
| `POST /campaigns/{id}/pause` and `/resume` | Yes, but check first. A repeat returns `409 conflict`, and so does a campaign in any other state, so read the campaign's `status` before treating the change as done. If someone else may have changed the campaign since, confirm the change is still wanted before repeating it. |
| `POST /conversations/{id}/messages` | Only with an `Idempotency-Key`. The header is required. |
| `POST /email/placement-tests` | Only with an `Idempotency-Key`. The header is required. |

## The Idempotency-Key header

```bash theme={null}
curl -X POST https://api.getcluster.ai/v1/conversations/$CONVERSATION_ID/messages \
  -H "Authorization: Bearer $CLUSTER_API_KEY" \
  -H "Idempotency-Key: 7f3c9a52-reply-to-ada" \
  -H "Content-Type: application/json" \
  -d '{"thread_id": "…", "text": "Thanks, Tuesday works."}'
```

* Choose any unique string of 8 to 200 characters, such as a UUID. Keys are scoped to your workspace.
* Sending the same key again returns the original result. Nothing is sent or charged a second time.
* The same key with a different request returns `422 idempotency_key_reused`. For a reply, that means a different conversation, thread or text. For a placement test or a new campaign, any change to the request. Do not rely on other differences being caught: use a new key for every new request.
* A launch is the exception to "the original result": the same key returns the campaign as it is now, which may have changed since, and never launches it again. The first request's `send_window_mode` stands.
* If a launch answers `409 conflict`, read the campaign's `status`. `running` tells you the campaign is running, not that your key launched it: someone else may have.
* If a retry arrives while the first request is still being processed, wait a moment and retry with the same key. A placement test answers `409 conflict` until then; a reply answers with the stored message, its `delivery_status` still `pending`.

## Sending replies

A reply's `delivery_status` is `sent`, `failed`, `pending` or `unknown`. `unknown` means we could not confirm the send. The **same** key keeps returning that stored message and never sends again, so a retry does not resolve it. The conversation is read from stored history, which can lag behind the mailbox, so a reply missing there is not proof that it was not sent. Check the mailbox itself, or wait and read again, before sending it again with a new key.

A message that ends as `failed` was not sent, and its key keeps returning that failed message. To try again, send it with a new key.


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