{
  "from": {
    "email": "richard@piedpiper.com",
    "name": "Richard"
  },
  "to": [
    {
      "email": "gavin@hooli.com",
      "name": "Gavin Belson",
      "customFields": {
        "firstName": "Gavin",
        "discountCode": "BELSON240"
        "status": "VIP"
      }
    },
    {
      "email": "erlich@piedpiper.com",
      "name": "Erlich Bachman",
      "customFields": {
        "firstName": "Erlich",
        "discountCode" : "BACHMAN10"
        "status": "Incubator"
      }
    },
  ],
  "subject": "Hello, {{firstName}}! Welcome to Pied Piper!",
  "htmlBody": "<p>Hi {{firstName}},</p><p>Your discount code is <b>{{discountCode}}</b>. Your account status is {{status}}}.</p>",
  "textBody": "Hi {{firstName}},\n\nYour discount code is {{discountCode}}. Your account status is {{status}}.",
  "ippool": "default",
  "trackOpens": true,
  "trackClicks": true,
  "groups": [
    "special-offers"
  ]
}

Explanation:

Custom Fields for Personalization:
  • Each recipient in the to array has a customFields map.
  • These fields are used to dynamically render the email content.
  • Example: {{firstName}}, {{discountCode}}, and {{status}} in the subject, htmlBody, and textBody are replaced with the respective values from customFields.

Output Example:

For gavin@hooli.com: Subject: Hello, Gavin! Your Special Offer Awaits Hi Gavin, Your discount code is BELSON240. Your account status is VIP.
For erlich@piedpier.com: Subject: Hello, Erlich! Your Special Offer Awaits Hi Erlich, Your discount code is BACHMAN10. Your account status is Incubator.
unsubscribe is a reserved custom field name. You can’t use it as a custom field name.
Here is how to add an unsubscribe link to your SendPost email templates. Add this to your email template:
<a href='{{unsubscribe}}'>Unsubscribe</a>
Any user who clicks on this will get added to the suppression list on your SendPost subaccount.