Requests, results and retries
Requests run in the background. Follow one until it finishes, then download what it made.
Every processing endpoint starts a request that runs in the background. The response is the request itself, with status queued.
Statuses
| Status | Meaning |
|---|---|
queued |
Accepted, waiting for a worker. |
processing |
Running. Video requests report progress (0–100). |
succeeded |
Finished. result holds the data and the files. |
failed |
Finished without a result. error says why. Not charged. |
aborted |
Stopped with POST /v1/requests/{id}/abort. Not charged. |
Poll GET /v1/requests/{id} every few seconds (images take about a second; videos take longer), or pass webhook_url to be told (see Webhooks). While a request is unfinished, stage says whether it is queued, starting (a dedicated worker for a long video is starting, which takes about a minute) or processing; once it starts, runtime says where it runs.
Waiting for the result
Send "wait": 20 (up to 25 seconds) to get the result in the response. If the request finishes in time the answer is 200 with the finished request; if not, 202 with the request as it stands, and it carries on as usual. Small images, reads, screenshots and document pages usually run right away on the server that took the request (runtime inline), so they answer about as fast as the work itself. A video does too when it is short enough to finish in the time; otherwise it goes to the queue at once. GET /v1/requests/{id}?wait=25 waits the same way, to follow up without polling.
Results
result.files has one file per output, in the order you sent them. Each has an id (file_…), the output's name, format, size and data (its dimensions). result.data describes the first output, and the source's own details: dimensions and format for images, duration and codec for videos, pages and size for PDFs.
A file the API keeps has a url: a download link that works until the file is deleted (url_expires_at, the same moment as the file's deleted_at), 7 days after the request finishes unless the output said otherwise. Anyone with the link can download the file, so share it only where the file may go. Opening it redirects to the file itself. GET /v1/files/{id} gives a file and a fresh link; DELETE /v1/files/{id} deletes it early.
Read endpoints (images/read, videos/read, documents/read) return result.data only.
Outputs
One request can make several files from one source. Send outputs, a list of up to 10 for images (for a video: the video, then up to two images of its frames, each with at in seconds; one for the other endpoints): each has a name you choose and can have its own format, quality, operations and destination. The request's operations run once; each output's own operations then run on that result.
{
"source": "https://example.com/photo.jpg",
"operations": [{"type": "watermark", "image_url": "https://example.com/logo.png", "x": 40, "y": 40}],
"outputs": [
{"name": "full", "format": "webp"},
{"name": "medium", "format": "webp", "quality": 85, "operations": [{"type": "resize", "width": 1200, "height": 1200}]},
{"name": "thumb", "format": "jpg", "operations": [{"type": "thumbnail", "width": 400}]}
]
}
A video's first output takes a format, a quality and a destination, and no operations of its own. Its quality (1 to 100) sets how the video is encoded: 78 is the default look, 90 is sharper and about 1.7 times the size, 65 is about 60% of the size. A WebM is written in VP9 when it is given a quality, which takes about twice as long as MP4.
The first output costs the endpoint's price and each further one the price of processing an image; price.breakdown lists each. The API keeps each file for 7 days; to keep one longer, write it to your own storage with a destination (see Files). output: {"format": "png"}, without outputs, is the same as one output named result.
Where each output's file goes, and every form source can take, is in Files in and out.
Idempotency
Send an Idempotency-Key header (any unique string up to 255 characters) to make a retry safe. The same key with the same body returns the first request (200, header Idempotent-Replayed: true) instead of starting and charging a second one. The same key with a different body is a 409.
Your own references
customer (up to 64 characters) and metadata (up to 20 keys of text) are stored on the request, returned with it and sent in its webhooks. Use them to tie requests to your own users and orders; GET /v1/usage?group_by=customer totals them.