Coupons
Create Coupon
Generate a new promotional coupon for an affiliate
POST
Create a new promotional coupon for an affiliate. The coupon is created at your payment provider and linked to the affiliate in Affonso.
Body Parameters
string
required
The ID of the affiliate who will own this coupon.
string
required
The coupon code. Must be 1-50 characters, alphanumeric characters and hyphens only. Will be converted to uppercase.
string
required
Type of discount to apply. Valid values:
percentage, fixed.number
required
The discount amount. For
percentage: value between 0-100. For fixed: the discount amount in the specified currency.string
required
How long the discount applies. Valid values:
forever: Discount applies to all future invoicesonce: Discount applies only to the first invoicerepeating: Discount repeats for a specified number of months
integer
Number of months the discount repeats. Required when
duration is repeating.string
Three-letter currency code (e.g.,
USD, EUR, GBP). Required when discount_type is fixed.array
Array of product IDs to restrict this coupon to. Leave empty or omit to apply to all products.
Response
The response includes the created coupon object.boolean
Always
true for successful responsesobject
The created coupon object.
Error Responses
Returned when the specified affiliate does not exist or does not belong to your team.
Error code:
NOT_FOUNDReturned when the affiliate has no program partnership or the program has no payment provider configured.
Error code:
VALIDATION_ERRORReturned when a coupon with the same code already exists in the program, or when the affiliate already has a coupon for this program.
Error code:
DUPLICATE_ERRORReturned when the payment provider fails to create the coupon.
