Developers

API reference

Public API endpoints, authentication, scopes, pagination, errors and the official SDKs.

12 min read11 sections
Code examples in
  • cURL
  • Node.js
  • Python
  • Go
On this page

Authentication and scopes

Every request sends a project API key in the ApiKey header. The key alone selects the workspace and project, so no workspace header is needed. Choose scopes on the API keys screen:

Scope Allows
template:read Account, template and render-log reads
template:render Everything above, plus queueing renders, status and download

Reference

Every call of the API, and what the SDK of your language names it.

Method and path Scope Purpose
GET /v1/me any Project, workspace and scopes of the key
GET /v1/templates read Templates, newest first; status, search, page, per_page
GET /v1/templates/{template_id} read Versions and the input of one version (version); UUID or slug
POST /v1/pdf/render render Queue a render
GET /v1/renders read Render log; status, template_id, started_after, started_before
GET /v1/renders/{render_id} render Render status and signed file_url
GET /v1/renders/{render_id}/download render PDF bytes of a successful render

Lists return data, page, per_page and has_more. per_page is 1–100 (default 30).

Call HTTP
account.get() GET /v1/me
templates.list(params) / templates.listAll(params) GET /v1/templates
templates.get(idOrSlug, { version }) GET /v1/templates/{template_id}
renders.create(request) POST /v1/pdf/render
renders.get(renderId) GET /v1/renders/{render_id}
renders.waitFor(renderId, options) / renders.createAndWait(request, options) polls GET /v1/renders/{render_id}
renders.list(params) / renders.listAll(params) GET /v1/renders
renders.download(status) signed file_url, else the row below
renders.download(renderId) GET /v1/renders/{render_id}/download
verifyWebhook({ payload, headers, secret }) renders.status webhook
Call HTTP
account.get() GET /v1/me
templates.list(...) / templates.list_all(...) GET /v1/templates
templates.get(id_or_slug, version=) GET /v1/templates/{template_id}
renders.create(template_id, version=, variant=, parameters=) POST /v1/pdf/render
renders.get(render_id) GET /v1/renders/{render_id}
renders.wait_for(render_id, ...) / renders.create_and_wait(...) polls GET /v1/renders/{render_id}
renders.list(...) / renders.list_all(...) GET /v1/renders
renders.download(status) signed file_url, else the row below
renders.download(render_id) GET /v1/renders/{render_id}/download
verify_webhook(payload=, headers=, secret=) renders.status webhook

AsyncTembuilder has the same calls, awaited.

Call HTTP
Account.Get(ctx) GET /v1/me
Templates.List(ctx, params) / Templates.All(ctx, params) GET /v1/templates
Templates.Get(ctx, idOrSlug, GetTemplateParams{Version}) GET /v1/templates/{template_id}
Renders.Create(ctx, RenderRequest) POST /v1/pdf/render
Renders.Get(ctx, renderID) GET /v1/renders/{render_id}
Renders.WaitFor(ctx, renderID, opts) / Renders.CreateAndWait(ctx, req, opts) polls GET /v1/renders/{render_id}
Renders.List(ctx, params) / Renders.All(ctx, params) GET /v1/renders
Renders.DownloadFrom(ctx, status) signed FileUrl, else the row below
Renders.Download(ctx, renderID) GET /v1/renders/{render_id}/download
VerifyWebhook(body, header, secret, VerifyOptions{}) renders.status webhook

Quickstart

Queue a render from a published template, wait for it and download the PDF. Choose your language at the top of the page. The Node.js, Python and Go SDKs are generated from the public OpenAPI contract and add retries, render polling, pagination and webhook verification.

# 1. Queue the render (202 returns render_id)
curl -X POST https://api.tembuilder.com/v1/pdf/render \
  -H "ApiKey: $TEMBUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template_id":"<template-uuid>","parameters":{}}'

# 2. Poll until status is success (a brief 404 right after 202 is normal)
curl https://api.tembuilder.com/v1/renders/<render-id> \
  -H "ApiKey: $TEMBUILDER_API_KEY"

