POST
blindly risks doing the work twice — a second collection created, a second photo
added. Send an Idempotency-Key and the retry is free: Pexafy replays the
first response instead of running the request again.
This applies to POST requests only. GET and DELETE are already safe to
repeat, so they ignore the header.
Using it
Generate a unique key per logical operation — a UUID is the usual choice — and send it with the request:Rules
| Rule | Detail |
|---|---|
| Scope | POST only. Other methods ignore the header. |
| Key format | Up to 128 characters, letters, digits, - and _. Anything else is rejected with 400 INVALID_IDEMPOTENCY_KEY. |
| Retention | 24 hours. After that the key is forgotten and the same request would act again. |
| What is stored | Successful responses only (2xx). A failed request is not remembered, so you can retry it and actually get through. |
| Reuse | A key identifies one operation. Reusing it for a different request returns the first response, not the new one — so never reuse a key across operations. |
Keys are stored per key value, not per endpoint. Generate a fresh one for each
operation you want to be able to retry.
When to bother
Use it whenever a failed call would be expensive to repeat — creating a collection, adding photos in bulk from a job that may be retried by your queue. For plain searches it adds nothing:GET /search/photos is already safe to
repeat as often as you like.