---
schema_version: "1"
id: 9af82dbec91d2640dff1adbccec494684ae8cd74de87b998ec1796f5cc397264
title: Salesforce Commerce Buyer Messaging Consent API
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/commerce-cloud/salesforce-commerce/references/generated-api-specs/comm-buyer-messaging-consent-ref.md
canonical_url: https://developer.salesforce.com/docs/commerce/salesforce-commerce/references/comm-buyer-messaging-consent-ref
source_site: developer.salesforce.com
content_type: documentation
content_hash: eef07cbcc7d6fac9e789eef6349f1bd39a8020fc0ac5ea7af2587c57381529e7
products:
  - B2B Commerce Developer Guide
  - Salesforce APIs
---
Salesforce Commerce Buyer Messaging Consent API

# Salesforce Commerce Buyer Messaging Consent API

Capture consent from a buyer for a webstore. The buyer can share marketing related emails based on their preference. The buyer can also grant or update consent from various places like the store's home page, the checkout page, the registration page, and the my account page.

Commerce Consent API

**Version:** 66.0

## Servers

*   `https://api.salesforce.com/services/data/${version}`
    *   `version (default v66.0): v66.0, v65.0, v64.0`

## Operations

### GET getConsentSubscription

`GET /commerce/webstores/${webstoreId}/consents/subscriptions?experience=${experience}&userContext=${userContext}`

Operation ID: `getConsentSubscription`.

Retrieves communication subscriptions with consent values for a specific webstore. When userContext is true, consent values are retrieved for the contact's email address.

Retrieves communication subscriptions with consent values for a specific webstore. When userContext is true, consent values are retrieved for the contact's email address.

#### Parameters

*   `webstoreId` (path, string, required) Id of the webstore.  
    Example: `0ZExx000000004DGAQ`.
*   `experience` (query, string) UI experience used to capture the buyer's consent (EmailCaptureComponent or ProfileAndRegistration).  
    Example: `Checkout`.
*   `userContext` (query, boolean) Indicates if the contact point value should be obtained from the user context.  
    Example: `false`.

#### Responses

*   **200** Successfully captured consent for the webstore or contact point value.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "contactPointValue": "josh@gmail.com",
      "webStoreId": "0ZExx00000001k5GAA",
      "experience": "EmailCaptureComponent",
      "isSuccess": true,
      "error": {},
      "communicationSubscriptions": [
        {
          "name": "PromotionSubscription",
          "title": "Promotion subscription",
          "description": "Consent for receiving promotional emails.",
          "commSubscriptionId": "0XlSB000000Fc9p0AC",
          "commSubscriptionChannelTypeId": "0XlSB000000Fc9p0AC",
          "consentExperience": "Checkout",
          "consentType": "Email",
          "consentStatus": "opt-in"
        },
        {
          "name": "TravelRelatedContent",
          "title": "Travel subscription",
          "description": "Consent for receiving travel-related emails.",
          "commSubscriptionId": "0XlSB000000Fc9p0AC",
          "commSubscriptionChannelTypeId": "0XlSB000000Fc9p0AC",
          "consentExperience": "Marketing",
          "consentType": "Email",
          "consentStatus": "opt-in"
        }
      ]
    }
    ```
    
*   **400** Bad request with invalid webstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INVALID_INPUT",
        "errorMsg": "Invalid webstoreId."
      },
      "communicationSubscriptions": {}
    }
    ```
    
*   **404** Communication subscriptions not found for WebstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "NOT_FOUND",
        "errorMsg": "Communication Subscriptions not found."
      },
      "communicationSubscriptions": {}
    }
    ```
    
*   **500** Bad request.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INTERNAL_SERVER_ERROR",
        "errorMsg": "Couldn't process request."
      },
      "communicationSubscriptions": {}
    }
    ```
    

### POST updateConsent

`POST /commerce/webstores/${webstoreId}/consents/update`

Operation ID: `updateConsent`.

Updates the consent statuses in Data Cloud of a single contact point value (Email address) related to multiple communication subscription channel types.

Updates the consent statuses in Data Cloud of a single contact point value (Email address) related to multiple communication subscription channel types.

#### Parameters

*   `webstoreId` (path, string, required) Id of the webstore.  
    Example: `0ZExx000000004DGAQ`.

#### Request body (required)

Media type: `application/json`. Schema: `ConsentUpdateInputRepresentation`.

