Create a template
POST/api/v1/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>"
}'{
"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
| Field | Type | Description |
|---|---|---|
namerequired | string | — |
subject | string | — |
tsx | string | A 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`. |
html | string | A 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`. |
text | string | A 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`. |
theme | object | Page-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_text | string | Inbox preview text: the snippet shown after the subject. A short line that complements the subject. Wins over a `preview-text` on <Email>. |
category | enumtransactional | marketing | — |
Response · 201 fields15 fields
| Field | Type | Description |
|---|---|---|
objectrequired | string | — |
idrequired | string | — |
namerequired | string | — |
subjectrequired | string | null | — |
statusrequired | enumdraft | published | — |
editor | enumsimple | design | code | Which 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. |
kindrequired | enumsimple | designed | The coarse kind: `simple` (editor `simple`) or `designed` (editor `design` or `code`). Prefer `editor`. |
preview_text | string | Inbox preview text: the snippet most inboxes show after the subject. Empty when unset. |
category | enumtransactional | 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. |
html | string | null | — |
tsx | string | null | A `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. |
text | string | null | A `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. |
warnings | string[] | 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_atrequired | string | — |
updated_atrequired | string | — |