Create a template

Create a template

POST/api/v1/email/templates

POST /email/templates
curl -X POST 'https://www.unitpost.com/api/v1/email/templates' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "name": "Welcome",
    "subject": "Welcome!",
    "html": "<h1>Hi Mike</h1>"
  }'
Response · 201
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "html": "string",
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Create a reusable email template from html (and optional subject). {{variables}} in the HTML fill per-recipient at send time. The body is stored in code mode so you can open it in the dashboard. Once created, send with it via Send or schedule an email, and iterate with Update a template. Requires the templates:write capability.

Request body5 fields
FieldTypeDescription
namerequiredstring—
subjectstring—
htmlstringThe email body as HTML (compose with @unitpost/email `render()` or any HTML; `{{variables}}` fill at send). Pass exactly one of `html` or `text`.
textstringSimple email body instead of `html` — plain text exactly as you'd type it into Gmail: lines, a blank line between paragraphs, '- ' or '1. ' list items, and inline <b>, <i>, <u>, <a href="…"> for emphasis and links. No Markdown (it stays literal). Sent as a bare mail-client fragment with no layout or colours; marketing templates get a one-line unsubscribe footer at send time. Max 20,000 characters. Pass exactly one of `html` or `text`.
categoryenumtransactional | marketing—
Response · 201 fields8 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredobject—
statusrequiredenumdraft | published—
htmlobject—
created_atrequiredstring—
updated_atrequiredstring—
201401422

Search docs and guides

Search the docs and product guides.