{"openapi":"3.1.0","info":{"title":"Cart Discount Waterfall","version":"1.0.0","description":"Apply cart discounts in the provided order, using half-up basis-point rounding and subtotal thresholds, and show the savings from each promotion.","contact":{"email":"jeremy@jeremycarter.ca"}},"servers":[{"url":"https://gptenv-x402-catalog.defcronyke.workers.dev"}],"paths":{"/cart-discount-waterfall/v1/check":{"post":{"operationId":"cart_discount_waterfall","summary":"Apply cart discounts in the provided order, using half-up basis-point rounding and subtotal thresholds, and show the savings from each promotion.","x-payment-info":{"protocols":[{"x402":{}}],"price":{"mode":"fixed","currency":"USD","amount":"0.04"}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"starting_cents":{"type":"integer","minimum":0,"maximum":100000000},"promotions":{"maxItems":100,"type":"array","items":{"oneOf":[{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":80},"type":{"type":"string","const":"fixed"},"cents":{"type":"integer","minimum":0,"maximum":100000000},"minimum_cents":{"type":"integer","minimum":0,"maximum":100000000}},"required":["code","type","cents","minimum_cents"],"additionalProperties":false},{"type":"object","properties":{"code":{"type":"string","minLength":1,"maxLength":80},"type":{"type":"string","const":"percent"},"basis_points":{"type":"integer","minimum":0,"maximum":10000},"minimum_cents":{"type":"integer","minimum":0,"maximum":100000000}},"required":["code","type","basis_points","minimum_cents"],"additionalProperties":false}]}}},"required":["starting_cents","promotions"],"additionalProperties":false},"example":{"starting_cents":1005,"promotions":[{"code":"A","type":"percent","basis_points":1000,"minimum_cents":1000},{"code":"B","type":"fixed","cents":200,"minimum_cents":1000},{"code":"C","type":"fixed","cents":1000,"minimum_cents":0}]}}}},"responses":{"200":{"description":"Service result","content":{"application/json":{"schema":{"type":"object"},"example":{"final_cents":0,"total_savings_cents":1005,"steps":[{"code":"A","eligible":true,"savings_cents":101,"remaining_cents":904},{"code":"B","eligible":false,"savings_cents":0,"remaining_cents":904},{"code":"C","eligible":true,"savings_cents":904,"remaining_cents":0}]}}}},"400":{"description":"Invalid request"},"402":{"description":"x402 exact payment required on Base"},"503":{"description":"Payment unavailable"}}}}}}