BigCommerce
Storefront API
Consent

Storefront Cookie Consent

Specify shopper cookie consent preferences on BigCommerce-hosted storefronts. To work with headless storefronts, use the GraphQL Storefront API.

The REST Storefront API uses CORS (opens in a new tab) headers for authentication, and therefore has no required scopes. You do not need to send any BigCommerce-specific tokens with your requests to these endpoints.

For info about authenticating BigCommerce APIs, see Authentication and Example Requests.

Set Cookie Consent Preferences

POST /consent

Request

Sets the status of a customer's consent to allow data collection by cookies and scripts according to the following consent categories:

  1. Analytics — These cookies provide statistical information on site usage so the store owner can improve the website over time.

  2. Functional — These cookies enable enhanced functionality, such as videos and live chat. If a shopper does not allow these, then some or all of these functions may not work properly.

  3. Targeting; Advertising — These cookies allow merchants to create profiles or personalize content to enhance users' shopping experience.

This endpoint only works if the cookie consent feature is enabled. It is assumed the shopper has not consented to anything until a value is explicitly set. The request body must be populated with a complete set of allowed and denied categories.

Once set, consent preferences will be saved as a cookie for guest shoppers. Consent preferences will be persisted to a shopper's account to be used for future sessions once they have logged in. Consent preferences can also be managed using the Update customer consent endpoint.

Note

  • Substitute your storefront domain for yourstore.example.com.

Parameters

  • store_domain in path - string
  • Accept in header with default of application/json - string
    required

    The MIME type of the response body.

  • Content-Type in header with default of application/json - string
    required

    The MIME type of the request body.

Data sent to the Update customer consent endpoint when creating a customer during checkout.

Body

object | application/json

List of allowed and denied consent categories. Must be populated with a complete set of allowed and denied categories.

Configurable categories are:

2 - Functional 3 - Analytics 4 - Targeting; Advertising

For further definition of these categories, see Scripts API.

  • allow
    array[integer]
    required

    Explicitly allowed consent categories. Allowed values are 2, 3, 4.

  • deny
    array[integer]
    required

    Denied consent categories. Allowed values are 2, 3, 4.

Example

Response

Consent Settings Saved

Did you find what you were looking for?