Templates
Versioned emails with {{variable}} placeholders. Values come from the send's data, then the contact's fields, then the declared default; {{name|fallback}} sets an inline fallback.
Every PUT publishes a new version; sends record which version they used. Eight ready-made, branded templates are one call away with POST /v1/templates/essentials.
type Template = {
key: string; // "password-reset"
version: number;
type: "transactional" | "marketing";
subject: string; preview_text: string | null;
source_kind: "html" | "react" | "markdown" | "blocks";
source: string; // HTML/Markdown with {{var}}, or a JSON block document
variables: { name: string; default?: string; description?: string }[];
essential: boolean; // one of the 8 ready-made templates
updated_at: string;
versions?: { version: number; created_at: string }[]; // GET /v1/templates/{key}
};curl https://api.mailpark.io/v1/templates \
-H "Authorization: Bearer $MAILPARK_API_KEY"{
"data": [
{
"key": "password-reset",
"version": 3,
"type": "transactional",
"subject": "Reset your {{product_name}} password",
"preview_text": "This link expires in 1 hour.",
"source_kind": "html",
"source": "<html>…<a href=\"{{reset_url}}\">Reset password</a>…</html>",
"variables": [
{
"name": "reset_url",
"description": "Link to the reset page"
}
],
"essential": true,
"updated_at": "2026-10-12T15:30:00Z"
}
],
"next_cursor": null
}Create a template
/v1/templatesA new template at version 1.
templates:writeBody
keystringrequiredLowercase id you send with, e.g.
trial-ending.typestringrequiredtransactionalormarketing.subjectstringrequiredMay contain
{{variables}}.sourcestringrequiredThe body: HTML or Markdown with
{{variables}}, or a blocks JSON document.source_kindstringhtml(default),react,markdownorblocks.preview_textstringThe line inboxes show after the subject.
variablesobject[]The variables it uses.
namestringrequiredPlaceholder name.
defaultstringUsed when the send and contact have no value.
descriptionstringWhat goes in it.
fontsobject{ heading?, body?, custom? }: Google Fonts families fromGET /v1/fonts, or custom stylesheets.
curl -X POST https://api.mailpark.io/v1/templates \
-H "Authorization: Bearer $MAILPARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"key": "trial-ending",
"type": "marketing",
"subject": "Your {{product_name}} trial ends in 3 days",
"source": "<p>Hi {{first_name|there}},</p><p>Your trial ends on {{trial_end}}.</p>",
"variables": [
{
"name": "trial_end",
"description": "Date the trial ends"
}
]
}'{
"key": "trial-ending",
"version": 1,
"type": "marketing",
"subject": "Your {{product_name}} trial ends in 3 days",
"preview_text": "This link expires in 1 hour.",
"source_kind": "html",
"source": "<html>…<a href=\"{{reset_url}}\">Reset password</a>…</html>",
"variables": [
{
"name": "reset_url",
"description": "Link to the reset page"
}
],
"essential": false,
"updated_at": "2026-10-12T15:30:00Z"
}Get a template
/v1/templates/{key}The latest version, or an earlier one with ?version=, plus the list of versions.
Path parameters
keystringrequiredTemplate key.
Query parameters
versionintegerA specific version.
curl https://api.mailpark.io/v1/templates/password-reset \
-H "Authorization: Bearer $MAILPARK_API_KEY"{
"key": "password-reset",
"version": 3,
"type": "transactional",
"subject": "Reset your {{product_name}} password",
"preview_text": "This link expires in 1 hour.",
"source_kind": "html",
"source": "<html>…<a href=\"{{reset_url}}\">Reset password</a>…</html>",
"variables": [
{
"name": "reset_url",
"description": "Link to the reset page"
}
],
"essential": true,
"updated_at": "2026-10-12T15:30:00Z",
"versions": [
{
"version": 3,
"created_at": "2026-10-12T15:30:00Z"
},
{
"version": 2,
"created_at": "2026-10-01T09:00:00Z"
},
{
"version": 1,
"created_at": "2026-09-02T08:10:00Z"
}
]
}Publish a new version
/v1/templates/{key}Saves a new version of the template. New sends use it right away; sent emails keep the version they used. Omit variables to keep the current list.
templates:writePath parameters
keystringrequiredTemplate key.
Body
typestringrequiredtransactionalormarketing.subjectstringrequiredMay contain
{{variables}}.sourcestringrequiredThe body.
source_kindstringhtml,react,markdownorblocks.preview_textstringInbox preview line.
variablesobject[]Replaces the variable list.
curl -X PUT https://api.mailpark.io/v1/templates/password-reset \
-H "Authorization: Bearer $MAILPARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"type": "transactional",
"subject": "Reset your {{product_name}} password",
"source": "<p>Click <a href=\"{{reset_url}}\">here</a> to reset your password. The link expires in 1 hour.</p>"
}'{
"key": "password-reset",
"version": 4,
"type": "transactional",
"subject": "Reset your {{product_name}} password",
"preview_text": "This link expires in 1 hour.",
"source_kind": "html",
"source": "<html>…<a href=\"{{reset_url}}\">Reset password</a>…</html>",
"variables": [
{
"name": "reset_url",
"description": "Link to the reset page"
}
],
"essential": true,
"updated_at": "2026-10-12T15:30:00Z"
}Delete a template
/v1/templates/{key}Deletes every version. Refused while a sequence or an unfinished campaign uses it.
templates:writePath parameters
keystringrequiredTemplate key.
Errors
curl -X DELETE https://api.mailpark.io/v1/templates/trial-ending \
-H "Authorization: Bearer $MAILPARK_API_KEY"{
"deleted": true,
"next_steps": []
}Preview a template
/v1/templates/{key}/previewRenders the template with your data: subject, HTML, plain text, a screenshot URL, and any variables you didn't fill.
Path parameters
keystringrequiredTemplate key.
Body
dataobjectValues for the variables.
curl -X POST https://api.mailpark.io/v1/templates/welcome/preview \
-H "Authorization: Bearer $MAILPARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"data": {
"first_name": "Jane"
}
}'{
"subject": "Welcome to Acme, Jane",
"html": "<!doctype html><html>…</html>",
"text": "Hi Jane, welcome to Acme…",
"image_url": "https://assets.mailpark.io/previews/welcome.png",
"missing_variables": [],
"next_steps": []
}Add the essential templates
/v1/templates/essentialsAdds 8 ready-made templates in your brand, built for mobile and dark mode: welcome, verify-email, password-reset, magic-link, receipt, payment-failed, team-invite and product-update.
templates:writeBody
brandobjectDefaults to the account's brand.
product_namestringShown in headers and subjects.
logo_urlstringHTTPS URL of your logo.
primary_colorstringHex colour for buttons and links.
support_emailstringShown in footers.
curl -X POST https://api.mailpark.io/v1/templates/essentials \
-H "Authorization: Bearer $MAILPARK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"brand": {
"product_name": "Acme",
"logo_url": "https://acme.dev/logo.png",
"primary_color": "#4f46e5",
"support_email": "help@acme.dev"
}
}'{
"data": [
{
"key": "password-reset",
"version": 3,
"type": "transactional",
"subject": "Reset your {{product_name}} password",
"preview_text": "This link expires in 1 hour.",
"source_kind": "html",
"source": "<html>…<a href=\"{{reset_url}}\">Reset password</a>…</html>",
"variables": [
{
"name": "reset_url",
"description": "Link to the reset page"
}
],
"essential": true,
"updated_at": "2026-10-12T15:30:00Z"
}
],
"next_steps": [
"Preview one with POST /v1/templates/welcome/preview."
]
}List fonts
/v1/fontsGoogle Fonts families templates can use for fonts.heading and fonts.body. Web fonts show in Apple Mail, iOS and Outlook for Mac; Gmail and Outlook for Windows use the fallback.
curl https://api.mailpark.io/v1/fonts \
-H "Authorization: Bearer $MAILPARK_API_KEY"{
"data": [
{
"family": "Inter",
"category": "sans",
"weights": [
400,
500,
600,
700
]
},
{
"family": "Playfair Display",
"category": "serif",
"weights": [
400,
700
]
}
]
}