Coupons
A coupon carries the discount rules. Onlyname is required — everything else falls back to a default.
string
required
Internal name for the coupon. Also usable as a lookup key on
GET /coupons.string
default:"PERCENTAGE"
PERCENTAGE or FLAT. A PERCENTAGE coupon requires percentOff between 1 and 100. A FLAT
coupon requires both amountOff and currency.string
default:"forever"
once, forever, or repeating. A repeating coupon requires durationInMonths.integer
Total redemptions allowed across every promotional code attached to this coupon.
string
ISO 8601 date after which the coupon can no longer be redeemed.
boolean
default:"false"
Restrict the discount to the products listed in
productIds.string
The identifier for this discount in your payment platform, such as a Stripe coupon ID. Must be
unique in your program — reusing one returns
400.Create a coupon
cURL
promotionalCodes array, so a single GET /coupons call gives you the discount and every code that uses it. See Create a Coupon for the full field list.
Creating a coupon through the API records it in Referly only. It does not create the matching
coupon in Stripe or any other payment platform — set
externalId to point at a discount that
already exists there.Promotional codes
A promotional code always belongs to a coupon and inherits its discount. Assigning it to an affiliate is what makes it trackable.string
required
The parent coupon. Returns
404 if the coupon does not belong to your program.string
The customer-facing string. Required unless you are auto-generating the code. Must be unique across
your program.
string
The affiliate who gets credit for redemptions. You can pass
affiliateEmail instead. Returns 404
if the affiliate is not in your program.boolean
default:"false"
Restrict the code so only the assigned affiliate can redeem it.
boolean
default:"false"
Restrict the code to a customer’s first order.
number
Minimum order value required, paired with
minimumAmountCurrency.string
ISO 8601 date after which the code stops working, independent of the coupon’s
redeemBy.Create a code for an affiliate
cURL
Auto-generate a code
Instead of inventing a string yourself, setisAutoGenerated to true and describe the shape of the code with codeStructure. An affiliate is required, because the generator reads their details.
cURL
REFJANE20K7QZ.
Generation happens once, at creation. If the resulting string is already taken, the request fails with 400 rather than retrying with a different one, so include randomChars when you generate codes in bulk.
Attribute a sale to a code
When a customer checks out with a promotional code instead of clicking a referral link, passpromoCode to Create a Sale. Referly resolves the affiliate from the code, so you do not send referralId or email.
cURL
400 when the code does not exist in your program, is not active, has expired, has no affiliate assigned, or when either the code or its parent coupon has hit its redemption limit.
On a successful sale, Referly increments timesRedeemed on both the promotional code and its coupon, which is what those limits are checked against.
Look up coupons and codes
BothGET endpoints accept several identifiers and return either a single object or an array.
Use
couponId to see every code issued from one discount, or affiliateEmail to see every code an affiliate holds.
List one affiliate's codes
Update and delete
Updates are identified bycouponId or promotionalCodeId in the request body, not by a path parameter.
Changing a coupon changes the discount for every code attached to it — that is the main reason to use the two-tier model. Deleting a coupon cascades: its promotional codes are deleted with it. To retire a single code without deleting it, set active to false with Update a Promotional Code.
Errors
Failures return a JSON object with anerror message.
See Authentication for how to generate an API key.
Related
Coupon endpoints
Create, read, update, and delete coupons.
Promotional code endpoints
Create, read, update, and delete promotional codes.
Create a Sale
Attribute a sale with a promo code.
Affiliates and referral links
Attribute sales with tracking links instead of codes.