Templates

Update a template

Update a template's metadata and/or html. Changes take effect for future sends only — emails already sent or queued keep the body they were rendered with. Writing html switches the template to code mode. Read the current body first with Retrieve a template. Requires the templates:write capability.

patch/email/templates/{id}

Request

  • Base URL: https://www.unitpost.com/api/v1
  • URL: https://www.unitpost.com/api/v1/email/templates/{id}
  • Auth: HTTP bearer

Request body

namestring
subjectstring nullable
status'draft' | 'published'
htmlstring

The email body as HTML (makes the template kind designed; compose with @unitpost/email render() or any HTML; {{variables}} fill at send). Pass exactly one of html or text.

textstring

Simple email body instead of html (makes the template kind simple) — 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 html or text.

Response

The updated template.

object'template' required
idstring required
namestring required
subjectstring nullable required
status'draft' | 'published' required
kind'simple' | 'designed' required

Which kind of email this is. simple: a plain, personal email (the dashboard's Simple editor) — update its body with text. designed: a designed or raw-HTML email (the Design / Code editor) — update its body with html. Sending the other field converts the template to that kind, so keep the kind unless the user asked to switch.

htmlstring nullable
warningsstring[]

Create or update with text only: markup or styling the Simple format doesn't support that was removed or couldn't be used (an unsupported tag, CSS property or font, an image that can't be sent), in plain words. Absent when nothing was.

created_atstring required
updated_atstring required

Changes

No recorded changes to this operation across all 1 revision of this API.