_Example: example-1_ Example of a successful consent value submission.

```
{
  "contactPointValue": "john.doe@example.com",
  "communicationSubscriptionConsentItemList": [
    {
      "commSubscriptionChannelTypeId": "0eBSB000000FRPh2AOYG",
      "consentValue": "opt-out"
    },
    {
      "commSubscriptionChannelTypeId": "0eBSB000000FRPh2GF",
      "consentValue": "opt-in"
    }
  ]
}
```

#### Responses

*   **200** Successfully recorded consent value for contact point value (Email address).
    
    Media type: `application/json`. Schema: `ConsentUpdateResponseRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": true,
      "error": {}
    }
    ```
    
*   **400** Invalid consent experience request.
    
    Media type: `application/json`. Schema: `ConsentUpdateResponseRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INVALID_INPUT",
        "errorMsg": "Invalid consent experience."
      }
    }
    ```
    
*   **404** Failed to find webstore for webstoreId.
    
    Media type: `application/json`. Schema: `ConsentUpdateResponseRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "NOT_FOUND",
        "errorMsg": "Couldn't find webstore."
      }
    }
    ```
    
*   **500** Failed to process request.
    
    Media type: `application/json`. Schema: `ConsentUpdateResponseRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INTERNAL_SERVER_ERROR",
        "errorMsg": "Couldn't process request."
      }
    }
    ```
    

### POST createCommunicationSubscription

`POST /commerce/webstores/${webstoreId}/consents/subscriptions`

Operation ID: `createCommunicationSubscription`.

Create Commerce communication subscription at store level on admin setup UI.

Create Commerce communication subscription at store level on admin setup UI.

#### Parameters

*   `webstoreId` (path, string, required) Id of the webstore.  
    Example: `0ZExx000000004DGAQ`.

#### Request body (required)

Media type: `application/json`. Schema: `ConsentSubscriptionInputRepresentation`.

_Example: example-1_ Example creating communication subscription for webstore with different channel and experience.

```
{
  "name": "PromotionalSubscription",
  "title": "Promotional Email Subscription",
  "description": "User consent for receiving promotional emails.",
  "channels": [
    {
      "consentType": "Email",
      "commSubscriptionChannelTypeId": null
    },
    {
      "consentType": "Sms",
      "commSubscriptionChannelTypeId": null
    }
  ],
  "experiences": [
    "EmailCaptureComponent"
  ]
}
```

#### Responses

*   **201** Successfully created communication subscriptions for webstore.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example_
    
    ```
    {
      "commSubscriptionId": "0eBSB000000FRPh2AO",
      "Success": {
        "value": {
          "isSuccess": true,
          "error": {}
        }
      }
    }
    ```
    
*   **400** Bad request with invalid webstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INVALID_INPUT",
        "errorMsg": "Invalid request."
      }
    }
    ```
    
*   **404** Couldn't find webstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "NOT_FOUND",
        "errorMsg": "Couldn't find webstoreId."
      }
    }
    ```
    
*   **500** Couldn't process request.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INTERNAL_SERVER_ERROR",
        "errorMsg": "Couldn't process request."
      }
    }
    ```
    

### PUT updateCommunicationSubscription

`PUT /commerce/webstores/${webstoreId}/consents/subscriptions/${csId}`

Operation ID: `updateCommunicationSubscription`.

Update or delete Commerce communication subscription for a webstore.

Update Commerce communication subscription for a webstore.

#### Parameters

*   `webstoreId` (path, string, required) Id of the webstore.  
    Example: `0ZExx000000004DGAQ`.
*   `communicationSubscriptionId` (path, string, required) Id of communication subscription.  
    Example: `0eBSB000000FRPh2AO`.

#### Request body (required)

Media type: `application/json`. Schema: `ConsentSubscriptionInputRepresentation`.

_Example: example-1_ Example updating communication subscription for webstore with different channel and experience.

```
{
  "name": "PromotionalSubscription",
  "title": "Promotional Email Subscription",
  "description": "Buyer consent for receiving promotional emails.",
  "channels": [
    {
      "consentType": "Email",
      "commSubscriptionChannelTypeId": "0LOxx000000004DGYG"
    }
  ],
  "experiences": [
    "EmailCaptureComponent"
  ]
}
```

#### Responses

*   **200** Successfully updated communication subscriptions for webstore.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": true,
      "error": {}
    }
    ```
    
