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

# Retrying safely

> Idempotency-Key: retry without sending or charging twice.

Every `POST` needs an `Idempotency-Key` header: your own unique id for that request, for example your order number.

* Send the **same key and the same body** again (after a timeout, say) and you get the **first answer** again, with the header `Idempotent-Replayed: true`. Nothing is sent or charged twice.
* The same key with a **different** body answers `request_id_reused`.
* A key is remembered for 24 hours.

```bash cURL theme={null}
curl https://api.getreply.in/v1/messages/template \
  -H "Authorization: Bearer gr_live_…" \
  -H "Idempotency-Key: order-4521-update" \
  -H "Content-Type: application/json" \
  -d '{"to": "+9198250*****", "template": {"name": "order_update", "language": "en"}, "body": ["Riya", "#4521"]}'
```

```javascript Node.js theme={null}
const res = await fetch("https://api.getreply.in/v1/messages/template", {
  method: "POST",
  headers: {
    "Authorization": "Bearer gr_live_…",
    "Idempotency-Key": "order-4521-update",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "to": "+9198250*****",
    "template": {
      "name": "order_update",
      "language": "en"
    },
    "body": [
      "Riya",
      "#4521"
    ]
  }),
});
console.log(await res.json());
```

```php PHP theme={null}
<?php
$ch = curl_init("https://api.getreply.in/v1/messages/template");
curl_setopt_array($ch, [
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer gr_live_…",
    "Idempotency-Key: order-4521-update",
    "Content-Type: application/json",
  ],
  CURLOPT_POSTFIELDS => '{"to": "+9198250*****", "template": {"name": "order_update", "language": "en"}, "body": ["Riya", "#4521"]}',
]);
echo curl_exec($ch);
```

```python Python theme={null}
import requests

res = requests.post(
    "https://api.getreply.in/v1/messages/template",
    headers={
        "Authorization": "Bearer gr_live_…",
        "Idempotency-Key": "order-4521-update",
    },
    json={
        "to": "+9198250*****",
        "template": {
            "name": "order_update",
            "language": "en"
        },
        "body": [
            "Riya",
            "#4521"
        ]
    },
)
print(res.json())
```

> [!TIP]
>
> Use one key per thing you want to happen once — one key per order update, not one per request attempt.

If you get `rate_limited`, wait the seconds in the `Retry-After` header and try again with the same key.


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