Generate preference page URLs to allow marketing email recipients to manage their subscription preferences.
Use the preference page URL API to generate URLs for a contact’s specific email preference pages, which allows them to manage their email preferences from within authenticated areas of your website.
Please note:
This API is currently in beta and is subject to change based on testing and feedback. By using these endpoints you agree to adhere to HubSpot’s Developer Terms & Developer Beta Terms. You also acknowledge and understand the risk associated with testing an unstable API.
Each set of URLs is generated for a specific contact to edit their own preferences. Ensure each link is only shared securely with the owner of the associated email address.
To generate subscription preferences URLs, ensure that your app has authorized the scopes listed below:
Please note:The API described in this article references business units, which is the former name for brands. This change does not impact the businessUnitId parameter.
To generate preference page URLs for a contact, make a POST request to /communication-preferences/v4/links/generate and provide the following query parameters:
channel(required): communication channel, required to be EMAIL.
businessUnitId: you can optionally include the ID of a specific brand, which results in the links that take contacts to pages customized for that brand. On these pages, only subscriptions within that brand will be displayed.
In the request body, you can also include the following properties:
subscriberIdString(required): email address of the contact for whom the subscription preferences page is being generated.
language: language for the preferences page. For translations to work as expected, you should select a language associated with a subscription type. If no language is specified, the system may default to your account’s default language or English.
subscriptionId: ID of a specific subscription type, which may result in that subscription type being highlighted on the preferences page. This parameter must be included to return an unsubscribeSingleUrl link.
The preference page URLs will be returned within the results field of the response.For example, if you wanted to generate a unique email preference page for bh@hubspot.com associated with a businessUnitId of 887987898, you’d make a POST to https://api.hubapi.com/communication-preferences/v4/links/generate?businessUnitId=887987898&channel=EMAIL, then include a request body that resembled the following:
Description: the provided language parameter is invalid.
Troubleshooting steps: assign one of the languages listed in the error property “message” to a subscription type, then wait several minutes to try again.