Skip to main content
POST
Create coupon

Authorizations

Authorization
string
header
required

Use your Shoppex API key in the Authorization header.

Body

code
string
required

Coupon code. Stored trimmed and lowercased (SUMMER10 becomes summer10); buyers can enter it in any case.

Required string length: 1 - 64
discount_value
number
required
Required range: x >= 1e-9
discount_type
enum<string>
Available options:
PERCENTAGE,
FIXED
max_uses
integer | null
first_order_only
boolean
products_bound
string[]
variants_bound
string[]
products_excluded
string[]

'all_except' coupons: the products the coupon does not discount.

product_discounts
object[]

'selected' coupons: a bound product's own discount instead of the coupon's. max_discount and min_order_amount still apply to the whole coupon.

applies_to
enum<string>

Which products the coupon discounts: 'all', 'selected' (only products_bound and variants_bound), or 'all_except' (every product but products_excluded). Without it, a write that sends a list stores 'all_except' when products are excluded, 'selected' when any item is bound and 'all' when neither is. A 'selected' coupon whose products and variants were all deleted applies to nothing.

Available options:
all,
selected,
all_except
min_order_amount
number | null
max_discount
number | null
valid_from
valid_until
subscription_duration
enum<string>

How many subscription payments the coupon discounts: the first one, the first subscription_payments (REPEATING), or every payment. Defaults to ONCE.

Available options:
ONCE,
REPEATING,
FOREVER
subscription_payments
integer | null

The number of discounted payments for REPEATING, 2 to 36; null otherwise.

Required range: 2 <= x <= 36

Response

Response for status 201

data
object
required