Image Optimization Endpoint
Reference for the POST /v1/optimize endpoint: request fields, response, and job status.
The primary endpoint for optimizing, transcoding, downscaling, and resizing images is:
POST https://api.smallpict.app/v1/optimize
(Alias: POST https://api.smallpict.app/v1/convert)
Request
POST /v1/optimize HTTP/1.1Host: api.smallpict.appX-API-Key: sp_sdk_9a8b7c6d5e4f3a2b1c0d9e8f7a6b5c4d3e2f1a0bX-Timestamp: 1716301234X-Signature: 3a9f8b2c4d6e8a0f1b3c5d7e9f2a4b6c8d0e1f3a5b7c9d1e3f5a7b9c1d3e5f7aContent-Type: application/jsonIdempotency-Key: c9b8a7f6-e5d4-4c3b-2a1f-0e9d8c7b6a5fRequest body
{ "filename": "hero-banner.jpg", "mime_type": "image/jpeg", "filesize": 1654200, "options": { "format": "avif", "quality": 80, "max_dimension": 1600, "max_width": 1920, "max_height": 1080, "lossless": false, "strip_metadata": true }}| Field | Type | Required | Description |
|---|---|---|---|
filename | string | Yes | Original filename of the asset (e.g. banner.png) |
mime_type | string | Yes | MIME type (e.g. image/jpeg, image/png, image/webp) |
filesize | integer | Yes | Total file size in bytes (must be > 0) |
options.format | string | No | Target format: avif, webp, jxl, original / keep, jpg, png (Default: webp) |
options.target_formats | array | No | 1 to 5 of webp, avif, jxl, jpg, png: one upload produces every listed format, see "Several formats in one job" below |
options.mode | string | No | lossy (default), extreme or lossless. lossless needs a plan that includes it (see "Plan limits" below) |
options.quality | integer | No | Compression quality between 1 and 100 (Default: 80) |
options.max_dimension | integer | No | Proportional clamp on maximum long-edge dimension in pixels (e.g. 1600, 1920, 2048, 2560) |
options.max_width | integer | No | Clamp maximum width in pixels |
options.max_height | integer | No | Clamp maximum height in pixels |
options.lossless | boolean | No | Deprecated: same as mode: "lossless". When both are sent, mode wins (Default: false) |
options.strip_metadata | boolean | No | Strip camera EXIF / color profile metadata (Default: true) |
Transform URL parameters
The transform route resizes and converts an image from a URL using query parameters:
GET https://api.smallpict.app/v1/transform?url=...&format=webp&quality=80&max_dimension=1600
?format=avif|webp|original?quality=1..100?max_dimension=1600?max_width=1920?max_height=1080
Response (200 OK)
The response contains a secure, time-limited upload URL and a job ID you can poll. Upload the image bytes to upload_url with an HTTP PUT request, then check the job status:
{ "upload_url": "https://upload.smallpict.app/uploads/a1b2c3d4/hero-banner.jpg?signature=...", "job_id": "job-a1b2c3d4", "object_key": "uploads/a1b2c3d4/hero-banner.jpg", "status": "queued"}Always use the upload_url exactly as returned in the response. It expires after a short time and works only for this upload.
Job status
Check the progress of a job with:
GET https://api.smallpict.app/v1/optimize/status?job_id=job-a1b2c3d4
Completed Response (200 OK)
{ "job_id": "job-a1b2c3d4", "status": "completed", "url": "https://cdn.smallpict.app/opt/hero-banner.avif", "format": "avif", "bytes_saved": 1456200, "savings_percentage": 88.03, "created_at": "2026-08-23T08:00:00Z", "updated_at": "2026-08-23T08:00:01Z"}If a JPEG XL request completed as WebP (see "JPEG XL" below), the response also has "format_fallback_reason".
JPEG XL
Set format to jxl for a JPEG XL file (.jxl, image/jxl). It is available on every plan and counts like any other format: one request on an API plan, and once by the source size on a WordPress plan.
- Lossless JPEG recompression: a JPEG source with
mode: "lossless"is recompressed from its DCT coefficients. The pixels do not change, and the original JPEG can be rebuilt byte for byte from the.jxlfile. EXIF, GPS and ICC data are removed, as for every output. Lossless mode is included in WordPress Pro and Business and in every API plan. - Other sources and modes get a regular JPEG XL encode.
- A JPEG XL request never fails because of JPEG XL. The job completes as WebP, with
format: "webp"andformat_fallback_reasonin the status, when the image is larger than the server's megapixel limit after resizing (jxl_megapixel_limit) or the encoder refuses it, for example a CMYK JPEG (jxl_encode_failed).
Several formats in one job
Send options.target_formats to get several formats from one upload, for example ["jpg", "webp", "avif"]. The first format also fills format. The whole job counts as one request, and once by the source size on a WordPress plan. Send it only when capabilities.multi_format is true (see "Plan limits" below); older servers ignore it.
The completed status then has an outputs array, in request order, with only the formats that were produced:
{ "job_id": "job-a1b2c3d4", "status": "completed", "url": "https://cdn.smallpict.app/opt/photo.jpg", "format": "jpg", "outputs": [ { "format": "jpg", "content_type": "image/jpeg", "size": 1638000, "bytes_saved": 812000, "url": "https://..." }, { "format": "webp", "content_type": "image/webp", "size": 980000, "bytes_saved": 1470000, "url": "https://..." } ], "failed_formats": [ "avif" ]}urlin each output is a link valid for 10 minutes; poll again for a new one.delivery_urlandcdn_urlare present when the output is stored for CDN delivery.- Each output can carry its own
format_fallback_reason. failed_formatslists formats that could not be encoded. The job fails only when every format failed.- An empty list, more than 5 formats or an unknown format is
400 VALIDATION_FAILED.avifon a plan without AVIF is403 feature_restricted.
Plan limits
| API plan | Requests per month | Max file size | Lossless mode |
|---|---|---|---|
| Sandbox | 100 | 5 MB | Yes |
| Ignite | 1,500 | 10 MB | Yes |
| Velocity | 10,000 | 25 MB | Yes |
| Momentum | 50,000 | 50 MB | Yes |
WordPress plans: Free 5 MB, Starter 10 MB, Pro 20 MB and Business 45 MB per file (see Quota & Multi-Site Shared Pool). A larger file is answered with 400 file_too_large.
GET /v1/quota reports what your key can use in capabilities:
{ "capabilities": { "bulk": true, "multi_format": true, "formats": [ "webp", "jpg", "avif", "png", "jxl" ], "max_file_mb": 20, "quota_mb": 5120 }}bulk:trueon every WordPress plan, Free included.multi_format: the server acceptstarget_formatsand returnsoutputs.formats: the output formats your plan allows.jxlis in the list on every plan.max_file_mb: your per-file limit.