# 3. Download the PDF from file_url in that response (no API key)
curl -o output.pdf "<file_url>"
npm install @tembuilderlabs/sdk
import { writeFile } from 'node:fs/promises'
import { Tembuilder } from '@tembuilderlabs/sdk'

const tembuilder = new Tembuilder() // reads TEMBUILDER_API_KEY
const template = await tembuilder.templates.get('invoice')
const status = await tembuilder.renders.createAndWait({
  template_id: template.id,
  parameters: template.input.example_parameters,
})
const pdf = await tembuilder.renders.download(status)
await writeFile(pdf.filename ?? 'output.pdf', pdf.bytes)
pip install tembuilder
from pathlib import Path

from tembuilder import Tembuilder

with Tembuilder() as client:  # reads TEMBUILDER_API_KEY
    template = client.templates.get("invoice")
    status = client.renders.create_and_wait(
        template.id, parameters=template.input_.example_parameters.to_dict()
    )
    pdf = client.renders.download(status)
    Path(pdf.filename or "output.pdf").write_bytes(pdf.content)
go get github.com/tembuilderlabs/tembuilder-sdk/go
client, err := tembuilder.New() // reads TEMBUILDER_API_KEY
if err != nil {
	log.Fatal(err)
}
template, err := client.Templates.Get(ctx, "invoice", tembuilder.GetTemplateParams{})
if err != nil {
	log.Fatal(err)
}
parameters := template.Input.ExampleParameters
status, err := client.Renders.CreateAndWait(ctx, tembuilder.RenderRequest{
	TemplateId: template.Id,
	Parameters: &parameters,
}, tembuilder.WaitOptions{})
if err != nil {
	log.Fatal(err)
}
pdf, err := client.Renders.DownloadFrom(ctx, status)
if err != nil {
	log.Fatal(err)
}
err = os.WriteFile(pdf.Filename, pdf.Content, 0o644)

Queue now, check later

No request waits for a render to finish. In a web request or a job queue, queue the render, store render_id and answer at once; read the status whenever it suits you. Right after queueing, the status can return 404 for a moment: treat it as pending.

# In your request handler: queue the render, store render_id, answer at once.
curl -X POST https://api.tembuilder.com/v1/pdf/render \
  -H "ApiKey: $TEMBUILDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"template_id":"<template-uuid>","parameters":{"customer":"Acme Corp"}}'
# 202 {"render_id":"<render-id>","status":"queued","status_url":"/v1/renders/<render-id>"}

# Later (a job, a "check status" button): read the status.
curl https://api.tembuilder.com/v1/renders/<render-id> \
  -H "ApiKey: $TEMBUILDER_API_KEY"
# pending: check again later
# success: download file_url (see "Download the PDF")
# failed or quota_exceeded: read error_message

# Every render still running:
curl "https://api.tembuilder.com/v1/renders?status=pending" \
  -H "ApiKey: $TEMBUILDER_API_KEY"
// In your request handler: queue the render and answer at once.
const { render_id } = await tembuilder.renders.create({
  template_id: template.id,
  parameters: { customer: 'Acme Corp' },
})
await db.orders.update(orderId, { renderId: render_id }) // keep the id

// Later (a job, a "check status" button): read the status.
const status = await tembuilder.renders.get(render_id)
if (status.status === 'success') {
  const pdf = await tembuilder.renders.download(status)
  await writeFile(pdf.filename ?? 'output.pdf', pdf.bytes)
} else if (status.status !== 'pending') {
  console.error(status.status, status.error_message) // failed or quota_exceeded
}

// Or wait for a render you already queued (polls every second):
const done = await tembuilder.renders.waitFor(render_id, { timeoutMs: 60_000 })

// Every render still running:
const running = await tembuilder.renders.list({ status: 'pending' })
# In your request handler: queue the render and answer at once.
queued = client.renders.create(template.id, parameters={"customer": "Acme Corp"})
order.render_id = str(queued.render_id)  # keep the id
order.save()

# Later (a Celery task, a "check status" button): read the status.
status = client.renders.get(order.render_id)
if status.status == "success":
    pdf = client.renders.download(status)
    Path(pdf.filename or "output.pdf").write_bytes(pdf.content)
