Templates

List templates

GET/api/v1/email/templates

GET /email/templates
curl -X GET 'https://www.unitpost.com/api/v1/email/templates' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'
Response · 200
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "template",
      "id": "id_123",
      "name": "Example",
      "subject": "Welcome to Acme",
      "status": "draft",
      "editor": "simple",
      "kind": "simple",
      "preview_text": "string",
      "category": "transactional",
      "html": "string",
      "tsx": "string",
      "text": "string",
      "warnings": [
        "string"
      ],
      "created_at": "2026-01-01T00:00:00.000Z",
      "updated_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}

Retrieve a list of your email templates, cursor-paginated. Each row says which editor it's authored in (design, simple or code). List rows omit html and tsx to keep responses small — fetch a single template with Retrieve a template to get it. Reference a template's id when sending with Send or schedule an email or when creating a campaign. Requires the templates:read capability.

Parameters3 fields
FieldTypeDescription
limitinteger · queryMax rows to return (default 20, max 100).
afterstring · queryReturn rows after this id (forward paging).
beforestring · queryReturn rows before this id (backward paging).
Response · 200 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
200401422

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",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Create a reusable email template from ONE body field, which picks its editor in the dashboard. tsx (the default for anything branded) makes a **Design** template from @unitpost/email components; wrap them in one <Email …> element, or pass theme, to set the page style, so one call makes the finished, branded template. text makes a **Simple** email: a plain, personal note typed like Gmail. html makes a **Code** template: your raw HTML, kept as-is. {{variables}} fill per-recipient at send time. Anything that changed that you didn't write comes back in warnings. Once created, send with it via Send or schedule an email, and iterate with Update a template. Requires the templates:write capability.

Request body8 fields
FieldTypeDescription
namerequiredstring—
subjectstring—
tsxstringA Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>, and <br /> for a line break (a new line in the markup is only a space); no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`.
htmlstringA Code email body (editor `code`): raw HTML kept as-is in one HTML block — the Design editor can show it but not edit it piece by piece. Use it only when the user asks for HTML or brings their own; for a branded email send `tsx` instead. Write simple, email-safe HTML: tables for layout, inline styles, hosted https images. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`.
textstringA Simple email body (editor `simple`) — only when the user wants a plain, personal note that reads like it was typed in Gmail. Plain text exactly as you'd type it into Gmail: lines, a blank line between paragraphs (the only spacing), '- ' or '1. ' list items, inline <b>, <i>, <u>, <s>, <a href="…">, <br>, and <span style="color:#hex; background-color:#hex; font-size:13px|18px|24px; font-family:Georgia"> for colour, highlight, size and font; <div style="text-align:center">…</div> around one line to centre it; <img src="/img/{id}" alt="…" width="400"> alone on a line for an image; {{variables}}. Not supported (removed): headings, layout/sections/buttons, block HTML tags (p, div, table, ul), other CSS, and Markdown (stays literal). Sent as a bare mail-client fragment with no layout; marketing templates get a one-line unsubscribe footer at send time. Max 20,000 characters. Pass exactly one of `tsx`, `html` or `text`.
themeobjectPage-level look of a Design template (`tsx`) — the same settings as the `<Email>` element's attributes. Keys you leave out keep the template's current value (a new template starts from the Unitpost brand theme). Not accepted with `html` (style the HTML itself) or `text` (Simple emails use the reader's own style).
preview_textstringInbox preview text: the snippet shown after the subject. A short line that complements the subject. Wins over a `preview-text` on <Email>.
categoryenumtransactional | marketing—
Response · 201 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
201401422

Retrieve a template

GET/api/v1/email/templates/{id}

GET /email/templates/{id}
curl -X GET 'https://www.unitpost.com/api/v1/email/templates/tmpl_123' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'
Response · 200
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Retrieve a single template by id, including the rendered html, for a Design template its tsx with the <Email> theme element, and for a Simple one its text (List templates omits both). Use this to read the body in its own editor, then save changes with Update a template. Requires the templates:read capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Response · 200 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
200401404

Update a template

PATCH/api/v1/email/templates/{id}

PATCH /email/templates/{id}
curl -X PATCH 'https://www.unitpost.com/api/v1/email/templates/tmpl_123' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "subject": "Welcome aboard!"
  }'
