Skip to main content

How It Works

Add a customFields object to each recipient in the to array. Use Handlebars syntax ({{variableName}}) in your subject, htmlBody, and textBody to reference these fields. SendPost replaces the placeholders with values from each recipient’s customFields object.

Output

gavin@hooli.com:
  • Subject: Hello, Gavin! Welcome to Pied Piper!
  • Body: Hi Gavin, Your discount code is BELSON240. Your account status is VIP.
erlich@piedpiper.com:
  • Subject: Hello, Erlich! Welcome to Pied Piper!
  • Body: Hi Erlich, Your discount code is BACHMAN10. Your account status is Incubator.

Advanced Personalization

Nested Fields

Access nested properties in customFields using dot notation. Example:
Output:
  • Subject: Welcome John!
  • HTML: Hello John Doe! We see you’re located in San Francisco, CA.

Array Iteration

Iterate over arrays in customFields using the {{#each}} helper. Example:
Output:
  • Subject: Alice, Your Order History
  • HTML:
    • ORD-001: Premium Plan - $99.99
    • ORD-002: Add-on Storage - $29.99

Nested Objects With Arrays

Combine nested objects and arrays for complex data structures. Example:
Output:
  • Subject: Order ORD-12345 Confirmed - Thank You Bob!
  • HTML: Order confirmation with customer info, items list, shipping address, and total

Syntax Reference

Basic Syntax

  • Variables: {{variableName}}
  • Nested properties: {{object.property}} or {{object.nested.property}}
  • Array iteration: {{#each arrayName}}...{{/each}}
  • Current item: {{this}} (inside {{#each}})
  • Array index: {{@index}} (0-based, inside {{#each}})
  • Conditionals: {{#if condition}}...{{/if}} or {{#if condition}}...{{else}}...{{/if}}

Common Patterns

Iterate over array:
Iterate over array of objects:
Check if array has items:
Nested iteration:

Important Notes

unsubscribe is a reserved custom field name. You can’t use it as a custom field name.
  1. Case sensitivity: Field names are case-sensitive. {{firstName}} and {{FirstName}} are different.
  2. Empty arrays: Empty arrays don’t render anything in {{#each}} blocks. Use {{#if}} to check for empty arrays.
  3. Null/undefined values: If a nested property doesn’t exist, an empty string is rendered. Use {{#if}} to check for existence.
  4. Data structure: Ensure your customFields structure matches your template expectations. Nested objects and arrays must be valid JSON.