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, original / keep, jpg, png (Default: webp)
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.losslessbooleanNoEnable pixel-perfect lossless compression (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"}