openapi: 3.1.0
info:
  title: Storefront Consent
  version: 1.0.0
paths:
  /consent:
    post:
      operationId: postCookieConsent
      summary: Set Cookie Consent Preferences
      description: >
        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](/developer/api-reference/rest/admin/management/customers/v3/consent/update-customer-consent)
        endpoint.   


        > #### Note

        > * Substitute your storefront domain for `yourstore.example.com`. 
      tags:
        - consent
      parameters:
        - name: Accept
          in: header
          description: >-
            The [MIME type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types) of the response
            body.
          required: true
          schema:
            type: string
            default: application/json
      responses:
        '200':
          description: Consent Settings Saved
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Consent_postCookieConsent_Response_200'
        '400':
          description: Invalid input
          content:
            application/json:
              schema:
                description: Any type
      requestBody:
        description: >-
          Data sent to the [Update customer
          consent](/developer/api-reference/rest/admin/management/customers/v3/consent/update-customer-consent) endpoint
          when creating a customer during checkout.
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ConsentPreferences'
servers:
  - url: https://your_store.example.com/api/storefront
    description: https://{store_domain}/api/storefront
components:
  schemas:
    ConsentPreferencesAllowItems:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
      title: ConsentPreferencesAllowItems
    ConsentPreferencesDenyItems:
      type: string
      enum:
        - '1'
        - '2'
        - '3'
      title: ConsentPreferencesDenyItems
    ConsentPreferences:
      type: object
      properties:
        allow:
          type: array
          items:
            $ref: '#/components/schemas/ConsentPreferencesAllowItems'
          description: Explicitly allowed consent categories. Allowed values are 1, 2, 3.
        deny:
          type: array
          items:
            $ref: '#/components/schemas/ConsentPreferencesDenyItems'
          description: Denied consent categories. Allowed values are 2, 3, 4.
      required:
        - allow
        - deny
      description: >-
        List of allowed and denied consent categories. Must be populated with a complete set of allowed and denied
        categories.


        Configurable categories are:


        1 - Analytics

        2 - Functional

        3 - Targeting; Advertising


        For further definition of these categories, see [Scripts API](/developer/docs/integrations/scripts).
      title: ConsentPreferences
    Consent_postCookieConsent_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: Consent_postCookieConsent_Response_200
