Skip to content
Snapkiln

Documentation

Snapkiln API

The Rust API is versioned at /v1. The browser product talks to a same-origin BFF; direct API clients authenticate with a tenant API key. The live OpenAPI 3.1 document is served at GET /v1/openapi.json.

Overview

A job takes one image, applies a preset or custom options, and produces one artifact. Work is queued durably in PostgreSQL and processed by a worker. Jobs are tenant-scoped; a key or session can only read its own tenant's records.

Base URL

Your deployment origin

Auth

Bearer tenant API key or BFF session

Content type

multipart/form-data

OpenAPI

GET /v1/openapi.json

Authentication

Create a key in Developer → API keys. The plaintext is shown once. Send it as a bearer token; never place it in browser storage or a public URL.

curl "$MEDIAFORGE_API_URL/v1/usage" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY"

Session cookies are only used by the browser BFF. They are HttpOnly, SameSite=Lax, and Secure on HTTPS. State-changing BFF requests also require the CSRF token.

Submit a job

curl -X POST "$MEDIAFORGE_API_URL/v1/jobs" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY" \
  -H "Idempotency-Key: order-1042-hero" \
  -F "file=@cover.jpg" \
  -F "preset=hero"

Use options instead of preset for a custom transform. The JSON is validated against the engine schema.

-F 'options={"transform":{"width":1600,"height":900,"fit":"cover"},"encode":{"format":"webp","quality":82,"metadata":"strip"}}'

The response is 202 Accepted with a job id. Idempotent replays return 200 and the existing job.

Batch

Send up to 16 file parts in one request, total body at most 32 MiB. Each file becomes an independent job. A partial failure is visible per item; the request fails only when validation of the batch itself fails.

curl -X POST "$MEDIAFORGE_API_URL/v1/jobs/batch" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY" \
  -F "file=@one.jpg" -F "file=@two.png" \
  -F "preset=thumbnail"

Status and artifacts

Poll GET /v1/jobs/:id. Terminal statuses are succeeded, failed, dead_letter, and cancelled. Stop polling then. The API has no webhook or SSE channel in this release.

curl "$MEDIAFORGE_API_URL/v1/jobs/$JOB_ID" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY"

curl -L "$MEDIAFORGE_API_URL/v1/jobs/$JOB_ID/artifact" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY" \
  -o result.webp

Artifact metadata includes format, dimensions, size, and SHA-256. Downloads are authenticated streams, not public URLs.

Recipes

curl -X POST "$MEDIAFORGE_API_URL/v1/recipes" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"storefront-hero","description":"Wide WebP","config":{"preset":"hero"}}'

List with GET /v1/recipes, update with PUT /v1/recipes/:id, delete with DELETE /v1/recipes/:id. Names are unique per tenant.

Usage and quotas

Usage is counted per accepted job: one unit plus the input bytes. Quotas apply per tenant and include an active-job concurrency ceiling. Private beta also enforces a global monthly job budget and an operator disable switch.

curl "$MEDIAFORGE_API_URL/v1/usage" \
  -H "Authorization: Bearer $MEDIAFORGE_API_KEY"

Quota errors return 429 with quota_exceeded or concurrency_limit. A disabled beta returns 503 beta_disabled.

Limits

Single request body16 MiB
Image file15 MiB
Batch request16 files / 32 MiB total
Dimensions8000 × 8000, 30 MP
Input formatsJPEG, PNG, WebP
Rate limitDefault burst 60, refill 10 req/s per tenant

Errors

{
  "error": {
    "code": "invalid_image",
    "message": "image payload exceeds maximum 15728640 bytes"
  }
}

Codes are stable identifiers. Messages are safe for display and never include storage keys, filesystem paths, or credentials. Honor Retry-After on 429 and 503 responses.