Commerce
createCoupon
Create Coupon
Mint ONE discount code for a shop.
Arguments
appIdstringrequiredThe Studio app ID whose shop is offering it.codestringrequiredThe code buyers type, e.g. SAVE5. Case-insensitive, unique per shop.typestringrequiredflat takes an amount off; percent takes a share off.valuenumberrequiredFor flat: minor units off, e.g. 500 = $5.00. For percent: whole percent, e.g. 10 = 10% (max 100).minSubtotalMinorintegeroptionalSmallest cart the code works on, in minor units (2000 = a $20 cart). Omit for no minimum.startsAtnumberoptionalEpoch ms the code starts working. Omit to start immediately.endsAtnumberoptionalEpoch ms the code stops working. Omit for no expiry.maxRedemptionsintegeroptionalTotal redemptions across all buyers, ever. This is the HARD bound: it holds even for an anonymous checkout with no email. Omit for unlimited.perCustomerLimitintegeroptionalRedemptions allowed per buyer. Counted per email, so it only bites where a buyer identity is known before payment; maxRedemptions is what always holds.firstOrderOnlybooleanoptionalRedeemable only by someone with no paid order at this shop yet. Same identity caveat as perCustomerLimit.
Returns
The registry does not declare a return shape.
Declared limits
value: greater than 0minSubtotalMinor: minimum 0minSubtotalMinor: maximum 9007199254740991maxRedemptions: greater than 0maxRedemptions: maximum 9007199254740991perCustomerLimit: greater than 0perCustomerLimit: maximum 9007199254740991
Ask for it
The Cloud routes these requests to this verb.
- make a SAVE5 code
- create a 10% off coupon
- set up a first-order discount
Pair it with
The verbs that finish the job.