API Reference

Update template

PATCH /templates/:id — edit a template's name, subject, or body.

PATCH/templates/:id

Updates only the fields you provide; omitted fields are left unchanged.

Body parameters
namestringoptional

New name.

aliasstring | nulloptional

New alias. Pass null to clear. Must be unique across your templates.

subjectstring | nulloptional

New default subject. Pass null to clear.

htmlstring | nulloptional

New HTML body. Pass null to clear.

textstring | nulloptional

New plain-text body. Pass null to clear.

fromstring | nulloptional

New default sender address. Use "Your Name <sender@domain.com>" for a friendly name. Pass null to clear.

reply_tostring | string[] | nulloptional

New default Reply-To address, or an array of addresses. Pass null to clear.

variablesarrayoptional

Replaces the template's variables (up to 50). Each is an object with key, type, and optional fallback_value — same shape as on create.

variables[] object
keystringrequired

The 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'optional

The type of the variable. Defaults to string when omitted.

fallback_valuestring | number | nulloptional

The 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('tmpl_8f5c2a1e', { "subject": "Welcome aboard, {{first_name}}!" });
console.log({ data, error });

Also edits a draft (does not auto-publish). Returns { object: "template", id }.