elif status.status != "pending":
    print(status.status, status.error_message)  # failed or quota_exceeded

# Or wait for a render you already queued (polls every second):
done = client.renders.wait_for(order.render_id, timeout=60)

# Every render still running:
running = client.renders.list(status="pending")
// In your HTTP handler: queue the render and answer at once.
queued, err := client.Renders.Create(ctx, tembuilder.RenderRequest{
	TemplateId: template.Id,
	Parameters: &parameters,
})
if err != nil {
	return err
}
renderID := queued.RenderId.String() // keep the id, e.g. on the order row

// Later (a job, a "check status" button): read the status.
status, err := client.Renders.Get(ctx, renderID)
if err != nil {
	return err
}
switch status.Status {
case tembuilder.RenderStatusPending:
	// not ready yet: check again later
case tembuilder.RenderStatusSuccess:
	file, err := client.Renders.DownloadFrom(ctx, status)
	if err != nil {
		return err
	}
	return os.WriteFile(file.Filename, file.Content, 0o644)
default: // failed or quota_exceeded
	return fmt.Errorf("render %s", status.Status)
}

// Or wait for a render you already queued (polls every second):
done, err := client.Renders.WaitFor(ctx, renderID, tembuilder.WaitOptions{Timeout: time.Minute})

// Every render still running:
pending := tembuilder.ListRendersParamsStatus("pending")
running, err := client.Renders.List(ctx, tembuilder.ListRendersParams{Status: &pending})

React to the webhook

Add an endpoint under Webhooks in the project sidebar. When a render ends, Tembuilder POSTs a renders.status event to it. Verify the Tembuilder-Signature header against the raw body (webhook security), ignore a repeated Tembuilder-Delivery-Id, then read the render’s status for a fresh file_url.

{"api_version":"2026-09-12","type":"renders.status","occurred_at":"2026-11-20T08:30:01Z","data":{"render_id":"<render-uuid>","status":"success","template_id":"<template-uuid>","template_version":3,"duration_ms":1200,"links":{"status_url":"/v1/renders/<render-uuid>"},"output":{"download_url":"/v1/renders/<render-uuid>/download","content_type":"application/pdf","size_bytes":48213}}}
import express from 'express'
import { verifyWebhook } from '@tembuilderlabs/sdk'

// Raw body: the signature covers the exact bytes Tembuilder sent.
app.post('/webhooks/tembuilder', express.raw({ type: 'application/json' }), async (req, res) => {
  const event = verifyWebhook({ payload: req.body, headers: req.headers, secret: process.env.TEMBUILDER_WEBHOOK_SECRET })
  if (event.type === 'renders.status' && event.data.status === 'success') {
    const status = await tembuilder.renders.get(event.data.render_id)
    const pdf = await tembuilder.renders.download(status)
    // store pdf.bytes
  }
  res.sendStatus(204)
})
from tembuilder import verify_webhook

# In your web framework's view: pass the raw request body bytes and headers.
event = verify_webhook(payload=request_body, headers=request_headers, secret=WEBHOOK_SECRET)
if event["type"] == "renders.status" and event["data"]["status"] == "success":
    status = client.renders.get(event["data"]["render_id"])
    pdf = client.renders.download(status)
    # store pdf.content
http.HandleFunc("/webhooks/tembuilder", func(w http.ResponseWriter, r *http.Request) {
	body, _ := io.ReadAll(r.Body) // the signature covers the raw bytes
	event, err := tembuilder.VerifyWebhook(body, r.Header, secret, tembuilder.VerifyOptions{})
	if err != nil {
		http.Error(w, "invalid signature", http.StatusBadRequest)
		return
	}
	var data tembuilder.RenderStatusEventData
	if event.Type == "renders.status" && json.Unmarshal(event.Data, &data) == nil && data.Status == tembuilder.RenderStatusSuccess {
		if status, err := client.Renders.Get(r.Context(), data.RenderId.String()); err == nil {
			file, _ := client.Renders.DownloadFrom(r.Context(), status)
			_ = file // store file.Content
		}
	}
	w.WriteHeader(http.StatusNoContent)
})

