Idempotency
Send an Idempotency-Key on every call that spends credits, so a retry after a timeout never charges twice.
Networks fail. If a request times out you do not know whether it ran. An Idempotency-Key lets you send it again safely: PostChamp runs the work once and answers the retry with the first answer.
Where it is required
Send the header on every call that spends credits. Without it the call answers 400 idempotency_key_required and nothing runs.
Other calls (saving, editing, scheduling, content styles) are free and ignore the header.
The key
How it behaves
“Same request” means the same method, path and body (after defaults are applied). Changing the prompt changes the request.
When the key is freed
You can reuse the same key (and retry the same request) when nothing was charged:
An unfinished call frees its key after 900 seconds (15 minutes).
Jobs and replays
Carousel and infographic creation start a job and answer 202. A retry with the same key returns the same carousel or infographic id (and Idempotent-Replayed: true) instead of starting a second one.
For a carousel change, a retry of a change that was already charged answers 409 conflict with details.reason: "already_done". Read the carousel to see the result.
Streaming
A post generation sent with Accept: text/event-stream uses the same key. The request is checked before anything streams. A replay arrives as a single result event. See Jobs and streaming.
If the store is down
When PostChamp cannot check the key, it answers 503 service_unavailable and starts nothing (it fails closed). Retry with the same key.