---
title: "Safe Retries with the iChatUp Idempotency-Key Header"
url: https://ichatup.com/docs/idempotency
description: "Make iChatUp API retries safe: send an Idempotency-Key header on any POST and a repeat request gets the first response back for 24 hours."
source: iChatUp
---

Developers

# Idempotency

Every POST to the iChatUp API accepts an Idempotency-Key header. If the same account sends the same key again within 24 hours, iChatUp returns the first response instead of running the request again, so a retry after a timeout cannot send the customer a second WhatsApp message or create a second record.

## At a glance

|  |  |
| --- | --- |
| Header | Idempotency-Key |
| Applies to | POST requests that carry the header |
| Remembered for | 24 hours, per account |
| Maximum length | 255 characters |
| Replay marker | Response header Idempotent-Replay: true |

## How it behaves

- The first request runs normally. If its response is final (any status below 500), iChatUp stores the status and body against your key.
- A later POST from the same account with the same key gets that stored response, with `Idempotent-Replay: true` , and nothing is sent or saved again.
- A 5xx answer is never stored, because it is treated as temporary, so a retry after a server error really runs.
- Keys from different accounts never collide.
- GET requests ignore the header.

## Example

```
curl -X POST https://ichatup.com/api/v1/messages \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "Idempotency-Key: order-A1042-confirmation" \
  -d '{"phone": "+919876543210", "template": "order_confirmed", "variables": ["Asha", "A-1042"]}'
```

```
HTTP/1.1 202 Accepted
Idempotent-Replay: true
{"id": 98231, "status": "accepted", "to": "+919876543210"}
```

## Choosing keys

Build the key from something that identifies the business event, not the attempt: an order number plus the message kind, a form submission id, a deal id plus stage. A random value made fresh on every attempt protects nothing. Do not reuse one key for two different messages, or the second will silently return the first one’s answer. The key is stored only as a hash.

Retries and status codes are covered in [errors and rate limits](https://ichatup.com/docs/errors-and-rate-limits).

## Questions

**What if I send the same key with a different body?**

The stored first response is returned. iChatUp does not compare bodies, so use a new key for a new message.

**Does idempotency apply to webhooks iChatUp sends me?**

No. For incoming webhooks, de-duplicate on the X-iChatUp-Delivery header, which stays the same across retries.

## Read next

- [Send a template message](https://ichatup.com/docs/messages)
- [Errors and rate limits](https://ichatup.com/docs/errors-and-rate-limits)
- [Webhook events](https://ichatup.com/docs/webhook-events)
- [Authentication](https://ichatup.com/docs/authentication)
- [Add or update a contact](https://ichatup.com/docs/contacts)

---
Source: https://ichatup.com/docs/idempotency
