Batch rendering

A batch renders N outputs from one template + a data source + a field mapping, asynchronously. It's the managed counterpart to POST /v1/render: submit a template, a target size, and rows of records; Lemtika seeds one render per row, processes them on a worker fleet, and gives you a per-row manifest plus a zip bundle. Each row is the same deterministic render the single endpoint produces.

1. (Optional) Discover the template's fields

curl -sS "https://api.lemtika.com/v1/render-batches/template-fields?templateId=tmpl_og_card" \
  -H "Authorization: Bearer $LEMTIKA_API_KEY"

Returns fields (the content fields you supply — brand-bound fields like the logo are filled automatically and don't appear) and a sample row.

2. Create the batch

POST /v1/render-batches returns 202 Accepted immediately with a batch id. The data source is either inline records (json-array only) or an uploaded sourceRef (from POST /v1/uploads, for csv/xlsx).

curl -sS -X POST "https://api.lemtika.com/v1/render-batches" \
  -H "Authorization: Bearer $LEMTIKA_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "templateId": "tmpl_og_card",
        "target": "square",
        "sourceType": "json-array",
        "source": { "records": [ { "name": "Jane" }, { "name": "Ada" } ] }
      }'
{ "id": "bat_5kQ2rL7vB4nC6dF8hX1yZ", "status": "queued" }

Fields map auto by name by default — a source field name binds to the template variable name. Supply bindings only to override or use a constant / profile / generated source.

3. Poll status

curl -sS "https://api.lemtika.com/v1/render-batches/bat_5kQ2rL7vB4nC6dF8hX1yZ" \
  -H "Authorization: Bearer $LEMTIKA_API_KEY"
{ "id": "bat_5kQ2rL7vB4nC6dF8hX1yZ", "status": "succeeded", "target": "square", "total": 2, "succeeded": 2, "failed": 0 }

Key off status for completion, not a counter sum (counters are eventually consistent). Values: queued, running, succeeded, partial (some rows failed), failed, degraded (stopped early by the failure circuit-breaker — fix the cause and replay).

4. The per-row manifest

curl -sS "https://api.lemtika.com/v1/render-batches/bat_5kQ2rL7vB4nC6dF8hX1yZ/renders?cursor=0" \
  -H "Authorization: Bearer $LEMTIKA_API_KEY"
{
  "rows": [
    { "rowIndex": 0, "status": "succeeded", "renderId": "rnd_7yLp2mQ4rK9vB1nC3dF5h", "outputKey": "tenant/…/0.png", "error": null },
    { "rowIndex": 1, "status": "failed", "renderId": "rnd_…", "outputKey": null, "error": "…" }
  ],
  "nextCursor": "199"
}

Paginated by a stable rowIndex cursor; every row is accounted for exactly once. A single malformed row fails only itself — the rest still complete.

5. Download the bundle

curl -sS "https://api.lemtika.com/v1/render-batches/bat_5kQ2rL7vB4nC6dF8hX1yZ/bundle" \
  -H "Authorization: Bearer $LEMTIKA_API_KEY"
{ "url": "https://… signed", "expiresAt": "2026-06-23T00:00:00.000Z" }

Returns a short-lived signed URL for a zip of every succeeded row's output. Available once the batch is terminal — requesting it while still processing returns 422.

Replay & cancel

  • POST /v1/render-batches/{id}/replay — re-queues failed/unprocessed rows; succeeded rows are untouched and reproduce their original identity. Use it to resume a degraded batch or retry transient failures.
  • POST /v1/render-batches/{id}/cancel — terminates the batch; already-rendered outputs stay retrievable. Idempotent.
  • DELETE /v1/render-batches/{id} — permanently removes the batch and its outputs.