Idempotency
Retry any create safely: the same Idempotency-Key never makes, or charges for, a second job.
The Idempotency-Key header
Networks drop. If a create times out you can't tell whether the job started. Send an Idempotency-Key header with every create, and you can retry without fear: we make the job once, whatever happens.
The key is any unique string up to 200 characters. A random UUID works; so does something from your own system that names the thing you are making, such as order-1042-film. Every create endpoint accepts it.
How repeats are answered
| You send | We answer |
|---|---|
| A new key | The request runs normally and answers 201. |
| The same key and the same body | The first response again, with status 200: the same job as it was then. Nothing new is started or charged. Retrieve the job for its current state. |
| The same key with a different body | 409 idempotency_conflict. Use a new key for a new request. |
| The same key while the first request is still being handled | 409 idempotency_conflict. Retry shortly. |
| The same key after the first request failed with an error | The request runs again: a refused create frees its key, so a corrected retry can use it. |
How long keys last
We keep every key with the response it answered, so a retry is covered however late it comes. That also means a key belongs to one request for good: never reuse it for a different one.
The SDKs add a key for you
The TypeScript and Python SDKs put a random key on every create and reuse it across their own retries. Pass your own with idempotencyKey (TypeScript) or idempotency_key (Python) when you want retries across restarts of your app, for example from a job queue, to be safe too.