Create Template
Create a new email template with optional variables. Templates are created in draft status. Call Publish Template to make them available for sending.
/templatesRequires a full_access API key.
Body Parameters
namestringrequiredThe template name.
htmlstringrequiredHTML content with variable placeholders using triple-brace syntax (e.g. {{{VARIABLE_NAME}}}).
aliasstringA unique alias for the template that can be used instead of the ID. Must be unique within your organization.
fromstringDefault sender email address. Use "Name <email@example.com>" format for a friendly name.
subjectstringDefault email subject.
reply_tostring | string[]Default reply-to email address(es).
textstringPlain text version of the template.
variablesarrayArray of template variables (max 50).
keystringrequiredVariable key (e.g. "PRODUCT_NAME"). Cannot be one of the reserved names: FIRST_NAME, LAST_NAME, EMAIL, RESEND_UNSUBSCRIBE_URL.
typestringrequiredVariable type: "string" or "number".
fallback_valuestring | numberA default value used when the variable is not provided at send time. Must match the declared type.
Response Fields
idstringThe ID of the newly created template.
objectstringAlways "template".
curl -X POST 'https://api.postflare.app/templates' \
-H 'Authorization: Bearer re_xxxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"name": "Welcome Email",
"html": "<p>Welcome, {{{FIRST_NAME}}}!</p>",
"alias": "welcome-email",
"subject": "Welcome to Acme",
"from": "Acme <welcome@acme.com>"
}'const response = await fetch('https://api.postflare.app/templates', {
method: 'POST',
headers: {
'Authorization': 'Bearer re_xxxxxxxxx',
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Welcome Email',
html: '<p>Welcome, {{{FIRST_NAME}}}!</p>',
alias: 'welcome-email',
subject: 'Welcome to Acme',
from: 'Acme <welcome@acme.com>',
}),
});
const data = await response.json();Response
{
"id": "e5f6a7b8-c9d0-1234-efab-345678901234",
"object": "template"
}