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.

POST/templates

Requires an API key with the templates:write permission.

Body Parameters

namestringrequired

The template name.

htmlstringrequired

HTML content with variable placeholders using triple-brace syntax (e.g. {{{VARIABLE_NAME}}}).

aliasstring

A unique alias for the template that can be used instead of the ID. Must be unique within your organization.

fromstring

Default sender email address. Use "Name <email@example.com>" format for a friendly name.

subjectstring

Default email subject.

reply_tostring | string[]

Default reply-to email address. At most one address — the message carries a single Reply-To. Pass a string or a one-element array; two or more addresses are refused.

textstring

Plain text version of the template. plain_text is accepted as an alias; when both are supplied, text wins.

variablesarray

Array of template variables (max 50).

keystringrequired

Variable key (e.g. "PRODUCT_NAME"). 1–50 characters; only ASCII letters, numbers and underscores. Reserved names, compared case-insensitively: FIRST_NAME, LAST_NAME, EMAIL, UNSUBSCRIBE_URL, RESEND_UNSUBSCRIBE_URL, contact, this.

typestringrequired

Variable type: "string" or "number".

fallback_valuestring | number | null

A default value used when the variable is not provided at send time. Must match the declared type; null stores no fallback value.

Response Fields

idstring

The ID of the newly created template.

objectstring

Always "template".

curl -X POST 'https://api.postflare.dev/templates' \
  -H 'Authorization: Bearer sk_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.dev/templates', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sk_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

Response
{
  "id": "e5f6a7b8-c9d0-1234-efab-345678901234",
  "object": "template"
}