Skip to main content
{
  "from": {
    "email": "[email protected]",
    "name": "Marketing Team"
  },
  "to": [
    {
      "email": "[email protected]",
      "name": "John Doe",
      "customFields": {
        "firstName": "John"
      }
    }
  ],
  "subject": "Special Offer Just for You!",
  "htmlBody": "<p>Hi {{firstName}},</p><p>We have an exclusive offer for you!</p><p><a href='{{unsubscribe}}'>Unsubscribe from these emails</a></p>",
  "textBody": "Hi {{firstName}},\n\nWe have an exclusive offer for you!\n\nUnsubscribe from these emails: {{unsubscribe}}",
  "trackOpens": true,
  "trackClicks": true,
  "groups": [
    "promotional"
  ]
}

How It Works

Use the {{unsubscribe}} template variable in your email body. SendPost replaces it with a unique unsubscribe URL for each recipient. Include it in both htmlBody and textBody. When a recipient clicks the unsubscribe link:
  • They’re added to your account’s suppression list
  • Future emails to that recipient are automatically dropped
  • You receive an unsubscribed webhook event (if webhooks are configured)

Examples

HTML email:
<p>Don't want to receive these emails? <a href='{{unsubscribe}}'>Click here to unsubscribe</a></p>
Plain text email:
Don't want to receive these emails? Unsubscribe here: {{unsubscribe}}
Styled unsubscribe link:
<p style="font-size: 12px; color: #666;">
  <a href='{{unsubscribe}}' style="color: #999; text-decoration: underline;">Unsubscribe</a>
</p>
unsubscribe is a reserved custom field name. You cannot use it as a custom field name in your customFields object.
The unsubscribe link is unique for each recipient and email. Once a recipient clicks the unsubscribe link, they are immediately added to your suppression list, and you will receive an unsubscribed webhook event (if webhooks are configured).