Skip to main content
Compress an uploaded image (.jpg, .jpeg, .png, .webp) with a preset or a custom operation chain. Every request returns a job, always the same shape. Small images are processed inline and the job comes back already completed (HTTP 200, result included); everything else is queued (HTTP 202) and finishes asynchronously. Sync eligibility: input of at most 5 MB, output format not AVIF, and no webhookUrl. Everything else is queued; AVIF always queues.

Request

Authorization
string
required
Bearer sk_live_...
Idempotency-Key
string
Optional, 1–255 characters. Returns the existing job if a job with this key was already created. Applies to queued jobs only; sync jobs complete inline and are not deduplicated.
imageId
string
required
Id of an upload, must be an image file (.jpg, .jpeg, .png, .webp).
preset
string
One of chill, medium, aggressive, thumbnail. Either preset or operations is required.
operations
array
1–10 custom operations, applied in order. See below.
webhookUrl
string
URL to receive job.completed / job.failed events for this job. Forces the queued path. Requires a plan with webhooks.

Presets

Operations

Encoding rules:
  • If your chain has no encode operation, one is appended with defaults (WebP, quality 80).
  • encode always runs last, regardless of where you place it. If several are sent, the last one wins.
  • The output file is result.webp, .avif, .jpg, or .png depending on format. AVIF encoding is memory-heavy, so AVIF jobs always take the queued path.
GET /v1/image/presets and GET /v1/image/operations return these definitions as JSON.

Examples

End-to-end: upload a photo, then thumbnail it synchronously:
End-to-end (sync)
Custom operations, AVIF output (queued)

Results

One code path handles both: check status. If it’s completed, the result is already in the response. Otherwise poll GET /v1/jobs/:id (ideally with ?wait=25 to long-poll) or wait for the webhook. result.outputUrl is a signed download URL, freshly generated on every read and valid for 1 hour; re-fetch the job for a new one. Results are retained for 7 days.

Credits

1 credit per started 2 MB of input, reserved up front and refunded if the job ultimately fails. See Credits.