Set a discount's application method
Authorizations
A secret API key. Publishable keys cannot reach this API. A key may carry an expiry, and an expired key is refused exactly like an unknown one, with a 401 that names no reason; check the key's expires_at in the dashboard rather than inferring it from a response. When a merchant rolls a key's secret they choose a grace window of up to 3 days, and for its duration BOTH the new secret and the one it replaced authenticate, so an integration moves over on its own deploy schedule instead of at the instant the button is pressed. Move before the window closes: after it, the old secret is refused. Nothing else about this contract moves with a roll. The key keeps its id and its scopes, so the only thing an integration updates is the credential itself.
Headers
A unique key per logical write. Replaying a request with the same key returns the first response byte for byte instead of applying the write twice.
Path Parameters
Body
THE SHAPE OF THE DISCOUNT, and the most dangerous write in this family. target_type decides whether the discount comes off the ORDER SUBTOTAL or off the SHIPPING, so one call can turn "10% off the order" into "10% off shipping"; it has no default for that reason. A discount with NO application method still discounts: the money path falls back to the discount's own type and value against the subtotal. Send exactly one of percentage_basis_points or amount_minor. A PUT replaces the whole method and keeps the existing row's id, so replaying converges by construction.
Required, with no default. shipping_methods discounts the SHIPPING and leaves the goods at full price; order and items both discount the subtotal today, because per-line allocation is not implemented. This is the field that decides which total the discount comes off, which is why omitting it is refused rather than defaulted.
order, items, shipping_methods Defaults to across. Stored and published so a client can read back what it set; nothing on the money path branches on it today.
across, each Sets a percentage method. Basis points, so 15% is 1500. 1..10000. Mutually exclusive with amount_minor, and a currency_code beside it is refused: a ratio has none.
x >= 1Sets a fixed method, in minor units. Mutually exclusive with percentage_basis_points, and requires currency_code in the same object. On a buy-get method it is PER DISCOUNTED UNIT, not per order.
x >= 1Required with amount_minor and refused without it. Stored on this table, unlike on the discount itself, but still asserted: it must equal the store's base currency or the write is refused with 409 currency_mismatch, because the amount is subtracted from the cart total without conversion.
The SWITCH that makes this a Buy X Get Y method: with it set, the money path computes a buy-get discount and never runs the standard one. Discounted target units granted per trigger. Must be sent together with buy_rules_min_quantity, and needs buy and target rules on the discount, or the offer computes zero.
x >= 1Units matching the discount's buy rules required to trigger the offer. Only read on a buy-get method, so it is refused without apply_to_quantity rather than stored where nothing would read it.
x >= 1Cap on total discounted units. Only read on a buy-get method, so it is refused without apply_to_quantity. Omit for uncapped.
x >= 1Response
Success
