Idempotency
Networks fail. With an Idempotency-Key, retrying a POST returns the first result instead of creating a second job or upload.
How it works
- Send
Idempotency-Key: <unique value>(1 to 255 printable ASCII characters; a UUID is ideal) on anyPOSTthat creates something:POST /v1/files,/v1/files/upload,/v1/files/{id}/complete,POST /v1/audio/denoise,/separate,/enhanceand/remove-fillers,POST /v1/image/remove-background,POST /v1/video/remove-backgroundandPOST /v1/jobs(JSON or multipart),POST /v1/webhook-endpointsand the signing-secret rotation. - The same key with the same body within 24 hours replays the first response: same status, same body, same job. The work is done once.
- The same key with a different body gets
409 idempotency_key_reused. - Keys are scoped to your API key, its mode and the endpoint. A request that failed validation (a
4xxbefore anything was created) is not stored, so you can fix it and resend with the same key. - After 24 hours the key is forgotten and a reuse counts as a new request.
- Replays of
POST /v1/filesreturn fresh upload URLs, never stale ones. For a multipart upload the comparison covers the file's name, size, type and SHA-256. - Secrets are never replayed: a replayed webhook endpoint create returns
secret: null, a replayed rotationalready_displayed: true.
KEY=$(uuidgen) # one key per job you mean to create; reuse it only for retries
# --retry retries timeouts, 429 and 5xx (honouring Retry-After) with the same key;
# any other 4xx (402 insufficient_credit, 409 idempotency_key_reused, ...) fails at once.
curl -s --fail-with-body --retry 4 --retry-connrefused --max-time 30 https://api.zilapi.com/v1/audio/denoise -H "Authorization: Bearer $ZILAPI_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $KEY" \
-d '{"file": "'"$FILE_ID"'", "model": "zilapi/nr-4.1"}'