---
title: "Update a template"
method: PATCH
path: "/email/templates/{id}"
tags: ["Templates"]
---

# Update a template

`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

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](#get-email-templates-id). Requires the `templates:write` capability.

## Request body

- TemplateUpdate: Update a template's metadata and/or body. To replace the body pass `html` (kind `designed`, code mode) OR `text` (kind `simple`) — never both (422). Match the template's current `kind` (simple → `text`, designed → `html`); the other field converts it, so only do that when the user asked to switch.
  - `name` string
  - `subject` string, nullable
  - `status` 'draft' | 'published'
  - `html` string: 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`.
  - `text` string: 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 `200`

The updated template.

- Template
  - `object` 'template', required
  - `id` string, required
  - `name` string, required
  - `subject` string, 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.
  - `html` string, nullable
  - `warnings` string[]: 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_at` string, required
  - `updated_at` string, required

## Other responses

- `401`: Missing or invalid API key.
- `404`: Template not found.
- `422`: Validation error.

---

[API](https://skmtc.dev/unitpost/apis/unitpost-api.md) · [All operations](https://skmtc.dev/unitpost/apis/unitpost-api/llms.txt) · [OpenAPI document](https://skmtc.dev/unitpost/apis/unitpost-api/revisions/86ff7c890967?raw)
