{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/salesforce-commerce-cloud/json-schema/salesforce-commerce-cloud-shopper-context-schema.json",
  "title": "ShopperContext",
  "description": "A shoppers' context represented as key-value string pairs.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/salesforce-commerce-cloud-shopper-context-api-openapi.yml#/components/schemas/ShopperContext",
  "type": "object",
  "properties": {
    "effectiveDateTime": {
      "description": "Qualifier to set the effective date time for the context to apply. For example, \"Shop the Future\" use cases. If not provided, the current dateTime will be assumed.",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "sourceCode": {
      "description": "Qualifier to set the source code for the context to apply. Set the source code to evaluate source code group that triggers the promotion (campaign assignment) and Price books (assigned to Source code group).",
      "type": [
        "string",
        "null"
      ]
    },
    "customerGroupIds": {
      "items": {
        "maxLength": 256,
        "type": "string"
      },
      "type": "array",
      "description": "Qualifier to set the Customer Group Ids for the context to apply. Set the Customer Group Ids to evaluate customer groups that trigger the promotions (campaign assignment) assigned to the customer groups."
    },
    "customQualifiers": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "Map of custom qualifiers for the shopper context. Set this object to trigger pricing and promotion experiences using a dynamic session-based customer group. Object size is limited to 20 key-value pairs (properties)."
    },
    "assignmentQualifiers": {
      "type": "object",
      "additionalProperties": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "Map of assignment qualifiers for the shopper context. Set this object when using the assignment framework to activate experiences based on assignment qualifiers. Currently, only pricing and promotion experiences are supported. Object size is limited to 20 key-value pairs (properties)."
    },
    "clientIp": {
      "type": "string",
      "description": "The IP Address of the client. If the client IP is not a valid IPv4 address, a Bad Request (400) error is thrown. This property is available with B2C Commerce version 24.7.\n\nWhen `clientIp` is set, the geolocation based on the `clientIp` is returned in the `X-Geolocation` header in the response. Note: Use/retrieve this header in a case insensitive manner.\n\nHowever, if the `geoLocation` attribute is also set in the context, it takes precedence over the `clientIp`, and the `X-Geolocation` header returns the geolocation based on the `geoLocation` attribute.\n\nThe query parameter `evaluateContextWithClientIp` determines whether to evaluate the context using the provided `clientIp`.\n  - If `evaluateContextWithClientIp` is set to `true`:\n    - The `clientIp` is saved and used in subsequent requests. \n    \n    Note: If `geoLocation` is also saved in the context, it takes precedence over the `clientIp`.\n  - If `evaluateContextWithClientIp` is set to `false`:\n    - The `clientIp` is not saved and is not used in subsequent requests."
    },
    "geoLocation": {
      "type": "object",
      "properties": {
        "city": {
          "type": "string",
          "description": "The city name associated with this location."
        },
        "country": {
          "type": "string",
          "description": "The country name associated with this location."
        },
        "countryCode": {
          "type": "string",
          "description": "The ISO country code associated with this location."
        },
        "latitude": {
          "type": "number",
          "description": "The latitude coordinate, which is a number between -90.0 and +90.0, associated with this location.",
          "format": "double"
        },
        "longitude": {
          "type": "number",
          "description": "The longitude coordinate, which is a number between -180.0 and +180.0, associated with this location.",
          "format": "double"
        },
        "metroCode": {
          "type": "string",
          "description": "The metro code associated with this location."
        },
        "postalCode": {
          "type": "string",
          "description": "The postal code associated with this location."
        },
        "region": {
          "type": "string",
          "description": "The region (subdivision) name for this location. Corresponds with \"state\" in the USA."
        },
        "regionCode": {
          "type": "string",
          "description": "The region (province or state) code for this location."
        }
      },
      "description": "The geographic location of the client. When you set a geolocation, it is saved as context for subsequent requests. This overrides any geolocation context previously saved using `clientIp`. This property is available with B2C Commerce version 24.7."
    },
    "couponCodes": {
      "items": {
        "maxLength": 256,
        "type": "string"
      },
      "type": "array",
      "description": "Array of coupon codes to be saved in the shopper context. Set the coupon codes to evaluate promotions that can be triggered by these codes."
    }
  },
  "additionalProperties": false
}