{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/salesforce-commerce-cloud/json-schema/salesforce-commerce-cloud-rule-schema.json",
  "title": "Rule",
  "description": "Document representing a categorization rule.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/salesforce-commerce-cloud-catalogs-api-openapi.yml#/components/schemas/Rule",
  "required": [
    "enabled",
    "exclusion",
    "id"
  ],
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "maxLength": 256,
      "description": "The ID of the rule."
    },
    "enabled": {
      "type": "boolean",
      "description": "A flag indicating whether this rule is enabled.",
      "default": false
    },
    "exclusion": {
      "type": "boolean",
      "description": "A flag indicating whether this rule is an exclusion.",
      "default": false
    },
    "categorizationLocaleId": {
      "type": "string",
      "maxLength": 10,
      "description": "This field indicates the locale to be used for evaluating rules/conditions for the entire category. Note: this applies to all the rules for that category, and the last modification for this field will apply to the entire ruleset for that category.\n"
    },
    "categorizationClassificationFlag": {
      "type": "boolean",
      "description": "This field indicates if the matching products assigned as a result of the rules run will be given the tag for classification category. Note: this applies to all the rules for that category, and the last modification for this field will apply to the entire ruleset for that category.\n",
      "default": false
    },
    "categorizationPrimaryFlag": {
      "type": "boolean",
      "description": "This field indicates if the matching products assigned as a result of the rules run will be given the tag for primary category. Note: this applies to all the rules for that category, and the last modification for this field will apply to the entire ruleset for that category.\n",
      "default": false
    },
    "conditions": {
      "items": {
        "$ref": "#/$defs/Condition"
      },
      "type": "array",
      "description": "The list of conditions for the rule."
    }
  },
  "$defs": {
    "Condition": {
      "required": [
        "attributeKey",
        "attributeValue",
        "id",
        "operator"
      ],
      "type": "object",
      "properties": {
        "id": {
          "description": "The ID of the condition.",
          "type": "string",
          "maxLength": 256
        },
        "attributeKey": {
          "type": "string",
          "maxLength": 256,
          "description": "The key of the attribute(system or custom). This represents the ID of the attribute."
        },
        "attributeName": {
          "type": "string",
          "maxLength": 4000,
          "description": "The human-readable name of the attribute(system or custom). This is a read-only field."
        },
        "attributeValue": {
          "items": {
            "type": "string",
            "maxLength": 4000,
            "description": "The value of the attribute."
          },
          "type": "array",
          "description": "Array of attribute values."
        },
        "operator": {
          "type": "string",
          "description": "The operator for the condition.",
          "enum": [
            "starts_with",
            "contains",
            "equals",
            "not_equals",
            "greater_than",
            "less_than",
            "is_one_of",
            "not_one_of",
            "is_defined",
            "is_not_defined"
          ]
        }
      },
      "description": "Document representing a condition."
    }
  }
}