---
title: "Commercial unsubscribe"
description: "Learn how to manage commercial email unsubscribe functionality in Knock."
tags: ["preferences", "unsubscribe", "commercial", "broadcasts", "workflows"]
section: Preferences
---

Knock provides built-in support for commercial email unsubscribe functionality, allowing recipients to opt out of promotional or commercial messages with a single click.

## How commercial unsubscribe works

When you mark a workflow or broadcast as commercial, Knock automatically handles the necessary unsubscribe functionality:

1. Adds required unsubscribe headers to all emails sent through that workflow or broadcast.
1. Provides an unsubscribe URL variable that can be included in your email templates.
1. Manages recipient opt-outs during [preference set evaluation](/preferences/overview#preference-evaluation-rules).

## Configuring commercial workflows

To enable commercial unsubscribe functionality for a workflow or broadcast:

1. Navigate to the workflow or broadcast.
1. For a workflow, click "Manage workflow." For a broadcast, click "Edit details."
1. Toggle "Commercial."
1. Save your changes.
1. For a workflow, commit your changes.

Once enabled, Knock will automatically include the necessary unsubscribe headers in all emails sent through that workflow.

## Adding unsubscribe links to emails

### Using footer links

When configuring an email layout using the visual editor, you can add an unsubscribe link to your email footer by clicking the "Add link" dropdown and selecting "1-click unsubscribe".

<Image
  src="/images/integrations/email/layouts/commercial-unsubscribe-dropdown.png"
  alt="Adding a commercial unsubscribe link from the Add link dropdown in the email layout editor"
  width="800"
  height="300"
  className="rounded-md mx-auto border border-gray-200"
/>

### Using the code editor

You can add an unsubscribe link to your email layouts or templates using the built-in variable:

```liquid title="Show unsubscribe link"
<a href="{{vars.commercial_unsubscribe_url}}">Unsubscribe</a>
```

You can conditionally include the link by checking if the variable is present:

```liquid title="Show unsubscribe link only for commercial messages"
{% if vars.commercial_unsubscribe_url %}
<a href="{{vars.commercial_unsubscribe_url}}">Unsubscribe</a>
{% endif %}
```

## Configuring the confirmation page

When a user unsubscribes by clicking the unsubscribe link, Knock displays a confirmation page showing they have been successfully unsubscribed from commercial messages. You can customize this page by navigating to **Platform** > **Preferences**, then clicking the **Unsubscribe** tab.

<AccordionGroup>
  <Accordion title="Standard confirmation page" defaultOpen>
    You can customize the title and body text that will appear on the Knock confirmation page.
    
    <Image
      src="/images/concepts/preferences/customize-unsubscribe-confirmation.png"
      alt="Customizing the standard unsubscribe confirmation page"
      width="500"
      height="300"
      className="rounded-md mx-auto border border-gray-200"
    />
  </Accordion>

  <Accordion title="Custom redirect URL">
    You can provide a URL that recipients should be redirected to after unsubscribing.
    
    <Image
      src="/images/concepts/preferences/set-custom-redirect-url.png"
      alt="Setting a custom redirect URL for unsubscribe"
      width="500"
      height="200"
      className="rounded-md mx-auto border border-gray-200"
    />
  </Accordion>
</AccordionGroup>

## Preference evaluation rules

When a recipient clicks the unsubscribe link, their `default` preference set will be updated, marking `commercial_subscribed` as `false`. They will be opted-out of commercial messages, and they will continue to receive transactional messages based on their other preferences.

This recipient-level preference will take precedence over other environment or tenant preferences. Learn more about [preference merging](/preferences/overview#preference-evaluation-rules).

## Setting `commercial_subscribed` via API

The unsubscribe link writes this preference for you, but you can also set it yourself. This is useful to sync an opt-out you captured elsewhere in your product, or to backfill preferences across your existing users.

`commercial_subscribed` lives on the recipient's `default` preference set. Call the [set user preferences endpoint](/api-reference/users/set_preferences) with a `merge` persistence strategy to update this key without replacing the rest of the preference set.

```javascript title="Opt a user out of commercial messages"
import Knock from "@knocklabs/node";
const knock = new Knock({ apiKey: process.env.KNOCK_API_KEY });

await knock.users.setPreferences("user-id", "default", {
  __persistence_strategy__: "merge",
  commercial_subscribed: false,
});
```

To update many users at once, use [bulk set preferences](/preferences/overview#bulk-set-user-preferences).

## Learn more

To learn more about managing recipient preferences and building preference centers with Knock, visit our [preferences overview](/preferences/overview).
