Update Template
Update a template's content or metadata. Updating a published template sets has_unpublished_versions to true until it is re-published.
/templates/{template_id}Requires an API key with the templates:write permission.
Path Parameters
template_idstringrequiredThe template ID (UUID) or alias string.
Body Parameters
namestringThe new template name.
htmlstringNew HTML content with variable placeholders.
aliasstring | nullNew alias. Must be unique within your organization. Pass null or "" to clear the alias; omit the field to keep it.
fromstringNew default sender email address.
subjectstringNew 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.
textstringNew plain text content. plain_text is accepted as an alias; when both are supplied, text wins.
variablesarrayNew set of template variables (replaces existing variables, max 50).
keystringrequiredVariable 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.
typestringrequiredVariable type: "string" or "number".
fallback_valuestring | number | nullDefault value for the variable. null stores no fallback value.
Response Fields
idstringThe template ID.
objectstringAlways "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
{
"id": "e5f6a7b8-c9d0-1234-efab-345678901234",
"object": "template"
}