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

# Idempotency

> Retry a POST without doing it twice.

A network error leaves you not knowing whether a post was created. Send an `Idempotency-Key` header with any `POST`, and sending the same request again with the same key gets the first answer instead of a second post.

```bash theme={"system"}
curl https://api.postinger.dev/v1/posts \
  -H "Authorization: Bearer $POSTINGER_API_KEY" \
  -H "Idempotency-Key: 7c1e2b9a-campaign-42" \
  -H "Content-Type: application/json" \
  -d @post.json
```

* Any string up to **255** characters. A UUID per operation works well.
* Kept for **24 hours**.
* Only successes are kept: after a failure, fix the request and send it again with the same key.
* A replayed answer carries the `Idempotent-Replayed: true` header.

| Case | Answer |
| - | - |
| Same key, same request | The first answer, again. |
| Same key, different request | `422` |
| Same key while the first is still running | `409` |

The CLI sends an `Idempotency-Key` with every `POST` and retries once with it when a request fails without an answer.


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