> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendpost.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Unsubscribe Links

> Add unsubscribe links to emails using the built-in {{unsubscribe}} template variable. Recipients who click the link are automatically added to your suppression list.

```json theme={null}
{
  "from": {
    "email": "marketing@example.com",
    "name": "Marketing Team"
  },
  "to": [
    {
      "email": "user@example.com",
      "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:**

```html theme={null}
<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:**

```html theme={null}
<p style="font-size: 12px; color: #666;">
  <a href='{{unsubscribe}}' style="color: #999; text-decoration: underline;">Unsubscribe</a>
</p>
```

<Warning>
  `unsubscribe` is a reserved custom field name. You cannot use it as a custom field name in your `customFields` object.
</Warning>

<Info>
  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).
</Info>
