Update Template

Update a template's content or metadata. Updating a published template sets has_unpublished_versions to true until it is re-published.

PATCH/templates/{template_id}

Requires an API key with the templates:write permission.

Path Parameters

template_idstringrequired

The template ID (UUID) or alias string.

Body Parameters

namestring

The new template name.

htmlstring

New HTML content with variable placeholders.

aliasstring | null

New alias. Must be unique within your organization. Pass null or "" to clear the alias; omit the field to keep it.

fromstring

New default sender email address.

subjectstring

New default email subject.

reply_tostring | string[]

New default reply-to email address. At most one address — the message carries a single Reply-To. Pass a string or a one-element array; two or more addresses are refused.

textstring

New plain text content. plain_text is accepted as an alias; when both are supplied, text wins.

variablesarray

New set of template variables (replaces existing variables, max 50).

keystringrequired

Variable key. 1–50 characters; only ASCII letters, numbers and underscores. Reserved names, compared case-insensitively: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, RESEND_UNSUBSCRIBE_URL, contact, this.

typestringrequired

Variable type: "string" or "number".

fallback_valuestring | number | null

Default value for the variable. null stores no fallback value.

Response Fields

idstring

The template ID.

objectstring

Always "template".

curl -X PATCH 'https://api.postflare.dev/templates/e5f6a7b8-c9d0-1234-efab-345678901234' \
  -H 'Authorization: Bearer sk_xxxxxxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "subject": "Welcome to Acme — Getting Started",
    "html": "<p>Welcome, {{{FIRST_NAME}}}! Let us show you around.</p>"
  }'
const response = await fetch(
  'https://api.postflare.dev/templates/welcome-email',
  {
    method: 'PATCH',
    headers: {
      'Authorization': 'Bearer sk_xxxxxxxxx',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      subject: 'Welcome to Acme — Getting Started',
      html: '<p>Welcome, {{{FIRST_NAME}}}! Let us show you around.</p>',
    }),
  }
);

const data = await response.json();

Response

Response
{
  "id": "e5f6a7b8-c9d0-1234-efab-345678901234",
  "object": "template"
}