{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/emporix/main/json-schema/emporix-create-cart-schema.json",
  "title": "createCart",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/emporix-cart-openapi.yml#/components/schemas/createCart",
  "type": "object",
  "properties": {
    "customerId": {
      "maxLength": 200,
      "type": "string",
      "description": "Customer unique identifier generated when a customer account is created through the Customer Service."
    },
    "restriction": {
      "$ref": "#/$defs/restriction"
    },
    "currency": {
      "type": "string",
      "pattern": "[A-Z]{3}",
      "minLength": 3,
      "maxLength": 3,
      "description": "Three-letter currency code, compliant with the ISO 4217 standard."
    },
    "legalEntityId": {
      "type": "string",
      "description": "ID of the legal entity to which customer is assigned."
    },
    "deliveryWindowId": {
      "type": "string",
      "description": "Delivery window unique identifier, as defined in the Shipping Service."
    },
    "deliveryWindow": {
      "$ref": "#/$defs/deliveryWindow"
    },
    "siteCode": {
      "default": "default",
      "type": "string",
      "description": "Site unique identifier. A site is a specific shop.\n\nIf the tenant owns only one shop, the value should be set to `main`."
    },
    "type": {
      "type": "string",
      "description": "Cart type. You can use this field if your store offers different types of carts, such as shopping carts and wishlists."
    },
    "channel": {
      "$ref": "#/$defs/channel"
    },
    "addresses": {
      "type": "array",
      "description": "List of addresses that should be associated with the cart and used for tax determination and shipping cost. There can be one address of type `BILLING` and one of type `SHIPPING` - others are ignored. These addresses are returned with the origin `REQUEST` in the cart response.",
      "items": {
        "$ref": "#/$defs/addressRequest"
      }
    },
    "metadata": {
      "$ref": "#/$defs/metadataRequest"
    },
    "mixins": {
      "type": "object",
      "additionalProperties": true
    },
    "sessionValidated": {
      "default": false,
      "description": "If set to `true`, endpoints validate whether the `session-id` used to create the cart matches the `session-id` passed in the request header.\n\n**Note**: The `sessionValidated` parameter only applies to anonymous customer carts.",
      "type": "boolean"
    }
  },
  "required": [
    "currency"
  ],
  "$defs": {
    "addressRequest": {
      "type": "object",
      "description": "Information about the cart address that can be provided in the request.",
      "additionalProperties": false,
      "properties": {
        "contactName": {
          "type": "string",
          "minLength": 0,
          "description": "Contact name."
        },
        "companyName": {
          "type": "string",
          "description": "Company name."
        },
        "street": {
          "type": "string",
          "minLength": 0,
          "description": "Street."
        },
        "streetNumber": {
          "type": "string",
          "description": "Street number."
        },
        "streetAppendix": {
          "type": "string",
          "description": "Street appendix."
        },
        "zipCode": {
          "type": "string",
          "maxLength": 11,
          "minLength": 0,
          "description": "Zip code."
        },
        "city": {
          "type": "string",
          "minLength": 0,
          "description": "City."
        },
        "country": {
          "type": "string",
          "pattern": "[a-zA-Z]{2}",
          "minLength": 2,
          "maxLength": 2,
          "description": "Country."
        },
        "state": {
          "type": "string",
          "description": "State."
        },
        "contactPhone": {
          "type": "string",
          "description": "Contact phone."
        },
        "type": {
          "type": "string",
          "enum": [
            "BILLING",
            "SHIPPING"
          ],
          "description": "Type of the address data",
          "minLength": 0
        },
        "metadata": {
          "$ref": "#/$defs/metadataRequest"
        },
        "mixins": {
          "type": "object",
          "description": "Mixins object.",
          "additionalProperties": true
        }
      }
    },
    "channel": {
      "type": "object",
      "description": "Channel through which the cart was created.",
      "properties": {
        "name": {
          "type": "string",
          "description": ""
        },
        "source": {
          "type": "string"
        }
      }
    },
    "deliveryWindow": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "ID of the delivery window."
        },
        "slotId": {
          "type": "string",
          "description": "ID of the delivery time slot."
        },
        "deliveryDate": {
          "type": "string",
          "format": "date-time",
          "description": "Delivery date. It has to be of \"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'\" format."
        }
      }
    },
    "metadataRequest": {
      "type": "object",
      "description": "",
      "properties": {
        "mixins": {
          "type": "object",
          "description": "Links to mixin schemas.",
          "additionalProperties": true
        }
      }
    },
    "restriction": {
      "type": [
        "string",
        "null"
      ],
      "description": "Access control identifier that determines who can view or manage the cart.\n\n**Purpose**: Restricts cart visibility based on scope permissions. Only users/applications \nwith matching restriction scopes can access carts with a specific restriction value.\n\n**Access Control**:\n- *Reading*: Users can only query and view carts with the `restriction` value that matches one of their authorized restrictions.\n\n**Validation**: The value must exist in the tenant's configured list of valid restrictions.\n\n**Restriction Synchronization**: \n- If cart is created by customer and `restriction` is not set, the `restriction` will be inherited from customer's restriction'.\n- If the `restriction` property is not set with tenant configuration property `enableSyncBetweenRestrictionsAndSiteCodes` set to `true`, the `restriction` field automatically syncs with cart's siteCode property.\n"
    }
  }
}