Download the PDF

A successful status carries file_url, a signed link that serves the PDF straight from storage for 15 minutes. Send no API key to it; once it expires, read the status again for a new one. GET /v1/renders/{render_id}/download streams the same file through the API with your key. The SDKs take the status and fall back to that endpoint on their own.

# file_url is signed: send no ApiKey header. It works for 15 minutes.
status=$(curl -s https://api.tembuilder.com/v1/renders/<render-id> \
  -H "ApiKey: $TEMBUILDER_API_KEY")
curl -o output.pdf "$(echo "$status" | jq -r .file_url)"

# Or stream the same file through the API, with your key:
curl -o output.pdf https://api.tembuilder.com/v1/renders/<render-id>/download \
  -H "ApiKey: $TEMBUILDER_API_KEY"
// With a status (from get, waitFor or createAndWait): straight from storage,
// no API key sent; falls back to the API if the link expired or failed.
const pdf = await tembuilder.renders.download(status)
await writeFile(pdf.filename ?? 'output.pdf', pdf.bytes)

// With only an id: through GET /v1/renders/{render_id}/download.
const sameFile = await tembuilder.renders.download(renderId)
# With a status (from get, wait_for or create_and_wait): straight from storage,
# no API key sent; falls back to the API if the link expired or failed.
pdf = client.renders.download(status)
Path(pdf.filename or "output.pdf").write_bytes(pdf.content)

# With only an id: through GET /v1/renders/{render_id}/download.
same_file = client.renders.download(render_id)
// With a status (from Get, WaitFor or CreateAndWait): straight from storage,
// no API key sent; falls back to the API if the link expired or failed.
file, err := client.Renders.DownloadFrom(ctx, status)
if err != nil {
	return err
}
err = os.WriteFile(file.Filename, file.Content, 0o644)

// With only an id: through GET /v1/renders/{render_id}/download.
sameFile, err := client.Renders.Download(ctx, renderID)

Template input

GET /v1/templates/{template_id} returns published_versions and an input object: variants, the declared parameters, a JSON Schema in parameters_schema and a ready-to-edit example_parameters built from defaults.

Search the templates and read one version’s input:

# Published templates matching a search, newest first.
curl "https://api.tembuilder.com/v1/templates?status=published&search=invoice" \
  -H "ApiKey: $TEMBUILDER_API_KEY"

# One template (UUID or slug) and the input of version 3.
curl "https://api.tembuilder.com/v1/templates/invoice?version=3" \
  -H "ApiKey: $TEMBUILDER_API_KEY"
for await (const template of tembuilder.templates.listAll({ status: 'published', search: 'invoice' })) {
  console.log(template.slug, template.published_versions)
}

const detail = await tembuilder.templates.get('invoice', { version: 3 })
console.log(detail.input.parameters_schema, detail.input.example_parameters)
for template in client.templates.list_all(status="published", search="invoice"):
    print(template.slug, template.published_versions)

detail = client.templates.get("invoice", version=3)
print(detail.input_.parameters_schema, detail.input_.example_parameters.to_dict())
for template, err := range client.Templates.All(ctx, tembuilder.ListTemplatesParams{}) {
	if err != nil {
		return err
	}
	fmt.Println(template.Slug, template.PublishedVersions)
}

detail, err := client.Templates.Get(ctx, "invoice", tembuilder.GetTemplateParams{Version: tembuilder.Ptr(int32(3))})

Parameter checks

parameters are checked against the version before the render is queued, so a mistake costs no quota and never reaches the PDF:

  • A required parameter must be present and not null; an optional one may be omitted, empty or null.
  • Every value must have its declared type at any depth: text is a string, number a number, boolean true or false, array a list of its item type, object an object of its fields.
  • Parameters the version does not declare are ignored and dropped, so one payload can serve several templates.

A failed check returns 400 COMMON_VALIDATION with one details line per offending value; the SDKs raise it as APIError:

{"code":"COMMON_VALIDATION","description":"parameters do not match the template","details":["parameters.lines[0].qty: expected number, but got string","parameters: missing properties: 'customer'"]}

