Skip to content

Personalization

You can replace the string enclosed by {{}} in the body or subject of an email with another string. This allows you to send an optimized email to your recipients.

const payload = {
subject: "{{topic}} Letter",
body: "# Hello {{user}}",
to: [
{ email: "[email protected]",
personalizations: [
{
name: "{{user}}",
value: "John"
},
{
name: "{{topic}}",
value: "News",
field: "subject"
}
]},
{ email: "[email protected]",
personalizations: [
{
name: "{{user}}",
value: "Bob"
}
]},
],
defaults: [
{
name: "{{topic}}",
value: "Welcome",
field: "subject"
}
]
};

The first recipient will have subject as News Letter and body as # Hello John. The second recipient will have subject as Welcome Letter and body as # Hello Bob.

const payload = {
subject: "Subject",
body: "# Hello {{user}}",
buttons: [
{
href: "https://your-site.com/user-page/{{token}}",
text: "Click Me!"
}
],
to: [
{ email: "[email protected]",
personalizations: [
{
name: "{{user}}",
value: "John"
},
{
name: "{{token}}",
value: "TOKEN-VALUE",
field: "content"
}
]}
]
};

The field can be either subject or content. If not specified, it will be content. Fields converted with content are body header footer buttons logo authors links.