Coupon and Promotion Code
The Coupon and Promotion Code entities in Billing.
A Coupon is a reusable discount definition (percent or fixed amount, with a duration). A Promotion Code is a customer-redeemable shortcode that points at exactly one coupon and adds redemption controls (validity window, redemption cap, first-time-only, minimum amount). You apply a coupon directly when you have one in hand server-side; you accept a promotion code when a customer types one in.
Lifecycle
- Create the coupon with
createCoupon— choosepercent_offoramount_off + currency, plusduration(once,repeating,forever). Forrepeating, setduration_in_months. - Optionally create promotion codes with
createPromotionCodereferencing thecoupon_id. The same coupon can back many codes. - Validate a code before applying with
validatePromotionCode— returnsvalid, the resolvedcoupon, and adiscount_preview. - Apply to a subscription via
applySubscriptionDiscount(pass eithercoupon_idorpromotion_code); scope to a single subscription item withsubscription_item_idif needed. - Remove with
removeSubscriptionDiscountto end the discount before its natural expiry. Coupons and promotion codes can be soft-disabled viaactive: false(updateCoupon/updatePromotionCode) or deleted outright.
Relationships
A PromotionCodeData always points at one CouponData (coupon_id). When applied to a subscription, both surface as a SubscriptionDiscount row referencing coupon_id and/or promotion_code_id. Coupons may be scoped to a subset of products via applies_to_products, in which case only invoice line items whose price_id belongs to one of those products receive the discount.
Fields that matter
- Coupon
duration(once|repeating|forever) — controls how many billing cycles the discount applies for.repeatingrequiresduration_in_months. - Coupon
percent_off(number, 0–100) oramount_off(number, smallest currency unit) — exactly one is set;amount_offrequirescurrency. - Coupon
max_redemptions/times_redeemed— global cap across all customers;applies_to_productsscopes the discount to specific products. - Promotion code
code(string) — the human-typed token. Case is preserved as stored. - Promotion code
first_time_only(boolean) — restricts to a customer's first redemption against this coupon family. - Promotion code
minimum_amount(number) — the invoice or subscription subtotal that must be reached for the code to apply.