Skip to content
smallPict
Start free

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

HTTP
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-0e9d8c7b6a5f

Request body

JSON
{  "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  }}
FieldTypeRequiredDescription
filenamestringYesOriginal filename of the asset (e.g. banner.png)
mime_typestringYesMIME type (e.g. image/jpeg, image/png, image/webp)
filesizeintegerYesTotal file size in bytes (must be > 0)
options.formatstringNoTarget format: avif, webp, jxl, original / keep, jpg, png (Default: webp)
options.target_formatsarrayNo1 to 5 of webp, avif, jxl, jpg, png: one upload produces every listed format, see "Several formats in one job" below
options.modestringNolossy (default), extreme or lossless. lossless needs a plan that includes it (see "Plan limits" below)
options.qualityintegerNoCompression quality between 1 and 100 (Default: 80)
options.max_dimensionintegerNoProportional clamp on maximum long-edge dimension in pixels (e.g. 1600, 1920, 2048, 2560)
options.max_widthintegerNoClamp maximum width in pixels
options.max_heightintegerNoClamp maximum height in pixels
options.losslessbooleanNoDeprecated: same as mode: "lossless". When both are sent, mode wins (Default: false)
options.strip_metadatabooleanNoStrip 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:

Response · 200 OK
{  "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)

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 .jxl file. 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" and format_fallback_reason in 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:

Response · 200 OK
{  "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"  ]}
  • url in each output is a link valid for 10 minutes; poll again for a new one. delivery_url and cdn_url are present when the output is stored for CDN delivery.
  • Each output can carry its own format_fallback_reason.
  • failed_formats lists 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. avif on a plan without AVIF is 403 feature_restricted.

Plan limits

API planRequests per monthMax file sizeLossless mode
Sandbox1005 MBYes
Ignite1,50010 MBYes
Velocity10,00025 MBYes
Momentum50,00050 MBYes

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:

JSON
{  "capabilities": {    "bulk": true,    "multi_format": true,    "formats": [      "webp",      "jpg",      "avif",      "png",      "jxl"    ],    "max_file_mb": 20,    "quota_mb": 5120  }}
  • bulk: true on every WordPress plan, Free included.
  • multi_format: the server accepts target_formats and returns outputs.
  • formats: the output formats your plan allows. jxl is in the list on every plan.
  • max_file_mb: your per-file limit.