Templates
API reference for listing templates and creating or updating a template by alias.
Using an AI agent? Just ask:“Save a password-reset template with a reset button.”Connect your agent →
List templates#
GET/api/v1/templates
Response · 200
{
"data": [
{ "id": "e21a…", "alias": "welcome", "name": "Welcome", "subject": "Welcome to Acme", "updated_at": "2026-11-10T12:00:00.000Z" }
]
}Create or update a template#
POST/api/v1/templates
Creates a template, or updates the one with the same alias. Returns 201 when created, 200 when updated.
Body
namestringrequiredA name for you.subjectstringrequiredSubject line. Liquid variables allowed.htmlstringrequiredEmail-safe HTML (tables, inline styles). Up to 500 KB.aliasstringStable id for your code, likewelcome. Lowercase letters, numbers,-and_.preheaderstringPreview text shown after the subject in inboxes.
Request
curl https://agent.maillayer.com/api/v1/templates \
-H "Authorization: Bearer $MAILLAYER_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Password reset",
"alias": "password-reset",
"subject": "Reset your password",
"html": "<p>Hi {{ first_name | default: \"there\" }}, <a href=\"{{ link }}\">reset it here</a>.</p>"
}'Then send it with "template": "password-reset" and "variables": { "link": "…" }. See Templates and variables.