Update template
PATCH /templates/:id — edit a template's name, subject, or body.
/templates/:idUpdates only the fields you provide; omitted fields are left unchanged.
namestringoptionalNew name.
aliasstring | nulloptionalNew alias. Pass null to clear. Must be unique across your templates.
subjectstring | nulloptionalNew default subject. Pass null to clear.
htmlstring | nulloptionalNew HTML body. Pass null to clear.
textstring | nulloptionalNew plain-text body. Pass null to clear.
fromstring | nulloptionalNew default sender address. Use "Your Name <sender@domain.com>" for a friendly name. Pass null to clear.
reply_tostring | string[] | nulloptionalNew default Reply-To address, or an array of addresses (an array is stored and returned as a single comma-separated string). Pass null to clear.
variablesarrayoptionalReplaces the template's variables (up to 50). Each is an object with key, type, and optional fallback_value — same shape as on create.
keystringrequiredThe variable key. Reserved names that cannot be used: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, contact, this. Keys must start with a letter or underscore and contain only letters, digits, underscores, or dots.
type'string' | 'number'optionalThe type of the variable. Defaults to string when omitted.
fallback_valuestring | number | nulloptionalThe value used when none is supplied at send time. Must match type.
import { Mailblastr } from 'mailblastr';
const mb = new Mailblastr('mb_xxxxxxxxx');
const { data, error } = await mb.templates.update('43f68331-0622-4e15-8202-246a0388854b', { "subject": "Welcome aboard, {{first_name}}!" });
console.log({ data, error });Also edits a draft (does not auto-publish). Returns { object: "template", id }. A published template keeps serving its last published snapshot until you publish again.
Field limits
These caps are enforced at the API boundary. Exceeding one returns a validation_error naming the field, e.g. *subject must be 998 characters or fewer.*
| Field | Maximum length |
|---|---|
name | 255 |
subject | 998 |
from | 320 |
reply_to | 320 |
alias | 255 |
not_found if no template with that id (or alias) belongs to you; validation_error if a field exceeds its maximum length, if the new alias is already used by another of your templates, or if variables is invalid (not an array, more than 50 entries, reserved/duplicate/invalid key, unknown type, or a fallback_value that does not match its type). See Errors.