Render log

Lists renders newest first, filtered by status, template_id, started_after and started_before; status=pending returns the renders still running.

curl "https://api.tembuilder.com/v1/renders?status=failed&template_id=<template-uuid>&started_after=2026-11-01T00:00:00Z&per_page=50" \
  -H "ApiKey: $TEMBUILDER_API_KEY"
for await (const render of tembuilder.renders.listAll({ status: 'failed', template_id: template.id })) {
  console.log(render.short_id, render.error_message)
}
for render in client.renders.list_all(status="failed", template_id=template.id):
    print(render.short_id, render.error_message)
failed := tembuilder.ListRendersParamsStatus("failed")
for render, err := range client.Renders.All(ctx, tembuilder.ListRendersParams{Status: &failed, TemplateId: &template.Id}) {
	if err != nil {
		return err
	}
	if render.ErrorMessage != nil {
		fmt.Println(render.ShortId, *render.ErrorMessage)
	}
}

POST /v1/pdf/render

JSON field Meaning
template_id Required template UUID, not a slug
version Published version; omitted selects the current version
variant Optional variant name
parameters Input matching parameters_schema; checked before queueing

GET /v1/renders/{render_id}

pending is processing; success, failed and quota_exceeded are terminal.

{"render_id":"<render-uuid>","status":"success","duration_ms":1200,"download_url":"/v1/renders/<render-uuid>/download","file_url":"https://<storage-host>/<render-uuid>.pdf?X-Amz-Expires=900&X-Amz-Signature=<signature>","file_url_expires_at":"2026-05-01T10:15:00Z"}

Once a render succeeds, file_url is a signed link that serves the PDF directly from storage for 15 minutes (file_url_expires_at). Fetch it without the ApiKey header — the link carries its own signature — and call this endpoint again for a fresh link after it expires. download_url serves the same file through the API. No request waits for a render to finish: keep the render_id, then poll this endpoint or react to the renders.status webhook.

Errors and retries

Errors use code, description and details. Branch on code. Fix 4xx requests before retrying. Retry GETs after 429, 502, 503 or 504; retry a render POST only after 429 or 503 (it was not accepted), honouring Retry-After. The SDKs apply exactly these rules.

{"code":"RENDER_TEMPLATE_VERSION_NOT_PUBLISHED","description":"template version is not published","details":[]}
curl -i https://api.tembuilder.com/v1/templates/does-not-exist \
  -H "ApiKey: $TEMBUILDER_API_KEY"
# HTTP/2 404
# {"code":"TEMPLATE_NOT_FOUND","description":"template not found","details":[]}
import { APIError, RenderFailedError, RenderTimeoutError } from '@tembuilderlabs/sdk'

try {
  await tembuilder.renders.createAndWait({ template_id: template.id })
} catch (error) {
  if (error instanceof APIError) console.error(error.status, error.code, error.details)
  else if (error instanceof RenderFailedError) console.error(error.render.status, error.render.error_message)
  else if (error instanceof RenderTimeoutError) console.error('still running', error.renderId)
  else throw error // ConnectionError, TimeoutError: no response after the retries
}
from tembuilder import APIError, RenderFailedError, RenderTimeoutError

try:
    client.renders.create_and_wait(template.id)
except APIError as error:
    print(error.status, error.code, error.details)
except RenderFailedError as error:
    print(error.render.status, error.render.error_message)
except RenderTimeoutError as error:
    print("still running", error.render_id)
# ConnectionError, TimeoutError: no response after the retries
_, err := client.Renders.CreateAndWait(ctx, request, tembuilder.WaitOptions{})
var apiErr *tembuilder.APIError
var failed *tembuilder.RenderFailedError
var timeout *tembuilder.RenderTimeoutError
switch {
case errors.As(err, &apiErr):
	log.Println(apiErr.StatusCode, apiErr.Code, apiErr.Details)
case errors.As(err, &failed):
	log.Println("render ended", failed.Render.Status)
case errors.As(err, &timeout):
	log.Println("still running", timeout.RenderID)
}
// *ConnectionError, *TimeoutError: no response after the retries

Search documentation