Create a discount code
Creates a reusable discount code that customers can apply at checkout (or that you pre-apply
via the discountCode field on POST /api/payment/create / POST /api/subscription/create).
Discount type
PERCENT— setdiscountPercent(1–100).discountAmountCentsmust NOT be set.FIXED(default) — setdiscountAmountCents(integer, in cents). Applied in each target product’s own currency.discountPercentmust NOT be set.
Target products
productIds accepts either:
- the literal string
"all"— the code applies to all your products, or - a non-empty array of product IDs.
Authorizations
API key authentication
Body
The discount code customers enter at checkout.
1 - 50"WELCOME10"
Either the literal string "all" (applies to every product you own) or a non-empty
array of product IDs the code is valid for.
all Whether the discount is a percentage or a fixed cents amount.
PERCENT, FIXED "FIXED"
Percentage off (1–100). Required when discountType is PERCENT, must NOT be set otherwise.
1 <= x <= 10010
Fixed amount off in cents, applied in each target product's currency.
Required when discountType is FIXED, must NOT be set otherwise.
x >= 1500
When true, the discount is applied automatically at checkout without the customer entering the code.
false
Maximum number of times the code can be redeemed. Omit for effectively unlimited.
x >= 1100
Expiration date (must be in the future). Omit for no expiry.
"2026-12-31T23:59:59Z"
Optional. Binds the code to a single account: it is then only accepted on a checkout created
with the exact same externalRef, and refused everywhere else with
DISCOUNT_CODE_EXTERNAL_REF_MISMATCH.
Use this for per-account codes (prepaid credits, upgrade proration) that must not be
transferable between your users. Matching is exact — no case folding, no trimming — and a
checkout created without an externalRef can never redeem a bound code.
Omit for a code any customer can use.
255"almanak_user_42"
Whether the code is active and redeemable.

