Skip to main content
POST
/
v1
/
coupons
curl -X POST "https://api.affonso.io/v1/coupons" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "affiliate_id": "aff_123",
    "code": "SAVE25",
    "discount_type": "percentage",
    "discount_value": 25,
    "duration": "forever"
  }'
{
  "success": true,
  "data": {
    "id": "cpn_abc123",
    "code": "SAVE25",
    "affiliate_id": "aff_123",
    "discount_type": "percentage",
    "discount_value": 25,
    "duration": "forever",
    "duration_in_months": null,
    "currency": null,
    "product_ids": [],
    "created_at": "2024-01-15T10:30:00Z"
  }
}
Create a new promotional coupon for an affiliate. The coupon is created at your payment provider and linked to the affiliate in Affonso.
Coupon creation rules vary by payment provider:
  • DODO: Only supports percentage discounts
  • CREEM: Requires at least one product_id
  • All providers: duration_in_months required when duration is repeating
  • All providers: currency required when discount_type is fixed

Body Parameters

affiliate_id
string
required
The ID of the affiliate who will own this coupon.
code
string
required
The coupon code. Must be 1-50 characters, alphanumeric characters and hyphens only. Will be converted to uppercase.
discount_type
string
required
Type of discount to apply. Valid values: percentage, fixed.
discount_value
number
required
The discount amount. For percentage: value between 0-100. For fixed: the discount amount in the specified currency.
duration
string
required
How long the discount applies. Valid values:
  • forever: Discount applies to all future invoices
  • once: Discount applies only to the first invoice
  • repeating: Discount repeats for a specified number of months
duration_in_months
integer
Number of months the discount repeats. Required when duration is repeating.
currency
string
Three-letter currency code (e.g., USD, EUR, GBP). Required when discount_type is fixed.
product_ids
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.
success
boolean
Always true for successful responses
data
object
The created coupon object.
curl -X POST "https://api.affonso.io/v1/coupons" \
  -H "Authorization: Bearer sk_live_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "affiliate_id": "aff_123",
    "code": "SAVE25",
    "discount_type": "percentage",
    "discount_value": 25,
    "duration": "forever"
  }'
{
  "success": true,
  "data": {
    "id": "cpn_abc123",
    "code": "SAVE25",
    "affiliate_id": "aff_123",
    "discount_type": "percentage",
    "discount_value": 25,
    "duration": "forever",
    "duration_in_months": null,
    "currency": null,
    "product_ids": [],
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Error Responses

409 Conflict
Returned when a coupon with the same code already exists.
502 Bad Gateway
Returned when the payment provider fails to create the coupon.