Create a Promotional Code
Creates a promotional code against an existing coupon. couponId is always required — the coupon supplies the discount.
There are two ways to create a code:
- Give it yourself. Send
codewith the exact string you want. It must be unique within the program. - Have it generated. Set
isAutoGeneratedtotrueand sendcodeStructuredescribing which pieces to combine — the affiliate’s first name, last name, email prefix, the discount value, the coupon name, and/or random characters. An affiliate is required in this mode, and you can shape the result further withprefix,randomCharsLengthandrandomCharsCase.
Assign the code to an affiliate with affiliateId or affiliateEmail so their redemptions are tracked. Assigned codes are also connected to that affiliate’s links automatically in the background.
Fires the promotional_code.created webhook.
Creating Promotional Codes
Create promotional codes that customers can use at checkout. Each promotional code must be linked to an existing coupon.Manual vs Auto-Generated Codes
Manual Codes
Specify the exact code string you want to create:Auto-Generated Codes
Let the system generate codes based on a structure:SAVEJOHN8X4Z
Code Structure Options
When using auto-generated codes, you can combine:- firstName: Include affiliate’s first name
- lastName: Include affiliate’s last name
- email: Include part of affiliate’s email (before @)
- discountAmount: Include the discount value
- couponName: Include the coupon name
- randomChars: Add random characters
Additional Settings
- active: Whether the code is currently active
- expiresAt: Expiration date for the code
- maxRedemptions: Maximum number of times the code can be used
- firstTimeOrder: Limit to first-time customers only
- minimumAmount: Minimum purchase amount required
- limitToAffiliate: Only the affiliate can use this code
- limitToCustomers: Restrict to specific customers
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The promotional code to create
The coupon ID this promotional code belongs to
The exact code string customers will type. Required unless isAutoGenerated is true. Must be unique within the program.
"JANE20"
Assign the code to this affiliate so their redemptions are credited. Required when isAutoGenerated is true unless affiliateEmail is supplied.
Assign the code to the affiliate with this email address. Alternative to affiliateId.
The code's ID in the connected billing provider, for example a Stripe promotion code ID
Whether the code is active (default: true)
Expiration date
Maximum redemptions
Limit to first-time orders (default: false)
Minimum purchase amount
Currency for minimum amount
Limit to specific customers (default: false)
Specific customer ID
Only affiliate can use (default: false)
Generate the code from codeStructure instead of using code. Requires an affiliate.
Which pieces to combine into the generated code, in this order: first name, last name, email prefix, discount value, coupon name, then random characters. Required when isAutoGenerated is true.
String placed at the front of a generated code
Length of random characters (default: 4)
Case for random characters (default: mixed)
uppercase, lowercase, mixed Response
The created promotional code, with its parent coupon and assigned affiliate.
A code customers enter at checkout. Its discount comes from the coupon it belongs to.
The promotional code ID
The actual promotional code string
The parent coupon ID
The affiliate ID this code is assigned to
External ID (e.g., Stripe promotion code ID)
Whether the promotional code is active
Expiration date for the code
How many times this code can be redeemed. null means unlimited. Redemptions are also capped by the parent coupon's own limit.
Number of times this code has been redeemed
Whether this code is limited to first-time orders
Minimum purchase amount required
Currency for minimum amount
Whether code is limited to specific customers
Specific customer ID this code is limited to
Whether only the assigned affiliate may redeem this code
Whether this code was generated from a codeStructure rather than supplied by hand
Timestamp when the code was created
Timestamp when the code was last updated
The coupon this code takes its discount from
Affiliate details
Whether the affiliate created this code themselves from their portal