Errors
Errors use HTTP status codes and an application/problem+json body with a stable code. Match on code, not on the text of detail.
Error format
Every error body has type, title, status, detail, code and request_id (RFC 9457). Every response, error or not, carries an X-Request-Id header: quote it when you contact us.
HTTP/1.1 402 Payment Required
Content-Type: application/problem+json
X-Request-Id: req_8Zt3NwQ1pL5m
{
"type": "https://zilapi.com/errors/insufficient_credit",
"title": "Insufficient credit",
"status": 402,
"detail": "Available credit is below this job's cost.",
"code": "insufficient_credit",
"request_id": "req_8Zt3NwQ1pL5m"
}Error codes
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 422, 400 | invalid_request | A field is missing or has a bad value, the JSON is malformed, or a cursor is invalid. detail names the field, for example size_bytes: …. | Correct the request. Retrying the same request will fail the same way. |
| 401 | unauthorized | The Authorization header is missing, or the key is unknown or revoked. | Send Authorization: Bearer zil_live_… (or zil_test_…) with an active key from the dashboard. |
| 402 | insufficient_credit | Your available credit (unexpired credit minus what running jobs hold) is below this job's exact cost. Nothing started and nothing was charged. While a job waits for payment, its price counts against your credit too, so a new job gets this code unless your credit covers both. | Add credit in the dashboard, or wait for running jobs to finish, then create the job again. |
| 402 | payment_required | GET /v1/jobs/{id}/output on a job in the status payment_required: it ran on slightly short credit and its output stays locked until it is paid (payment.amount_due_micros). Also a failed job's error.code when that output was not paid within 72 hours or was deleted unpaid; nothing was charged then. | Top up so that your available credit covers the amount due; the job is paid and unlocked automatically, then ask for the output again. See When a job waits for payment. |
| 403 | forbidden | This key or account is not allowed to do this. | Check that you are using the right key and account. |
| 403 | insufficient_scope | The key lacks a scope this endpoint needs; detail names it (files:write, jobs:write, jobs:read or credits:read). | Use a key that has the scope, or create one. See Authentication. |
| 403 | account_suspended | The account is suspended. New jobs are refused; jobs already running finish. | Email support@zilapi.com. |
| 403 | account_frozen | The account is frozen while a card payment dispute is open. | Email support@zilapi.com to resolve the dispute. |
| 403 | live_jobs_restricted | Live-mode jobs on the test stack (api-test.zilapi.com) run only for approved accounts. | Use a test key on the test stack, or a live key on api.zilapi.com. |
| 403 | email_not_verified | Creating a live webhook endpoint in the dashboard needs a confirmed email address. | Open the link in the email we sent you (the dashboard can send another), then try again. |
| 404 | not_found | No such file, job, model or webhook endpoint on this account in this mode. Test keys never see live objects, and live keys never see test ones. | Check the id, and use a key of the same mode (live or test) that created the object. |
| 405 | method_not_allowed | The path exists but not with this HTTP method. | Check the method in the API reference. |
| 409 | file_not_ready | The file is still uploading or validating, or it was rejected, so a job cannot use it yet. | Poll GET /v1/files/{id} until status is ready. A rejected file never becomes ready. |
| 409 | file_in_use | You tried to delete a file that a queued or processing job is using. | Wait for the job to finish (or cancel it while it is queued), then delete the file. |
| 409 | upload_expired | /complete came after the upload window (6 hours from POST /v1/files) closed. | Start a new upload with POST /v1/files. |
| 409 | job_not_cancelable | The job has already started processing. Only jobs that are waiting for their file or queued can be canceled. | Let it finish. It is charged only if it succeeds. |
| 409 | job_not_succeeded | You asked for the output of a job that has not succeeded (yet). | Poll GET /v1/jobs/{id} until status is succeeded. Failed and canceled jobs have no output. |
| 409 | job_not_finished | DELETE /v1/jobs/{id}/output on a job that has not finished yet (waiting, queued or processing). Also when a job waiting for payment was paid by a top-up while you were deleting its output: the output is kept, unlocked. | Wait until the job has finished. For a job that was just paid, delete the output again if you still want to. |
| 409 | too_many_endpoints | The account already has 20 webhook endpoints in this mode (disabled ones count too). | Delete endpoints you no longer use, or subscribe one endpoint to more events. |
| 409 | endpoint_disabled | You sent a test ping to a disabled webhook endpoint. | Re-enable it with PATCH /v1/webhook-endpoints/{id} and {"enabled": true}, then ping it. |
| 409 | last_sign_in_method | Dashboard only: you tried to disconnect the only way left to log in to the account. | Set a password or connect another sign-in method first. |
| 409 | idempotency_key_reused | This Idempotency-Key was already used with a different request body, or an earlier request with it did not record a result. | Use a new key for each distinct request. Reuse a key only to retry the identical request. |
| 410 | output_expired | The result was deleted: outputs are kept for 7 days after the job succeeds. | Download results within 7 days. To get it again, run a new job on a new upload. |
| 413 | file_too_large | The file is over 5 GB (5,368,709,120 bytes), over 50 MB for a one-request upload (POST /v1/files/upload or a multipart job), over 25 MB for a test key, or over the model's size limit. Also a rejected file's or failed job's error.code when a URL download turns out too large. | Upload larger files with POST /v1/files (up to 5 GB), or compress or split the audio. Use a live key for files over 25 MB. |
| 413 | request_too_large | The request body itself is too large. Only the multipart endpoints (POST /v1/files/upload and the task endpoints, such as POST /v1/audio/denoise or POST /v1/image/remove-background) take file bytes, up to 50 MB, and only with an Authorization header; everything else is small JSON. | Send larger files to upload.url from POST /v1/files, or give us a URL to fetch. |
| 415 | unsupported_media_type | content_type (or the multipart part's type) is not an audio, image or video type we accept (see Files). On a URL input it is the rejected file's error.code when the server returned, say, an HTML page. | Send the file's real type, for example audio/wav, audio/mpeg, audio/mp4, image/png, image/jpeg, image/webp or video/mp4. |
| 422 | fetch_failed | We could not download the url (or input_url), or it is not allowed: not https, a non-public address, too many redirects, or too slow. The file becomes rejected and a job waiting for it fails, with this error.code; nothing is charged. | Check that the URL is public, https and downloadable without a login (try it with curl), then send it again. |
| 422 | invalid_audio | The upload is not audio we can decode. The file becomes rejected (error.code on the file), and a job waiting for it fails with the same code; nothing is charged. | Check the file plays locally and that content_type matches it, then upload it again. |
| 422 | audio_too_long | The audio is longer than 6 hours (21,600 s), or longer than the model allows. The file is rejected and a job waiting for it fails; nothing is charged. | Split the recording into parts under 6 hours. |
| 422 | invalid_image | Background removal got a file that is not a PNG, JPEG or WebP image we can decode (animated images and HEIC are not supported). An image that fails the check is rejected with this error.code, and a job waiting for it fails with it; nothing is charged. | Send a still PNG, JPEG or WebP image; convert other formats first. |
| 422 | image_too_large | The image is over 10,000 px on a side or over 50 megapixels (WebP, and progressive JPEGs saved without colour subsampling (4:4:4), in CMYK or with unusual colour sampling: over 20 megapixels). The file is rejected with this error.code and a job waiting for it fails with it; nothing is charged. (An upload declared as an image over 50 MB gets 413 file_too_large.) | Resize the image to fit within 10,000 px per side and 50 megapixels (20 megapixels for WebP and those progressive JPEGs), or convert a large WebP or progressive JPEG to PNG or baseline JPEG, then send it again. |
| 422 | invalid_video | Video background removal got a file it cannot use: not an MP4, MOV or WebM (H.264, HEVC, VP8, VP9 or AV1) video we can decode, no frames, a side under 64 px, or over 60 fps. Problems found when the file is checked (an unsupported codec, an odd width or height, a frame size that changes) reject the file with this error.code, unless its audio track is fine: then the file is ready for audio models and only video jobs refuse it. With a ready file the create call answers with it; otherwise the job fails with it. Nothing is charged. | Send an MP4, MOV or WebM video within the limits; convert or re-encode other files first. |
| 422 | video_too_large | The video is larger than 1920×1080 (1080×1920 in portrait). Nothing is charged. | Scale the video down to fit within 1920×1080, then send it again. |
| 422 | video_too_long | The video is longer than 60 seconds. Nothing is charged. | Split the video into parts of at most 60 seconds. |
| 422 | model_not_available | The model id is unknown, not live, or has no price. | Pick a model from GET /v1/models, or leave model out to use the task's default. |
| 429 | rate_limited | Over the per-key limit: 120 creates or 1,200 reads per minute (and per IP for public endpoints). | Wait Retry-After seconds, then retry. See Rate limits. |
| 429 | too_many_active_jobs | The account already has as many jobs waiting, queued or processing as it may: 10 live jobs before your first top-up (audio and image together); after it, 50 audio jobs and, counted separately, 500 image jobs; 10 with test keys. | Wait Retry-After seconds, or for some jobs to finish, then retry. Check GET /v1/limits; for more, email support@zilapi.com. |
| 429 | test_job_quota_exceeded | Test keys only: the account created 500 test jobs in the last 24 hours. | Wait Retry-After seconds. Finished test jobs are deleted after 30 days. |
| 429 | quota_exceeded | A file quota was reached: 10 uploads in progress, stored inputs (1 GB before your first top-up, 20 GB after), or files checked per hour (20 before your first top-up, 10,000 after). Retry-After comes with the hourly limit. | Finish or delete open uploads, delete files you no longer need, or wait Retry-After seconds. |
| 500 | internal_error | Something went wrong on our side. On a job, error.code is internal_error and you are not charged. | Retry with the same Idempotency-Key. If it keeps happening, email us the request_id. |
| 502 | provider_error | An upstream service failed: the GPU provider (as a failed job's error.code) or the payment provider. | Create the job again. Failed jobs are never charged. |
| 503 | service_unavailable | A dependency (storage, the rate-limit store) is briefly unavailable. | Retry after Retry-After seconds, with the same Idempotency-Key for creates. |
Errors on a job or a file
Some problems show up after the request was accepted: in a failed job's error and a rejected file's error, as { code, message }, and in the job.failed and file.rejected webhooks. A failed job is never charged. Files explains each file code for audio, images and video.
| code | On | Meaning |
|---|---|---|
| fetch_failed | file, job | We could not download the url or input_url, or it is not allowed (not https, not a public address, too many redirects). message gives a short reason. |
| invalid_audio | file, job | The input is not audio we can decode, or an audio model got an image or a video without audio. |
| audio_too_long | file, job | The input is longer than 6 hours. |
| invalid_image | file, job | Not a still PNG, JPEG or WebP we can decode, or background removal got a file that is not an image. |
| image_too_large | file, job | The image is over 50 MB, 10,000 px on a side or 50 megapixels (20 megapixels for WebP and some progressive JPEGs). |
| invalid_video | file, job | A video we cannot use: an unsupported codec, an odd width or height, a changing frame size, a side under 64 px, over 60 fps, or no video track. |
| video_too_long | job | The video is longer than 60 seconds. |
| video_too_large | job | The video is larger than 1920×1080 (1080×1920 in portrait). |
| file_too_large | file, job | The download was larger than 5 GB (25 MB with a test key), or the input is over the model's size limit. |
| unsupported_media_type | file, job | The URL returned a type we do not accept, such as an HTML page. |
| quota_exceeded | file, job | The file did not fit your stored-input quota. |
| insufficient_credit | job | When the input became ready, your available credit was below the job's cost. |
| payment_required | job | The job ran on slightly short credit and its locked output was not paid within 72 hours, or you deleted it unpaid. The output is gone and nothing was charged. |
| provider_error | job | The model could not process the file. Create the job again. |
| internal_error | job | Something went wrong on our side. |
Handling errors
- Retry
429,500,502and503afterRetry-Afterseconds (or with exponential backoff when there is none). For aPOST, retry with the sameIdempotency-Key. - Do not retry other
4xxerrors unchanged: fix the request first. The exceptions are409 file_not_ready(wait until the file is ready),429 too_many_active_jobs(wait for some of your jobs to finish) and402 payment_requiredon an output (top up, then ask again). - Only a succeeded job is ever charged. A failed request or a failed job costs nothing.
# --retry honours Retry-After on 429 and 503
curl -s --retry 5 --retry-max-time 120 https://api.zilapi.com/v1/jobs/$JOB_ID -H "Authorization: Bearer $ZILAPI_KEY" -D headers.txt
grep -i '^ratelimit-' headers.txt # RateLimit-Limit: 1200, RateLimit-Remaining: 1199, RateLimit-Reset: 1Slow or timed-out uploads
If an upload to api.zilapi.com (POST /v1/files/upload, or a job request with the file in a multipart file field) is slow, times out or loses its connection, especially from far away or above about 5 MB, switch to uploading straight to storage: POST /v1/files, PUT the bytes to the signed URL, POST /v1/files/{id}/complete, then create the job with file. The bytes go straight to storage instead of through our API servers on the US East Coast, so uploads from far away are more reliable, and a failed PUT can simply be sent again to the same URL.
Before you switch, a request that timed out can be retried with the same Idempotency-Key: if it did reach us, you get the first answer back instead of a second file or job.