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 a full_access API key.

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(es).

textstring

Plain text version of the template.

variablesarray

Array of template variables (max 50).

keystringrequired

Variable key (e.g. "PRODUCT_NAME"). Cannot be one of the reserved names: FIRST_NAME, LAST_NAME, EMAIL, RESEND_UNSUBSCRIBE_URL.

typestringrequired

Variable type: "string" or "number".

fallback_valuestring | number

A default value used when the variable is not provided at send time. Must match the declared type.

Response Fields

idstring

The ID of the newly created template.

objectstring

Always "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

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