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

# Idempotency

> Retry a send safely. The same Idempotency-Key returns the same id for 24 hours instead of sending twice.

Networks fail and queues redeliver. Without protection, a retry after a timeout can send the same receipt twice. Send an `Idempotency-Key` header with any POST and Sendbaze remembers the result.

```bash theme={"dark"}
curl https://api.sendbaze.com/v1/emails \
  -H "Authorization: Bearer $SENDBAZE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-1042-shipped" \
  -d '{ "from": "orders@yourshop.co.za", "to": "thandi@example.com", "subject": "Shipped", "text": "Tracking: CG123456789ZA" }'
```

```ts Node.js theme={"dark"}
await sendbaze.emails.send(email, { idempotencyKey: "order-1042-shipped" });
```

```python Python theme={"dark"}
requests.post(url, headers={**headers, "Idempotency-Key": "order-1042-shipped"}, json=email)
```

## How it behaves

* **Same key, same body within 24 hours**: the original response is returned with the header `Idempotent-Replayed: true`. Nothing is sent again.
* **Same key, different body or channel**: `409 idempotency_conflict`. A key identifies one logical send; do not reuse it for a new message.
* **Request failed before the message was queued** (validation, suppression, allowance): the key is released, so a corrected retry goes through.
* **After 24 hours** the key is released.
* Keys are up to 255 characters and scoped to your organisation. Something you already have is the best key: an order id plus the event, a job id, a UUID you store with the record.

## Where it matters

* Job queues that retry on failure (Sidekiq, Celery, BullMQ, SQS consumers).
* Serverless functions that may run more than once for one trigger.
* Any client that retries on timeout, which should be every client.

> [!NOTE]
>
> Batch endpoints apply the key to the whole batch, not to each item.


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