Documentation

Templates

Store HTML once and render it per request with data. Templates use Handlebars — loops, conditionals, and helpers all work.

Create a template

bashexample
curl -X POST https://api.pdfend.com/v1/templates \
  -H "Authorization: Bearer pk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "name": "invoice-v1",
    "html": "<h1>Invoice {{number}}</h1><p>Total: {{total}}</p>"
  }'

Render with data

jsonexample
{
  "template": "invoice-v1",
  "data": {
    "number": 1042,
    "total": "$249.00"
  }
}

Handlebars features

htmlexample
{{#each items}}
  <tr>
    <td>{{name}}</td>
    <td>{{quantity}}</td>
    <td>${{price}}</td>
  </tr>
{{/each}}

{{#if paid}}
  <p class="text-emerald-600">Paid in full</p>
{{else}}
  <p>Due on {{due_date}}</p>
{{/if}}

Versioning

Templates are referenced by slug (e.g. invoice-v1). To ship a new version, create a new template (e.g. invoice-v2) and migrate callers — the old one keeps working.