Skip to main content
POST
/
coupons
Create coupon
curl --request POST \
  --url https://api.affonso.io/v1/coupons \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "affiliate_id": "<string>",
  "code": "<string>",
  "discount_type": "percentage",
  "discount_value": 50,
  "duration": "forever",
  "duration_in_months": 2,
  "currency": "<string>",
  "product_ids": [
    "<string>"
  ]
}
'
{
  "success": true,
  "data": {
    "id": "<string>",
    "affiliate_id": "<string>",
    "program_id": "<string>",
    "code": "<string>",
    "discount_type": "percentage",
    "discount_value": 123,
    "duration": "forever",
    "duration_in_months": 123,
    "product_ids": [
      "<string>"
    ],
    "provider": "stripe",
    "provider_coupon_id": "<string>",
    "provider_promo_code_id": "<string>",
    "created_at": "2023-11-07T05:31:56Z",
    "updated_at": "2023-11-07T05:31:56Z"
  }
}

Authorizations

Authorization
string
header
required

API key authentication. Prefix with 'sk_live_' for production or 'sk_dev_' for development.

Body

application/json
affiliate_id
string
required

ID of the affiliate to create the coupon for

code
string
required

Promotional code. Can only contain letters, numbers, and hyphens. Will be converted to uppercase.

Required string length: 1 - 50
discount_type
enum<string>
required

Type of discount. Note: DODO only supports 'percentage'

Available options:
percentage,
fixed
discount_value
number
required

Discount amount. For percentage: 0-100. For fixed: the amount in the specified currency.

Required range: 0 <= x <= 100
duration
enum<string>
required

How long the discount applies. 'repeating' requires duration_in_months.

Available options:
forever,
once,
repeating
duration_in_months
integer

Required when duration is 'repeating'. Number of months the discount applies.

Required range: x >= 1
currency
string

Required when discount_type is 'fixed'. 3-letter ISO currency code (e.g., USD, EUR).

Required string length: 3
product_ids
string[]

List of product IDs to restrict the coupon to. Required for CREEM provider.

Response

Coupon created

success
boolean
data
object