POST
Create a disabled discount

Authorizations

Authorization
string
header
required

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

Idempotency-Key
string
required

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.

Body

application/json

Send exactly one of percentage_basis_points or amount_minor. The discount is created DISABLED: a live money rule in front of shoppers must not be a side effect of one call, so going live is a second, idempotent POST /discounts/{discountId}/enable. A retry outside the idempotency window collides on the unique (store, code) index and answers 409 code_taken rather than creating a duplicate.

code
string
required

Required on create. The natural key a shopper types, and what makes a retry outside the idempotency window a 409 code_taken rather than a second discount. UPPER-CASED AND TRIMMED SERVER-SIDE, so "apitest-disc-001" is stored and returned as "APITEST-DISC-001": read the code back from the response rather than assuming the bytes you sent, and note that two codes differing only in case are the SAME code and the second is a 409.

percentage_basis_points
integer

Sets a percentage discount. Basis points, so 15% is 1500 and no rounding question arises. 1..10000. Mutually exclusive with amount_minor.

Required range: x >= 1
amount_minor
integer

Sets a fixed discount, in minor units of the store's base currency. Mutually exclusive with percentage_basis_points, and requires currency_code in the same object.

Required range: x >= 1
currency_code
string

Required with amount_minor and refused without it. An assertion rather than a choice: promotion has no currency column, so this must equal the store's base currency or the write is refused with 409 currency_mismatch.

starts_at
string<date-time>
ends_at
string<date-time>
usage_limit
integer

Total redemptions allowed. Omit, or send null on a patch, for unlimited. Zero is refused rather than read as unlimited.

Required range: x >= 1

Response

Created

data
object