Templates & variables

Reference a saved template and pass per-recipient data.

Rather than inlining HTML on every send, save a template once and reference it by ID. Pass `template.variables` and any {{variable}} in the template is substituted at send time.

cURL
curl https://www.unitpost.com/api/v1/email \
  -H "Authorization: Bearer $UNITPOST_API_KEY" \
  -H "Content-Type: application/json" \
  -H "User-Agent: my-app/1.0" \
  -d '{
    "from": "you@yourdomain.com",
    "to": "customer@acme.com",
    "template": {
      "id": "tmpl_123",
       "variables": { "plan": "Pro" }
    }
  }'

When you send to a known contact, that contact's custom fields merge into the variables automatically — so a template can reference {{first_name}} without you re-sending it on every request.

Drafts can't be sent

A template must be published before the API will send it. Referencing a draft returns a 422 with code template_not_published. Publish it in the editor first.

Author templates in the visual editor, or in your app with `import { Heading, render } from "@unitpost/email/react"` and POST `{ name, html: render(<Email />), subject }`. Manage them under Templates. Every block and layout is documented at /components.