*   **400** Bad request with invalid webstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INVALID_INPUT",
        "errorMsg": "Invalid request."
      }
    }
    ```
    
*   **404** Couldn't find webstore for webstoreId.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "NOT_FOUND",
        "errorMsg": "Couldn't find webstore."
      }
    }
    ```
    
*   **500** Couldn't process request.
    
    Media type: `application/json`. Schema: `ConsentSubscriptionResultRepresentation`.
    
    _Example: Success_
    
    ```
    {
      "isSuccess": false,
      "error": {
        "errorCode": "INTERNAL_SERVER_ERROR",
        "errorMsg": "Couldn't process request."
      }
    }
    ```
    

### DELETE deleteCommunicationSubscription

`DELETE /commerce/webstores/${webstoreId}/consents/subscriptions/${csId}`

Operation ID: `deleteCommunicationSubscription`.

Update or delete Commerce communication subscription for a webstore.

Delete a Commerce communication subscription for a webstore.

#### Parameters

*   `webstoreId` (path, string, required) Id of the webstore.  
    Example: `0ZExx000000004DGAQ`.
*   `communicationSubscriptionId` (path, string, required) Id of communication subscription.  
    Example: `0eBSB000000FRPh2AO`.

#### Responses

*   **200** Successfully deleted communication subscription.

## Schemas

### ConsentSubscriptionRepresentation

*   `isSuccess` (_boolean_) Indicates whether the operation was successful.
*   `contactPointValue` (_string_) The email address of the buyer, if retrieved in user context.
*   `webStoreId` (_string_) The unique identifier of the webstore.
*   `experience` (_string_) The user experience context in which the consent was captured. Possible values: 'EmailCaptureComponent', 'ProfileAndRegistration', 'Checkout', 'Marketing'.
*   `error` (_object_) Details of any error that occurred during the operation.
*   `communicationSubscriptions` (_array of object_) A list of communication subscription items and their consent statuses.
    *   `name` (_string_) The internal name of the communication subscription.
    *   `title` (_string_) The display title of the subscription.
    *   `description` (_string_) A description of the subscription.
    *   `commSubscriptionId` (_string_) The unique identifier of the communication subscription.
    *   `commSubscriptionChannelTypeId` (_string_) The unique identifier of the communication subscription channel type.
    *   `consentExperience` (_string_) The user experience context in which consent was captured. Possible values: 'EmailCaptureComponent', 'ProfileAndRegistration', 'Checkout', 'Marketing'.
    *   `consentType` (_string_) The communication channel for the subscription. Possible values: 'Email', 'Sms'.
    *   `consentStatus` (_string_) The buyer's consent status. Possible values: 'opt-in', 'opt-out'.

### ConsentUpdateInputRepresentation

*   `contactPointValue` (_string_) Email address of buyer.
*   `communicationSubscriptionConsentItemList` (_array of object_) List of consent values for a communication subscription.
    *   `commSubscriptionChannelTypeId` (_string_) Id of the communication subscription channel type.
    *   `consentValue` (_string_) Buyer's consent value (opt-in or opt-out).

### ConsentUpdateResponseRepresentation

Output representation of consent update.

*   `isSuccess` (_boolean_) Indicates if the update was succeeded.
*   `error` (_array of object_) Subscription consent information.
    *   `errorCode` (_string_) Message describing the error code.
    *   `errorMessage` (_string_) Message stating the reason for error, if any.

### ConsentSubscriptionInputRepresentation

*   `name` (_string_) Name of the subscription or consent item.
*   `title` (_string_) Title of the consent item.
*   `description` (_string_) Description of what the consent item is for.
*   `channels` (_array of object_) List of channels with commSubscriptionChannelTypeId.
    *   `consentType` (_string_) Channel value.
    *   `commSubscriptionChannelTypeId` (_string_) Corresponding commSubscriptionChannelTypeId.
*   `experiences` (_array of object_) List of experiences with commSubscriptionChannelTypeId.
    *   `experience` (_string_) Experience value.

### ConsentSubscriptionResultRepresentation

Output representation of communication subscription upsert.

*   `isSuccess` (_boolean_) Indicates if the operation was successful.
*   `commSubscriptionId` (_string_) Id of communication subscription.
*   `error` (_array of object_) Subscription consent information.
    *   `errorCode` (_string_) Message describing the error code.
    *   `errorMessage` (_string_) Message stating the reason for error, if any.