Catalog/commerce-discount-stack

Commerce

Stack discounts (seq vs additive) API

Applies a list of percentage discounts sequentially (correct retail compounding) and additively, returning both totals, the equivalent single discount, and the gap between methods. Answers 'What is 20% then 10% off?', 'Is stacking additive or sequential?'.

Price$0.02per request
MethodPOST
Route/v1/commerce/discount-stack
StatusLive
MIME typeapplication/json
Rate limit120/minute
Cache0s public
commercepricingdiscountstackingsequentialadditivecouponpromotion
API URLhttps://x402.hexl.dev/v1/commerce/discount-stack
Integration docs
Example request
{
  "basePrice": 100,
  "discountsPct": [
    20,
    10
  ],
  "mode": "sequential"
}
Example response
{
  "mode": "sequential",
  "basePrice": 100,
  "appliedDiscountsPct": [
    20,
    10
  ],
  "steps": [
    {
      "discountPct": 20,
      "priceBefore": 100,
      "amountOff": 20,
      "priceAfter": 80
    },
    {
      "discountPct": 10,
      "priceBefore": 80,
      "amountOff": 8,
      "priceAfter": 72
    }
  ],
  "sequentialFinal": 72,
  "additiveFinal": 70,
  "additivePctCapped": 30,
  "finalPrice": 72,
  "totalSaved": 28,
  "equivalentSingleDiscountPct": 28,
  "sequentialVsAdditiveGap": -2,
  "interpretation": "Stacking 20%+10% sequential: $100 -> $72 (equiv 28% single). Sequential always costs more than the naive additive sum."
}
Input schema
{
  "type": "object",
  "required": [
    "basePrice",
    "discountsPct"
  ],
  "properties": {
    "basePrice": {
      "type": "number",
      "examples": [
        100
      ]
    },
    "discountsPct": {
      "type": "array",
      "items": {
        "type": "number"
      },
      "examples": [
        [
          20,
          10
        ]
      ]
    },
    "mode": {
      "type": "string",
      "enum": [
        "sequential",
        "additive"
      ],
      "examples": [
        "sequential"
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}