Skip to main content
POST
Create a discount code

Authorizations

X-Suby-Api-Key
string
header
required

Secret API key. sk_live_… (production) or sk_sandbox_… (sandbox).

Headers

Idempotency-Key
string

Optional key (≤255 chars, e.g. a UUID v4) making this POST safe to retry · the response is cached 24h and a retry with the SAME key replays it instead of re-executing. The same key with a different body → 422 IDEMPOTENCY_KEY_CONFLICT; a retry while the first is in flight → 409.

Maximum string length: 255
Example:

"5f3b9c2e-1a4d-4f2b-9c31-7e2a1b6d8c04"

Body

application/json

Only the field matching discountType is stored; the other is cleared, so a code can never carry two contradictory discounts.

name
string
required

The code you hand out. Unique per account and environment.

Required string length: 2 - 40
Pattern: ^[A-Z0-9][A-Z0-9_-]*$
Example:

"NOEL2026"

discountType
enum<string>
default:PERCENTAGE
Available options:
PERCENTAGE,
FIXED
discountPercent
integer

Required when discountType=PERCENTAGE.

Required range: 1 <= x <= 99
discountAmountCents
string

Required when discountType=FIXED. Minor units as a string of digits.

Pattern: ^[1-9]\\d*$
Example:

"500"

currency
string

Required when discountType=FIXED.

Pattern: ^[A-Z]{3}$
productIds
string[]

Eligible products. Leave empty to apply to every product.

maxUses
integer | null

Global redemption cap. Null = unlimited. Counts settled redemptions plus checkouts in flight, so the last use is never handed to two buyers; an abandoned attempt releases its slot on expiry.

Required range: x >= 1
expiresAt
string<date-time> | null
preApply
boolean
default:false

Apply on the hosted checkout with no payer input, on every order it covers. A code carried by the session wins over it. The payer sees the discount already deducted and can still remove it; one that no longer redeems is silently skipped rather than raising an error they did not cause.

Response

Code created

success
boolean
required
Example:

true

data
object
required

Endpoint-specific payload.

message
string