Response · 200
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Update a template's metadata and/or body. Changes take effect for future sends only — emails already sent or queued keep the body they were rendered with. Send the body in the template's own editor (tsx for design, text for simple, html for code); another body field switches the editor. editor alone converts the current body (lossy steps are listed in warnings), and theme alone restyles a Design template, and category switches it between marketing and transactional on any editor. A change to its body, subject or category, or an unpublish, is refused with 409 while a live campaign renders it (see Get a template's usage). Read the current body first with Retrieve a template. Requires the templates:write capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Request body10 fields
FieldTypeDescription
namestring—
subjectstring | null—
statusenumdraft | published—
tsxstringA Design email body (editor `design`) — the DEFAULT for anything branded: newsletters, announcements, promos, welcome and product emails, receipts. @unitpost/email component TSX: <Section>, <Row>/<Column>, <Heading>, <Text>, <Button href>, <Image src alt>, <List>, <Divider>, <Spacer>, <Link>, <Code> (props and ready-made layout bands: the `design_library` MCP tool or unitpost.com/components). Wrap the blocks in ONE <Email …> element to set the page in the same call: background-color, body-color, content-width, body-padding, body-radius, body-border-width/-style/-color, font-family, text-color, link-color, preview-text, category. <Section> holds leaf blocks and nested <Section>s (never a <Row>); <Row> holds only <Column>s. Inline <strong>/<em>/<a href> inside <Text>, and <br /> for a line break (a new line in the markup is only a space); no Markdown; no <html>/<body>. Images: hosted https URLs or `/img/{id}` library images only. Don't write the unsubscribe / postal-address footer — marketing templates get it at send. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`.
htmlstringA Code email body (editor `code`): raw HTML kept as-is in one HTML block — the Design editor can show it but not edit it piece by piece. Use it only when the user asks for HTML or brings their own; for a branded email send `tsx` instead. Write simple, email-safe HTML: tables for layout, inline styles, hosted https images. `{{variables}}` fill at send. Pass exactly one of `tsx`, `html` or `text`.
textstringA Simple email body (editor `simple`) — only when the user wants a plain, personal note that reads like it was typed in Gmail. Plain text exactly as you'd type it into Gmail: lines, a blank line between paragraphs (the only spacing), '- ' or '1. ' list items, inline <b>, <i>, <u>, <s>, <a href="…">, <br>, and <span style="color:#hex; background-color:#hex; font-size:13px|18px|24px; font-family:Georgia"> for colour, highlight, size and font; <div style="text-align:center">…</div> around one line to centre it; <img src="/img/{id}" alt="…" width="400"> alone on a line for an image; {{variables}}. Not supported (removed): headings, layout/sections/buttons, block HTML tags (p, div, table, ul), other CSS, and Markdown (stays literal). Sent as a bare mail-client fragment with no layout; marketing templates get a one-line unsubscribe footer at send time. Max 20,000 characters. Pass exactly one of `tsx`, `html` or `text`.
themeobjectPage-level look of a Design template (`tsx`) — the same settings as the `<Email>` element's attributes. Keys you leave out keep the template's current value (a new template starts from the Unitpost brand theme). Not accepted with `html` (style the HTML itself) or `text` (Simple emails use the reader's own style).
preview_textstringInbox preview text: the snippet shown after the subject. A short line that complements the subject. Wins over a `preview-text` on <Email>.
categoryenumtransactional | marketing`marketing` or `transactional`, on any editor. A campaign sends only a `marketing` template; a change is a content edit, so it is refused while a live campaign uses the template. With `tsx` it wins over `<Email category>`.
editorenumsimple | design | codeConvert the template to this editor. Alone (no body field) it converts the CURRENT body: simple → design keeps every line; design → code renders it to HTML (looks the same, no longer editable block by block); code → design rebuilds components where the HTML maps and keeps the rest as HTML; design or code → simple flattens to plain lines. What a conversion changes comes back in `warnings`. With a body field it must name that field's editor (`tsx` = design, `html` = code, `text` = simple). Only when the user asked to switch.
Response · 200 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
200401404409422

Delete a template

DELETE/api/v1/email/templates/{id}

DELETE /email/templates/{id}
curl -X DELETE 'https://www.unitpost.com/api/v1/email/templates/tmpl_123' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'

Permanently delete a template. Emails already sent with it are unaffected, but future sends that reference its id will fail — update any code or campaigns that still point at it first (see List campaigns or Get a template's usage). A template a campaign or live automation still uses, or with queued sends, is a 409. Requires the templates:write capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
204401404409

Render a template

POST/api/v1/email/templates/{id}/render

POST /email/templates/{id}/render
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/render' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 200
{
  "object": "template_render",
  "subject": "Welcome to Acme",
  "html": "string",
  "text": "string",
  "missing_variables": [
    "string"
  ]
}

The subject, HTML and text a send of this template would carry, with your footer and branding, without sending or storing anything. Pass variables as a send's template.variables, and contact_id to fill contact fields from that contact. missing_variables lists the variables left without a value: they render as a literal {{token}} here, and a real send refuses them. {{unsubscribe_url}} renders a preview link. A POST only because it takes a body; any other key is a 422. Requires the templates:read capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Request body3 fields
FieldTypeDescription
variablesobjectValues for the template's {{variables}}, as a send's `template.variables`. One with no value stays a literal {{token}} and is listed in `missing_variables`.
subjectstringRender this subject instead of the template's.
contact_idstringFill contact fields ({{first_name}}, custom fields) from this contact (`con_…`), as a send to them would.
Response · 200 fields5 fields
FieldTypeDescription
objectrequiredstring—
subjectrequiredstring—
htmlrequiredstringThe HTML a send would carry, footer and branding included. `{{unsubscribe_url}}` is a preview link.
textrequiredstring—
missing_variablesrequiredstring[]Variables with no value: they render as a literal {{token}}, and a real send would refuse them.
200400401403404422429

Send a test of a template

POST/api/v1/email/templates/{id}/test-send

POST /email/templates/{id}/test-send
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/test-send' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 200
{
  "object": "template_test_send",
  "email_id": "email_123",
  "status": "queued",
  "dispatched": false,
  "unresolved_variables": [
    "string"
  ]
}

Render the template with sample variables and send ONE test email to to, exactly as a recipient would get it (footer included). With a verified sending domain it comes from test@<your domain> and may go to anyone; with none it comes from Unitpost's shared test address and only to your workspace's members (403 forbidden otherwise). unresolved_variables lists the ones with no sample value. Rate limited per workspace. Requires the emails:send capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Request body3 fields
FieldTypeDescription
torequiredstring—
subjectstring—
variablesobject—
Response · 200 fields5 fields
FieldTypeDescription
objectrequiredenumtemplate_test_send—
email_idrequiredstringThe test email (`email_…`); retrieve it like any email.
statusrequiredstringThe test email's status, usually `queued`.
dispatchedrequiredbooleanFalse when this environment records sends without delivering them.
unresolved_variablesrequiredstring[]Variables with no sample value, sent as a literal `{{name}}`.
200401403404422429502

Duplicate a template

POST/api/v1/email/templates/{id}/duplicate

POST /email/templates/{id}/duplicate
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/duplicate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 201
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Copy a template into a new draft, as the dashboard's Duplicate does: its name (with " (copy)", or your name), subject, editor and body carry over; its status, versions and usage don't. Pass an Idempotency-Key so a retry returns the same copy instead of making a second one. Requires the templates:write capability.

Parameters2 fields
FieldTypeDescription
idrequiredstring · path—
Idempotency-Keystring · headerAny unique string (1–256 characters, e.g. a UUID). Retrying with the same key and the same body within 24 hours returns the first result instead of sending again; the same key with a different body is `409 invalid_idempotent_request`, and one still in flight is `409 concurrent_idempotent_requests`.
Request body1 field
FieldTypeDescription
namestringThe copy's name. Default: the original's with " (copy)".
Response · 201 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
201400401403404409422

Add a template from the gallery

POST/api/v1/email/templates/from-library

POST /email/templates/from-library
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/from-library' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{
    "slug": "welcome"
  }'
Response · 201
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Add one of the gallery's ready-made emails (unitpost.com/templates) to your workspace as a draft Design template, as the gallery's "Use this template" does. slug names it; the ones marked for paid plans answer 403 limit_reached on the free plan. Edit it with Update a template. Pass an Idempotency-Key so a retry returns the same template. Requires the templates:write capability.

Parameters1 field
FieldTypeDescription
Idempotency-Keystring · headerAny unique string (1–256 characters, e.g. a UUID). Retrying with the same key and the same body within 24 hours returns the first result instead of sending again; the same key with a different body is `409 invalid_idempotent_request`, and one still in flight is `409 concurrent_idempotent_requests`.
Request body2 fields
FieldTypeDescription
slugrequiredstringThe gallery email to add (unitpost.com/templates): `welcome`, `email-verification`, `one-time-code`, `magic-link`, `password-reset`, `password-changed`, `security-alert`, `team-invite`, `receipt`, `invoice`, `payment-failed`, `subscription-renewal`, `trial-ending`, `usage-alert`, `subscription-cancelled`, `order-confirmation`, `shipping-confirmation`, `delivery-update`, `booking-confirmation`, `appointment-reminder`, `review-request`, `comment-mention`, `support-reply`, `weekly-report`, `document-to-sign`, `export-ready`, `newsletter`, `daily-brief`, `link-roundup`, `content-digest`, `essay-letter`, `founder-letter`, `community-update`, `monthly-product-update`, `july-newsletter`, `product-announcement`, `product-launch-dark`, `app-release`, `pricing-update`, `waitlist-invite`, `flash-sale`, `discount-offer`, `new-collection`, `back-in-stock`, `abandoned-cart`, `birthday-reward`, `holiday-greeting`, `new-listings`, `seasonal-menu`, `rewards-poster`, `travel-guide`, `event-invite`, `conference-invite`, `webinar-recap`, `webinar-invite`, `onboarding-tips`, `re-engagement`, `feedback-survey`, `referral`, `case-study`, `nonprofit-impact`.
namestringThe template's name. Default: the gallery email's.
Response · 201 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
201400401403409422

Get a template's usage

GET/api/v1/email/templates/{id}/usage

GET /email/templates/{id}/usage
curl -X GET 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/usage' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'
Response · 200
{
  "object": "template_usage",
  "template_id": "template_123",
  "campaigns": [
    {
      "id": "id_123",
      "name": "Example",
      "status": "draft",
      "created_at": "2026-01-01T00:00:00.000Z"
    }
  ],
  "campaign_count": 1,
  "sent_count": 1,
  "live_campaigns": [
    {
      "id": "id_123",
      "name": "Example",
      "status": "draft"
    }
  ],
  "live_automations": [
    {
      "id": "id_123",
      "name": "Example",
      "status": "active"
    }
  ],
  "pending_sends": 0,
  "system_locked": false,
  "can_edit_content": false,
  "content_blocked_reason": "string",
  "can_unpublish": false,
  "unpublish_blocked_reason": "string"
}

What uses a template, and whether a change would be accepted now: the campaigns that reference it, its live campaigns and automations, queued sends, and can_edit_content / can_unpublish with the reason when not. Read it before an edit or delete: a content edit is refused while a live campaign renders the template, and a delete while any campaign uses it. Requires the templates:read capability.

Parameters1 field
FieldTypeDescription
idrequiredstring · path—
Response · 200 fields13 fields
FieldTypeDescription
objectrequiredstring—
template_idrequiredstring—
campaignsrequiredobject[]The campaigns that use it, any status, newest first: the newest 25 (`campaign_count` says how many in all).
campaign_countrequiredintegerHow many campaigns use it in all.
sent_countrequiredintegerEmails sent from it, all time.
live_campaignsrequiredobject[]Scheduled, sending or paused campaigns: they render its current content when they send, so its content is locked.
live_automationsrequiredobject[]Active or paused automations whose published version sends it: it can't be unpublished or deleted.
pending_sendsrequiredintegerQueued or scheduled single sends that render it when they go out.
system_lockedrequiredbooleanA template behind Unitpost's own emails: read-only.
can_edit_contentrequiredbooleanWhether an update to its body, subject or category would be accepted now.
content_blocked_reasonrequiredstring | null—
can_unpublishrequiredbooleanWhether `status: "draft"` would be accepted now.
unpublish_blocked_reasonrequiredstring | null—
200401403404422

List a template's versions

GET/api/v1/email/templates/{id}/versions

GET /email/templates/{id}/versions
curl -X GET 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/versions' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'
Response · 200
{
  "object": "list",
  "has_more": false,
  "data": [
    {
      "object": "template_version",
      "version": 0,
      "subject": "Welcome to Acme",
      "created_at": "2026-01-01T00:00:00.000Z"
    }
  ]
}

A template's history, newest first: a version is added on every publish and on every content save while it's published. Put one back with Restore a template version. Page with the last row's version as after. Requires the templates:read capability.

Parameters3 fields
FieldTypeDescription
idrequiredstring · path—
limitinteger · query1–100 (default 20).
afterinteger · queryThe last `version` of the previous page.
Response · 200 fields4 fields
FieldTypeDescription
objectrequiredstring—
versionrequiredinteger1 is the first publish; every publish, and every content save while published, adds one.
subjectrequiredstring | null—
created_atrequiredstring—
200401403404422

Restore a template version

POST/api/v1/email/templates/{id}/versions/{version}/restore

POST /email/templates/{id}/versions/{version}/restore
curl -X POST 'https://www.unitpost.com/api/v1/email/templates/tmpl_123/versions/3/restore' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0'
Response · 200
{
  "object": "template",
  "id": "id_123",
  "name": "Example",
  "subject": "Welcome to Acme",
  "status": "draft",
  "editor": "simple",
  "kind": "simple",
  "preview_text": "string",
  "category": "transactional",
  "html": "string",
  "tsx": "string",
  "text": "string",
  "warnings": [
    "string"
  ],
  "created_at": "2026-01-01T00:00:00.000Z",
  "updated_at": "2026-01-01T00:00:00.000Z"
}

Put a version's subject and body back, as the dashboard's version restore does. It is an update, so the update rules apply: a system template, or one a live campaign renders, is a 409 naming why (Get a template's usage says so up front). On a published template the restore adds a new version; history is never rewritten. Takes no body. Requires the templates:write capability.

Parameters2 fields
FieldTypeDescription
idrequiredstring · path—
versionrequiredinteger · pathA `version` from the template's history.
Response · 200 fields15 fields
FieldTypeDescription
objectrequiredstring—
idrequiredstring—
namerequiredstring—
subjectrequiredstring | null—
statusrequiredenumdraft | published—
editorenumsimple | design | codeWhich editor this template is authored in — and so which body field updates it. `design`: built from @unitpost/email components (the dashboard's Design tab) — update with `tsx`. `simple`: a plain, personal Gmail-style email (the Simple tab) — update with `text`. `code`: raw HTML (the Code tab) — update with `html`. Keep the editor unless the user asked to switch; to switch, send the other body field or `editor` alone to convert the current body.
kindrequiredenumsimple | designedThe coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`.
preview_textstringInbox preview text: the snippet most inboxes show after the subject. Empty when unset.
categoryenumtransactional | marketing`marketing` (a campaign can send it; it gets the unsubscribe footer at send) or `transactional` (receipts, sign-in codes, notifications: no footer, and campaigns refuse it). Change it with `category` on an update.
htmlstring | null—
tsxstring | nullA `design` template's body as @unitpost/email component TSX, wrapped in the `<Email …>` element that carries its theme, preview text and category — edit it and send it back as `tsx`. Null for `simple` and `code` templates. Present on single reads; omitted from list rows.
textstring | nullA `simple` template's body in the Simple `text` format: edit it and send it back as `text`. Null for `design` and `code` templates, and for a Simple email the format can't carry whole (an indented line): change that one in the dashboard, or send a whole new `text`. Present on single reads; omitted from list rows.
warningsstring[]Create or update only: what changed that you didn't write, in plain words — markup the Simple format removed from `text`, `<Email>` attributes or theme values that were ignored, what an `editor` conversion flattened or couldn't keep, a `tsx` write that switched the template's editor. Absent when nothing did. Tell the user.
created_atrequiredstring—
updated_atrequiredstring—
200400401403404409422

Search docs and guides

Search the docs and product guides.