{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/salesforce-commerce-cloud/json-schema/salesforce-commerce-cloud-discount-rule-schema.json",
  "title": "DiscountRule",
  "description": "The discount-rule document for a promotion, managed as a sub-resource at /promotions/{id}/discount-rule. It holds\n the discount rule (shape selected by promotionClass), the product qualifiers, and the payment-method qualifiers.\n The promotion shell (id, name, enabled, promotionClass) is managed separately on the\n parent /promotions/{id} resource.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/salesforce-commerce-cloud-promotions-api-openapi.yml#/components/schemas/DiscountRule",
  "additionalProperties": {
    "title": "Additional Property Support",
    "description": "This type supports additional properties passed along with the defined properties of this API.\nTo indicate that the properties were defined and expected to be handled as additional properties, they are expected to be prefixed with a `c_`.\nThe type will reject any property that does not fit this pattern, only allowing additional properties beginning with the known prefix."
  },
  "type": "object",
  "properties": {
    "promotionRule": {
      "description": "The discount rule for this promotion. Its shape is selected by the parent promotion's promotionClass (product,\n order, or shipping) and holds the discount, tiers, BOGO, thresholds, max-applications, and class-specific flags.",
      "allOf": [
        {
          "$ref": "#/$defs/PromotionRule"
        }
      ]
    },
    "qualifyingProducts": {
      "description": "The products a customer must purchase for the promotion to apply.",
      "allOf": [
        {
          "$ref": "#/$defs/ProductSpecification"
        }
      ]
    },
    "discountedProducts": {
      "description": "The products that receive the discount. Valid only for a product-class promotion; supplying it for an order or shipping\n promotion is rejected with a 400.",
      "allOf": [
        {
          "$ref": "#/$defs/ProductSpecification"
        }
      ]
    },
    "excludedProducts": {
      "description": "The products excluded from both qualifying for and receiving the discount. Valid only for an order-class\n promotion; supplying it for a product or shipping promotion is rejected with a 400.",
      "allOf": [
        {
          "$ref": "#/$defs/ProductSpecification"
        }
      ]
    },
    "paymentMethodQualifiers": {
      "description": "The payment methods the promotion is restricted to.",
      "allOf": [
        {
          "$ref": "#/$defs/PromotedPaymentMethods"
        }
      ]
    }
  },
  "$defs": {
    "BogoDiscount": {
      "description": "A buy-one-get-one discount. In Business Manager the Type selector (Buy X / Get Y) is Product-class only.",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "threshold": {
          "format": "double",
          "minimum": 0,
          "description": "The quantity of eligible products required.",
          "type": "number"
        },
        "discount": {
          "description": "The discount applied to the bonus product; typically fixed_price, percentage, or amount.",
          "allOf": [
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        },
        "eligibleQuantity": {
          "format": "int32",
          "minimum": 1,
          "description": "The number of eligible products that earn the bonus.",
          "type": "integer"
        },
        "requireExactEligibleQuantity": {
          "description": "Determines if exactly the eligible quantity is required, rather than at least.",
          "type": "boolean"
        }
      }
    },
    "CurrencyCode": {
      "description": "A three letter uppercase currency code conforming to the [ISO 4217](https://www.iso.org/iso-4217-currency-codes.html) standard, or the string `N/A` indicating that a currency is not applicable.",
      "pattern": "^([A-Z][A-Z][A-Z]|N/A)$",
      "type": "string"
    },
    "Discount": {
      "description": "A discount value object. The type determines which value field applies: amount, fixed_price, total_fixed_price,\n and fixed_price_shipping use amount; percentage and percent_off_options use percentage; price_book_price uses\n priceBookId; bonus and bonus_choice use bonusProducts; free_shipping carries no value.\nValid types depend on the enclosing promotion class - the schema does not enforce this, so the backend rejects an\n out-of-class type: product rules accept amount, percentage, fixed_price, total_fixed_price, price_book_price, bonus,\n bonus_choice, free_shipping, fixed_price_shipping, percent_off_options; order rules accept amount, percentage, bonus,\n bonus_choice; shipping rules accept fixed_price, percentage, amount. A BOGO discount is a stricter product subset:\n fixed_price, price_book_price, percentage, amount.",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "description": "The kind of discount.",
          "enum": [
            "amount",
            "percentage",
            "fixed_price",
            "total_fixed_price",
            "price_book_price",
            "bonus",
            "bonus_choice",
            "free_shipping",
            "fixed_price_shipping",
            "percent_off_options"
          ],
          "type": "string"
        },
        "amount": {
          "description": "The monetary value, for amount, fixed_price, total_fixed_price, and fixed_price_shipping discounts.",
          "allOf": [
            {
              "$ref": "#/$defs/Money"
            }
          ]
        },
        "percentage": {
          "description": "The percentage off, for percentage and percent_off_options discounts.",
          "allOf": [
            {
              "$ref": "#/$defs/Percentage"
            }
          ]
        },
        "priceBookId": {
          "maxLength": 256,
          "description": "The price book the discounted price is taken from, for a price_book_price discount.",
          "type": "string"
        },
        "bonusProducts": {
          "description": "The bonus products offered, for bonus and bonus_choice discounts.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProductId"
          }
        }
      }
    },
    "Money": {
      "description": "A combination of a Currency and an amount of that Currency.",
      "type": "object",
      "properties": {
        "currencyMnemonic": {
          "$ref": "#/$defs/CurrencyCode"
        },
        "value": {
          "format": "double",
          "description": "The amount of money for the given currency.",
          "type": "number"
        }
      }
    },
    "OrderPromotionRule": {
      "description": "The discount rule for an order promotion.",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "promotionClass"
      ],
      "properties": {
        "promotionClass": {
          "description": "The promotion class discriminator. Always order for an order promotion rule.",
          "enum": [
            "order"
          ],
          "type": "string"
        },
        "discount": {
          "description": "The discount applied by this rule.",
          "allOf": [
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        },
        "tiers": {
          "description": "The tiered discounts, applied by threshold. Empty or absent for a non-tiered rule.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TieredDiscount"
          }
        },
        "discountOnlyQualifyingProducts": {
          "description": "Determines if only the qualifying products are discounted.",
          "type": "boolean"
        },
        "excludeDiscountedProducts": {
          "description": "Determines if products that already received a product-level discount are excluded.",
          "type": "boolean"
        },
        "disableGlobalExcludedProducts": {
          "description": "Determines if this rule ignores the site-level global product exclusions. Distinct from the\n promotion-level disableGloballyExcluded flag.",
          "type": "boolean",
          "default": false
        },
        "enableUpsells": {
          "description": "Determines if the promotion is returned as an approaching promotion to encourage upsell.",
          "type": "boolean"
        },
        "upsellThreshold": {
          "description": "The amount by which the merchandise total may fall short of the purchase condition and still upsell.",
          "allOf": [
            {
              "$ref": "#/$defs/Money"
            }
          ]
        }
      }
    },
    "Percentage": {
      "description": "A percentage value, from 0 to 100.",
      "format": "double",
      "minimum": 0,
      "maximum": 100,
      "type": "number"
    },
    "ProductCondition": {
      "description": "A single product condition - a condition type, a comparison operator, and one or more values. Each condition type\n supports a specific operator (for example, category supports is_equal, is_exactly,\n is_child_of; brand and attribute add exists / does_not_exist).",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "type"
      ],
      "properties": {
        "type": {
          "description": "The kind of product condition.",
          "enum": [
            "brand",
            "product_id",
            "category",
            "price",
            "inventory",
            "attribute",
            "product_set",
            "price_book",
            "option"
          ],
          "type": "string"
        },
        "operator": {
          "maxLength": 256,
          "description": "The comparison operator, as a lower_snake_case token. The valid set depends on the condition type:\n category: is_equal, is_exactly, is_direct_child_of, is_child_of, is_direct_parent_of, is_parent_of, is_sibling_of;\n brand: exists, does_not_exist, is_equal, is_not_equal, starts_with, ends_with, contains, does_not_contain;\n product_id: is_equal, is_not_equal, starts_with, ends_with, contains, does_not_contain;\n price: less_than, greater_than, ends_with;\n inventory: less_than, greater_than;\n attribute: less_than, greater_than, equals, is_not_equal, exists, does_not_exist, starts_with, ends_with, contains, does_not_contain;\n product_set: is_equal, exists;\n price_book: storefront_price_in_recursive, storefront_price_in, price_in;\n option: is_equal, exists, does_not_exist.",
          "type": "string"
        },
        "values": {
          "description": "The values compared against.",
          "type": "array",
          "items": {
            "maxLength": 256,
            "type": "string"
          }
        },
        "catalogId": {
          "maxLength": 256,
          "description": "The id of the catalog that owns the categories listed in `values`. Required when `type` is `category; ignored for every other condition type.",
          "type": "string"
        },
        "attributeId": {
          "maxLength": 256,
          "description": "The id of the custom product attribute to compare. Required when `type` is `attribute`; ignored for every\n other condition type.",
          "type": "string"
        },
        "optionId": {
          "maxLength": 256,
          "description": "The id of the product option to compare. Required when `type` is `option`; ignored for every other\n condition type.",
          "type": "string"
        }
      }
    },
    "ProductConditionGroup": {
      "description": "A group of product conditions.",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "conditions": {
          "description": "The conditions in this group.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProductCondition"
          }
        }
      }
    },
    "ProductId": {
      "minLength": 1,
      "maxLength": 100,
      "type": "string",
      "description": "The id (SKU) of the product."
    },
    "ProductPromotionRule": {
      "description": "The discount rule for a product promotion.",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "promotionClass"
      ],
      "properties": {
        "promotionClass": {
          "description": "The promotion class discriminator. Always product for a product promotion rule.",
          "enum": [
            "product"
          ],
          "type": "string"
        },
        "discount": {
          "description": "The discount applied by this rule.",
          "allOf": [
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        },
        "tiers": {
          "description": "The tiered discounts, applied by threshold. Empty or absent for a non-tiered rule.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TieredDiscount"
          }
        },
        "bogo": {
          "description": "The buy-one-get-one discount. Present only for a buy-X-get-Y product promotion.",
          "allOf": [
            {
              "$ref": "#/$defs/BogoDiscount"
            }
          ]
        },
        "maxApplications": {
          "format": "int32",
          "minimum": 1,
          "description": "The maximum number of times the discount can be applied.",
          "type": "integer"
        },
        "identicalProducts": {
          "description": "Determines if the qualifying and discounted products must all be identical.",
          "type": "boolean"
        },
        "prorate": {
          "description": "Determines if the discount is prorated across the eligible items.",
          "type": "boolean"
        },
        "disableGlobalExcludedProducts": {
          "description": "Determines if this rule ignores the site-level global product exclusions. Distinct from the\n promotion-level disableGloballyExcluded flag.",
          "type": "boolean",
          "default": false
        }
      }
    },
    "ProductSpecification": {
      "description": "A set of product conditions. A product matches when it satisfies the included-products groups and none of the\n excluded-products groups.",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "includedProducts": {
          "description": "The condition groups a product must match.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProductConditionGroup"
          }
        },
        "excludedProducts": {
          "description": "The condition groups that exclude a product.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/ProductConditionGroup"
          }
        }
      }
    },
    "PromotedPaymentMethods": {
      "description": "The payment methods a promotion is restricted to.",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "methodIds": {
          "description": "The payment method IDs. Each is either a payment method ID or a credit card type prefixed with CREDIT_CARD\n (for example CREDIT_CARD.Visa).",
          "type": "array",
          "items": {
            "maxLength": 256,
            "type": "string"
          }
        }
      }
    },
    "PromotedShippingMethods": {
      "description": "The shipping methods a shipping promotion applies to.",
      "additionalProperties": false,
      "type": "object",
      "properties": {
        "methodIds": {
          "description": "The shipping method IDs.",
          "type": "array",
          "items": {
            "maxLength": 256,
            "type": "string"
          }
        }
      }
    },
    "PromotionRule": {
      "description": "The discount rule for a promotion. The concrete shape is selected by promotionClass: a product promotion uses\n ProductPromotionRule, an order promotion uses OrderPromotionRule, and a shipping promotion uses ShippingPromotionRule.",
      "oneOf": [
        {
          "$ref": "#/$defs/ProductPromotionRule"
        },
        {
          "$ref": "#/$defs/OrderPromotionRule"
        },
        {
          "$ref": "#/$defs/ShippingPromotionRule"
        }
      ]
    },
    "ShippingPromotionRule": {
      "description": "The discount rule for a shipping promotion.",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "promotionClass"
      ],
      "properties": {
        "promotionClass": {
          "description": "The promotion class discriminator. Always shipping for a shipping promotion rule.",
          "enum": [
            "shipping"
          ],
          "type": "string"
        },
        "discount": {
          "description": "The discount applied by this rule.",
          "allOf": [
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        },
        "tiers": {
          "description": "The tiered discounts, applied by threshold. Empty or absent for a non-tiered rule.",
          "type": "array",
          "items": {
            "$ref": "#/$defs/TieredDiscount"
          }
        },
        "shippingMethodQualifiers": {
          "description": "The shipping methods the promotion applies to. Shipping-class only.",
          "allOf": [
            {
              "$ref": "#/$defs/PromotedShippingMethods"
            }
          ]
        },
        "prohibitNonqualifyingProducts": {
          "description": "Determines if the shipment must contain only qualifying products for the discount to apply.",
          "type": "boolean"
        },
        "disableGlobalExcludedProducts": {
          "description": "Determines if this rule ignores the site-level global product exclusions. Distinct from the\n promotion-level disableGloballyExcluded flag.",
          "type": "boolean",
          "default": false
        },
        "maxApplications": {
          "format": "int32",
          "minimum": 1,
          "description": "The maximum number of times the discount can be applied.",
          "type": "integer"
        }
      }
    },
    "TieredDiscount": {
      "description": "A single discount tier - a threshold and the discount applied once the threshold is met. \n All tiers in the same rule MUST carry the same conditionType - the backend applies one condition-type to the whole\n tier set and rejects mixed values.",
      "additionalProperties": false,
      "type": "object",
      "required": [
        "threshold",
        "conditionType",
        "discount"
      ],
      "properties": {
        "threshold": {
          "format": "double",
          "minimum": 0,
          "description": "The threshold at which this tier's discount applies.",
          "type": "number"
        },
        "conditionType": {
          "description": "The kind of threshold. All tiers in the same rule MUST send the same value. Valid values depend on the promotion class -\n product: product_quantity, product_amount; order: order_total, product_quantity, product_combination;\n shipping: shipment_total, product_quantity, product_combination.",
          "enum": [
            "product_quantity",
            "product_amount",
            "order_total",
            "product_combination",
            "shipment_total"
          ],
          "type": "string"
        },
        "discount": {
          "description": "The discount applied at this tier.",
          "allOf": [
            {
              "$ref": "#/$defs/Discount"
            }
          ]
        }
      }
    }
  }
}