Use Handlebars templating to personalize email content in the subject, HTML body, and text body with custom field variables.
{ "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" ]}
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.