Retrieve all subcription preferences for the shopper (authenticated or guest)
If you would like to get a raw Response object use the other getSubscriptions function.
An object containing the options for this method.
A promise of type ConsentSubscriptionResponse.
Retrieve all subcription preferences for the shopper (authenticated or guest)
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type ConsentSubscriptionResponse otherwise.
Update the consent status for a given subscription.
If you would like to get a raw Response object use the other updateSubscription function.
An object containing the options for this method.
A promise of type ConsentSubscription.
Update the consent status for a given subscription.
An object containing the options for this method.
Set to true to return entire Response object instead of DTO.
A promise of type Response if rawResponse is true, a promise of type ConsentSubscription otherwise.
Generated using TypeDoc
Shopper Consents
*# Shopper Consent
API Overview
The Shopper Consent API offers a centralized method for managing shopper consent. With this API, shoppers can view and update subscription preferences for marketing communications across various channels. This API controls how and where shoppers receive marketing messages while ensuring compliance with privacy regulations.
Key Features
Authentication & Authorization
The Shopper Consent API requires a JSON Web Token acquired using the Shopper Consent endpoint:
https://{{shortcode}}.api.commercecloud.salesforce.com/customer/shopper-customers/v1/organizations/{{organizationId}}/customers/actions/login
You must include the relevant scope(s) in the client ID used to generate the SLAS token.
Required Scopes
sfcc.shopper-consents
: Required for reading communication subscription data (GET operations).sfcc.shopper-consents.rw
: Required for creating and modifying communication subscription data (POST operations).Use Cases
Shopper Subscription Management
Data Model
Subscriptions
Subscriptions represent a shopper's consent to receive specific types of marketing communications. Each subscription includes:
Channels
Channels define the communication methods available for a subscription:
email
: Email communicationssms
: SMS/text messageswhatsapp
: WhatsAppTags
Tags indicate where subscription options are displayed in your shopper experience. Tags are also accepted as optional filtering parameters in the retrieval of shopper consent subscriptions. For example:
homepage_banner
: Main website homepageregistration
: Shopper registration processcheckout
: Checkout processuser_profile
: User profile management areaBest Practices
User Experience
Implementation Guidelines
Compliance Considerations
Error Handling
The API uses standard HTTP status codes and returns detailed error information to help with troubleshooting:
400 Bad Request
: Invalid request format or missing required fields401 Unauthorized
: Invalid or missing authentication token403 Forbidden
: Insufficient permissions for the requested operation404 Not Found
: Requested organization or resource not found500 Internal Server Error
: Unexpected server errorRate Limits
To ensure fair usage and system stability, the Shopper Consent API implements rate limiting. Refer to the response headers for current rate limit status and adjust your integration accordingly.*
For instructions on how to retrieve access token for admin APIs: https://developer.salesforce.com/docs/commerce/commerce-api/guide/authorization-for-admin-apis.html
Example with admin auth
API Version: 1.4.4import { ShopperConsents, ClientConfig } from "commerce-sdk"; // or const { ShopperConsents, ClientConfig } = require("commerce-sdk"); const clientConfig: ClientConfig = { parameters: { clientId: "XXXXXX", organizationId: "XXXX", shortCode: "XXX", siteId: "XX" } }; token = { access_token: 'INSERT_ACCESS_TOKEN_HERE' }; clientConfig.headers['authorization'] = `Bearer ${token.access_token}`; const shopperConsentsClient = new ShopperConsents(clientConfig);
Last Updated: