Idempotent requests
Send an Idempotency-Key so a retried create or convert never reserves or bills a second job.
Networks drop responses. If POST /v1/jobs or POST /v1/convert times out, you cannot tell whether convt created the job. Send an Idempotency-Key header and you don’t have to: retry with the same key, and convt returns the job the first request made instead of reserving another.
curl -fsSL https://api.convt.app/v1/convert \
-H "Authorization: Bearer $CONVT_API_KEY" \
-H "Idempotency-Key: 7f1c2e4a-order-1042" \
-F file=@photo.png -F to=webp -o photo.webp
Rules
- A key is any 1 to 255 visible ASCII characters. A UUID per logical request works well. Use a value tied to your own record, such as an order id, when you want the same job back after your process restarts.
- Keys belong to your account and last as long as the job: 24 hours. After the job expires, the key is free again.
- A retry must send the same request. convt fingerprints the route, formats, options,
source_url,webhook_url,input_sha256and, for/v1/convert, the file’s bytes.POST /v1/jobsonly sees the declared size, so send the file’s SHA-256 asinput_sha256with a key; otherwise two different files of the same size look like the same request. The same key with a different request fails with409 idempotency_key_reused. - A replay answers with the original job and an
Idempotent-Replayed: trueheader. It never touches your spend cap.
What a replay returns
| Route | Original job state | Replay returns |
|---|---|---|
POST /v1/jobs |
created (not uploaded yet) |
The job and a fresh upload_url. |
POST /v1/jobs |
Started or finished | The job, with upload_url: null. Its input can no longer be replaced. |
POST /v1/convert |
Not uploaded yet | convt stores the file from the retry and runs the job. |
POST /v1/convert |
Queued or running | Waits for the same job, then answers as the first request would have, or 409 still_running again if it is still going after wait. |
POST /v1/convert |
Finished | The same outcome: a 303 redirect to the stored file (or JSON outputs, or the failure). |
Hanging up
Without a key, closing the connection to POST /v1/convert before the answer cancels the job. That is best effort: a conversion that already succeeded is billed, and you can’t fetch it without its id, which is one more reason to send a key. With a key, the job keeps running, because a retry with that key is expected to collect it. It is billed once if it succeeds.
When a create fails in a way that leaves the outcome unknown (a timeout, a reset connection), the SDK’s ConvtError carries the idempotencyKey it used. Retry with it.
The SDK does this for you
convt.convert() and convt.convertUrl() create every job with a fresh key, and retry rate limits, gateway errors and broken responses with it. Pass your own with the idempotencyKey option (or convt.create(input, { idempotencyKey })), such as your order id, so a second run after a crash returns the same job.