Skip to content

Generating Images

The generate endpoint is the core of the API. You send variable values; it returns the rendered image bytes.

POST /api/v1/templates/{templateId}/generate

Each successful call consumes one render from your monthly quota.

Path parameter: templateId (UUID) — the template to render.

Headers

HeaderRequiredDescription
X-Api-KeyyesYour API key
Content-Typeyesapplication/json
Idempotency-KeynoUp to 128 chars. Repeating a request with the same key returns the cached image without re-rendering (and without consuming extra quota).

Body

FieldTypeRequiredDescription
variablesobjectyesMap of variable name → value. Names must match those from GET /templates/{id}. Values are strings.
formatstringnopng (default), jpeg, webp, or pdf
optionsobjectnoRender options (below)

options object

FieldTypeRangeDescription
scaleinteger14Resolution multiplier for raster output
qualityinteger1100Compression quality for jpeg / webp
outputDpiinteger96, 150, 300DPI tier — use 300 for print/PDF
backgroundColorstringhexOverrides the template background, e.g. #ffffff
Terminal window
curl -X POST https://app.zandovi.com/api/v1/templates/$TEMPLATE_ID/generate \
-H "X-Api-Key: $ZANDOVI_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-10432-coupon" \
-o coupon.png \
-d '{
"variables": {
"first_name": "Sarah",
"discount_code": "VIP30",
"expires_at": "30 Jun 2026"
},
"format": "png",
"options": { "scale": 2, "quality": 90 }
}'

For JavaScript and Python examples, see the Quickstart.

On success the response is 200 OK with the raw image as the body — there is no JSON wrapper and no hosted URL. The Content-Type matches the requested format:

formatContent-Type
pngimage/png
jpegimage/jpeg
webpimage/webp
pdfapplication/pdf

A Content-Disposition: attachment; filename=… header is included. Write the body straight to a file or pipe it onward.

Response headers

HeaderDescription
X-Request-IdUnique ID for this request — include it in support requests
X-Template-IdTemplate used for the render
X-Render-Time-MsServer-side render duration
X-Quota-LimitMonthly render ceiling for the workspace
X-Quota-RemainingRenders left this billing period
X-Quota-ResetISO 8601 UTC time the quota resets
  • Supply every required variable. Missing required variables return 400 with an application/problem+json body naming the offending variable.
  • Values are sent as strings, including number, date, phone, and url types — they are validated against the template’s rules server-side.
  • qrcode and barcode variables take the data to encode; image variables take an image URL.
  • Variables you omit fall back to their defaultValue if the template defines one; otherwise an optional variable simply renders empty.
CodeCause
400Missing required variable or a value failed validation
401Missing or invalid API key
404Template not found or not accessible to this key
429Monthly quota or short-term rate limit exceeded
502 / 503Rendering service errored or is temporarily unavailable — retry with backoff

See Errors, quotas & rate limits for response bodies and retry guidance.