PlatformXeDocs
Get API Key

Templates Overview

Reusable message templates with variable substitution.

Templates let you define reusable message content with Handlebars-style variable substitution. Create a template once, then render it with different data for each recipient.

How templates work

  1. Create a template with HTML content and variable placeholders
  2. Render the template by passing a variables object
  3. Send the rendered output via email or other channels

Template syntax

Templates use double curly braces for variable substitution:

<h1>Welcome, {{firstName}}!</h1>
<p>Your order <strong>{{orderId}}</strong> has been confirmed.</p>
<p>Expected delivery: {{deliveryDate}}</p>

Conditionals

{{#if isPremium}}
  <p>Thank you for being a premium member!</p>
{{else}}
  <p>Upgrade to premium for faster delivery.</p>
{{/if}}

Loops

<ul>
{{#each items}}
  <li>{{this.name}} — {{this.quantity}} x {{this.price}}</li>
{{/each}}
</ul>

Quick example

// Create a template
const template = await px.createTemplate({
  name: 'order-confirmation',
  subject: 'Order {{orderId}} Confirmed',
  body: '<h1>Hi {{firstName}}</h1><p>Your order is confirmed.</p>',
});

// Render with variables
const rendered = await px.renderTemplate(template.data.id, {
  variables: { firstName: 'Ada', orderId: 'ORD-12345' },
});

console.log(rendered.data.html);

PlatformXe renders templates server-side. Your application sends the template ID and variables — PlatformXe returns the final HTML. This keeps template logic centralized and versioned.

Next steps