Idempotency-Key header with a POST request. If the request times out or the connection drops, send it again with the same key. It runs once and is charged once.
Rules
What you get back
When a key is freed
A key is freed when the request did nothing, so you can send it again.Ambiguous timeouts
A504 service.timeout carries "ambiguous": true. The request may have completed and charged.
1
Send the same request with the same key
If the first request finished, you get its answer with
Idempotent-Replayed: true. If it is still marked as running, you get 409 idempotency.in_progress.2
On 409, wait and repeat
Wait for
Retry-After and send again.3
Check before you give up
GET /v1/credits lists the latest charges. Check it before you send the request with a new key.Recommendations
- Generate one key per logical request, and reuse it only for retries of that request.
- Do not reuse a key for a changed body. Changing
max_creditsor one identifier makes it a different request. - Send the body with the same content on every retry.

