The v4 subscription preferences endpoints allow you to manage email subscriptions details for contacts in your account.
businessUnitId
field or query parameter, which you can use if you purchased the Brands add-on. Be aware that business units is the former name for brands, but this change does not impact the API. You should continue using any previous reference to businessUnitId
. You can get a list of brands in your account using the brands API.communication_preferences.read
: provides access to fetch subscription type definitions and subscription preferences for a contact.communication_preferences.write
: provides access to update subscription preferences for a contact.communication_preferences.read_write
: provides access to both fetch and update subscription preferences for a contact and fetch all subscription definitions in your account.communication_preferences.statuses.batch.read
: provides access to fetch subscription statuses in bulk.communication_preferences.statuses.batch.write
: provides access to manage and update subscription statuses in bulk.GET
request to /communication-preferences/v4/definitions
.
If you have the Brands add-on, you can filter subscription types by brand by including the businessUnitId
as a query parameter in your request. The default Account brand will always use "businessUnitId": 0
.
The subscription types will be returned within the results
field of the response.
includeTranslations=true
query parameter in your request to retrieve any subscription translations associated with each definition.
For example, if you made a GET
request to /communication-preferences/v4/definitions?includeTranslations=true
, the response would resemble the following:
GET
request to /communication-preferences/v4/statuses/{subscriberIdString}?channel=EMAIL
where the subscriberIdString
is the email address of the contact.
For example, to get the subscription preferences for a contact with an email address of jdoe@example.com
, you’d make a GET
request to /preferences/v4/statuses/jdoe@example.com?channel=EMAIL
.
The response will include a full list of the current subscription preferences for the contact in the results
field. An example response is included below:
status
for a subscription type:
SUBSCRIBED
: contact opted into the subscription type.UNSUBSCRIBED
: contact opted out of the subscription type.NOT_SPECIFIED
: contact hasn’t provided opt-in preference for the subscription type.POST
request to /communication-preferences/v4/statuses/batch/unsubscribe-all/read
.
If you have the Brands add-on, you’ll see the wideStatusType: "BUSINESS_UNIT_WIDE"
field in the response. Note that the default Account brand will always use "businessUnitId": 0
.
GET
request to /communication-preferences/v4/statuses/{subscriberIdString}/unsubscribe-all
, where the subscriberIdString is the email address of the contact.
If you have the Brands add-on, you’ll see the wideStatusType: "BUSINESS_UNIT_WIDE"
field in the response. Note that the default Account brand will always use "businessUnitId": 0
.
For example, to check whether a contact with an email address of jdoe@example.com
has opted out of all email communications, you’d make a GET
request to /communication-preferences/v4/statuses/jdoe@example.com/unsubscribe-all
.
POST
request to /communication-preferences/v4/statuses/{subscriberIdString}
, where the subscriberIdString
is the email address of the contact. In the request body, you’ll need to include the fields listed the table below:
Parameter | Type | Description |
---|---|---|
subscriptionId | Number | The internal ID of the subscription type. You can get a full list of subscription IDs by making a GET request to /communication-preferences/v4/statuses/{subscriberIdString} . |
statusState | string | The opt-in or opt-out state that you want to update the contact’s subscription to. The possible values are SUBSCRIBED , UNSUBSCRIBED , or NOT_SPECIFIED . |
legalBasis | string | The legal reason for changing the subscriber’s status. If you data privacy settings turned on, this field is required, along with the legalBasisExplanation field. |
legalBasisExplanation | string | An explanation for the legal basis you provided for updating the subscriber status. |
channel | string | The channel type for the subscription type. Currently, the only supported channel type is EMAIL . |
39644612
. You can fetch a list of all subscription types available to get their IDs by making a GET
request to /communication-preferences/v4/definitions
.
POST
request to /communications-preferences/v4/statuses/{subscriberIdString}/unsubscribe-all
, where the subscriberIdString
is the email address of the contact.
businessUnitId
query parameter in your request. Note that the Account brand will always use "businessUnitId": 0
.verbose
query parameter to include the details of the updated subscription statuses the contact has unsubscribed from in the response. If you don’t use the verbose
query parameter, the resulting response will be empty.POST
request, the contact will be unsubscribed from all email communication from your account. If you have the Brands add-on, the contact will be unsubscribed from all email from the brand specified in your request, but will still be eligible to receive email from other brands in your account.
POST
request to /communication-preferences/v4/statuses/batch/unsubscribe-all/read
, and provide the following query parameters:
businessUnitId
: if you have the Brands add-on, you can include this parameter to specify which business unit your contacts will be opted out of all subscription types from. If you don’t provide this query parameter in the URL of your request, then all statuses for the account will be returned across all brands.channel
: the communication type to unsubscribe all contacts out of. Currently, the only the supported channel is EMAIL
.inputs
field:
POST
request to /communication-preferences/v4/statuses/batch/unsubscribe-all/read?channel=EMAIL
, the resulting response would resemble the following:
POST
request to /communication-preferences/v4/statuses/batch/read
. If you have the Brands add-on, you can include the businessUnitId
query parameter to specify which brand your contacts will be opted out of all subscription types from.
In the body of your request, provide a list of the email addresses for the associated contacts you want to opted out of all email communications using the inputs
field:
POST
request to /communication-preferences/v4/statuses/batch/read?channel=EMAIL
, the resulting response would resemble the following:
POST
request to /communication-preferences/v4/statuses/batch/unsubscribe-all
, and provide the following query parameters in your request:
businessUnitId
: if you have the Brands add-on, you can include this parameter to specify which brand your contacts will be opted out of all subscription types from.channel
: the communication type to unsubscribe all contacts out of. Currently, the only the supported channel is EMAIL
.verbose
: an optional boolean value that controls if the endpoint returns all the subscriptions that were impacted for all contacts.inputs
field:
POST
request to /communication-preferences/v4/statuses/batch/unsubscribe-all?channel=EMAIL&verbose=true
, the resulting response would resemble the following:
POST
request to /communication-preferences/v4/statuses/batch/write
, and provide the details of the subscription updates in the inputs field in the body of your request. For example, the following request body would subscribe the contact with an email address of test@hubspot.com
to the subscription with an ID of 123: