coupons

Stable. Describes behaviour that is built and covered by tests in this repository.

API reference

GET /v1/coupons #

Coupons, newest first

Not paged: the response is the complete list.

Responses

StatusMeaningBody
200OKListCouponsResponse
Example response
{
  "coupons": [
    {
      "code": "string",
      "name": "string",
      "id": "0192f0b4-6f6e-7c3a-9a3e-6a1f2b3c4d5e",
      "percent_bps": 1,
      "amount_minor": "string",
      "currency": "string",
      "bonus_percent_bps": 1,
      "applies_to": [
        "COUPON_TARGET_SUBSCRIPTION"
      ],
      "duration": "COUPON_DURATION_ONCE",
      "duration_periods": 1,
      "max_redemptions": 1,
      "redeemed": 1,
      "expire_time": "2026-11-03T10:15:00Z",
      "active": false,
      "create_time": "2026-11-03T10:15:00Z",
      "promotion_code_count": 1,
      "without_default_code": false
    }
  ]
}
curl
curl -X GET https://YOUR-API-ADDRESS/v1/coupons \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY"

POST /v1/coupons #

Make a coupon

Request body

FieldTypeDescription
code requiredstring2–40 letters, digits, - or _
namestring
idstring · uuid
percent_bpsinteger1000 is 10 %. Use one of percent_bps, amount_minor and bonus_percent_bps
amount_minorstring · int64Minor units of currency; applies only in that currency
currencystring
bonus_percent_bpsintegerExtra credits on a credit purchase, in the same lot: 1000 is 10 % more. Credit purchases only
applies_toarray of COUPON_TARGET_SUBSCRIPTION | COUPON_TARGET_CREDIT_PURCHASE | COUPON_TARGET_PAYMENTWhere the coupon works; empty means all three (a bonus coupon: credit purchases)
durationCOUPON_DURATION_ONCE | COUPON_DURATION_REPEATING | COUPON_DURATION_FOREVERHow long a subscription keeps the coupon; required when it applies to subscriptions
duration_periodsintegerFor a repeating coupon, how many fees
max_redemptionsinteger0 or absent = unlimited. Counts the uses through all the coupon's codes
redeemedintegerThe uses that count against the limit
expire_timestring · date-time
activeboolean
create_timestring · date-time
promotion_code_countinteger
without_default_codebooleanDo not make the promotion code with the coupon's own text that a new coupon gets
Example
{
  "code": "string"
}

Responses

StatusMeaningBody
201CreatedCoupon
400Error envelopeError
409Error envelopeError
Example response
{
  "code": "string",
  "name": "string",
  "id": "0192f0b4-6f6e-7c3a-9a3e-6a1f2b3c4d5e",
  "percent_bps": 1,
  "amount_minor": "string",
  "currency": "string",
  "bonus_percent_bps": 1,
  "applies_to": [
    "COUPON_TARGET_SUBSCRIPTION"
  ],
  "duration": "COUPON_DURATION_ONCE",
  "duration_periods": 1,
  "max_redemptions": 1,
  "redeemed": 1,
  "expire_time": "2026-11-03T10:15:00Z",
  "active": false,
  "create_time": "2026-11-03T10:15:00Z",
  "promotion_code_count": 1,
  "without_default_code": false
}
curl
curl -X POST https://YOUR-API-ADDRESS/v1/coupons \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"string"}'

DELETE /v1/coupons/{code} #

Stop new redemptions of a coupon (subscriptions that have it keep it)

Parameters

NameInTypeDescription
code requiredpathstring

Responses

StatusMeaningBody
200OKCoupon
404Error envelopeError
Example response
{
  "code": "string",
  "name": "string",
  "id": "0192f0b4-6f6e-7c3a-9a3e-6a1f2b3c4d5e",
  "percent_bps": 1,
  "amount_minor": "string",
  "currency": "string",
  "bonus_percent_bps": 1,
  "applies_to": [
    "COUPON_TARGET_SUBSCRIPTION"
  ],
  "duration": "COUPON_DURATION_ONCE",
  "duration_periods": 1,
  "max_redemptions": 1,
  "redeemed": 1,
  "expire_time": "2026-11-03T10:15:00Z",
  "active": false,
  "create_time": "2026-11-03T10:15:00Z",
  "promotion_code_count": 1,
  "without_default_code": false
}
curl
curl -X DELETE https://YOUR-API-ADDRESS/v1/coupons/<code> \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY"

POST /v1/coupons/{code}/promotion-codes #

Make promotion codes for a coupon

Name the codes (2-40 letters, digits, - or _; the same in any case) or ask for count random ones (1-1000, prefix + 8 characters without 0, O, 1, I, L). Every code gets the template's limit, expiry and restrictions.

Parameters

NameInTypeDescription
code requiredpathstring

Request body

FieldTypeDescription
templatePromotionCodeInputWhat a customer types. Many codes point to one coupon, each with its own limit, expiry and restrictions.
codesarray of stringName the codes, or ask for count
countinteger
prefixstringFor random codes; at most 20 characters
Example
{}

Responses

StatusMeaningBody
201CreatedCreatePromotionCodesResponse
400Error envelopeError
404Error envelopeError
409Error envelopeError
Example response
{
  "codes": [
    {
      "id": "0192f0b4-6f6e-7c3a-9a3e-6a1f2b3c4d5e",
      "coupon_id": "0192f0b4-6f6e-7c3a-9a3e-6a1f2b3c4d5e",
      "coupon_code": "string",
      "code": "string",
      "active": false,
      "max_redemptions": 1,
      "redeemed": 1,
      "expire_time": "2026-11-03T10:15:00Z",
      "first_purchase_only": false,
      "one_per_customer": false,
      "min_amount_minor": "string",
      "min_amount_currency": "string",
      "allowed_plans": [
        "string"
      ],
      "allowed_packs": [
        "string"
      ],
      "allowed_currencies": [
        "string"
      ],
      "restore_on_reversal": false,
      "create_time": "2026-11-03T10:15:00Z"
    }
  ]
}
curl
curl -X POST https://YOUR-API-ADDRESS/v1/coupons/<code>/promotion-codes \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{}'

Models

Coupon

FieldTypeDescription
code requiredstring2–40 letters, digits, - or _
name requiredstring
id requiredstring · uuid
percent_bps requiredinteger1000 is 10 %. Use one of percent_bps, amount_minor and bonus_percent_bps
amount_minor requiredstring · int64Minor units of currency; applies only in that currency
currency requiredstring
bonus_percent_bps requiredintegerExtra credits on a credit purchase, in the same lot: 1000 is 10 % more. Credit purchases only
applies_to requiredarray of COUPON_TARGET_SUBSCRIPTION | COUPON_TARGET_CREDIT_PURCHASE | COUPON_TARGET_PAYMENTWhere the coupon works; empty means all three (a bonus coupon: credit purchases)
duration requiredCOUPON_DURATION_ONCE | COUPON_DURATION_REPEATING | COUPON_DURATION_FOREVERHow long a subscription keeps the coupon; required when it applies to subscriptions
duration_periods requiredintegerFor a repeating coupon, how many fees
max_redemptions requiredinteger0 or absent = unlimited. Counts the uses through all the coupon's codes
redeemed requiredintegerThe uses that count against the limit
expire_time requiredstring · date-time
active requiredboolean
create_time requiredstring · date-time
promotion_code_count requiredinteger
without_default_code requiredbooleanDo not make the promotion code with the coupon's own text that a new coupon gets

CouponInput

FieldTypeDescription
code requiredstring2–40 letters, digits, - or _
namestring
idstring · uuid
percent_bpsinteger1000 is 10 %. Use one of percent_bps, amount_minor and bonus_percent_bps
amount_minorstring · int64Minor units of currency; applies only in that currency
currencystring
bonus_percent_bpsintegerExtra credits on a credit purchase, in the same lot: 1000 is 10 % more. Credit purchases only
applies_toarray of COUPON_TARGET_SUBSCRIPTION | COUPON_TARGET_CREDIT_PURCHASE | COUPON_TARGET_PAYMENTWhere the coupon works; empty means all three (a bonus coupon: credit purchases)
durationCOUPON_DURATION_ONCE | COUPON_DURATION_REPEATING | COUPON_DURATION_FOREVERHow long a subscription keeps the coupon; required when it applies to subscriptions
duration_periodsintegerFor a repeating coupon, how many fees
max_redemptionsinteger0 or absent = unlimited. Counts the uses through all the coupon's codes
redeemedintegerThe uses that count against the limit
expire_timestring · date-time
activeboolean
create_timestring · date-time
promotion_code_countinteger
without_default_codebooleanDo not make the promotion code with the coupon's own text that a new coupon gets

CreatePromotionCodes

FieldTypeDescription
templatePromotionCodeInputWhat a customer types. Many codes point to one coupon, each with its own limit, expiry and restrictions.
codesarray of stringName the codes, or ask for count
countinteger
prefixstringFor random codes; at most 20 characters

CreatePromotionCodesResponse

FieldTypeDescription
codes requiredarray of PromotionCode

Error

FieldTypeDescription
error requiredobject

ListCouponsResponse

FieldTypeDescription
coupons requiredarray of Coupon

PromotionCode

FieldTypeDescription
id requiredstring · uuid
coupon_id requiredstring · uuid
coupon_code requiredstring
code requiredstring
active requiredboolean
max_redemptions requiredinteger0 or absent = unlimited
redeemed requiredinteger
expire_time requiredstring · date-time
first_purchase_only requiredbooleanOnly a customer who has paid for nothing yet
one_per_customer requiredboolean
min_amount_minor requiredstring · int64A purchase under this amount cannot use the code; needs min_amount_currency
min_amount_currency requiredstring
allowed_plans requiredarray of stringPlan codes; empty means any
allowed_packs requiredarray of stringCredit pack ids; empty means any
allowed_currencies requiredarray of stringEmpty means any
restore_on_reversal requiredbooleanA void or full refund gives the use back to the count. Off by default
create_time requiredstring · date-time

PromotionCodeInput

FieldTypeDescription
idstring · uuid
coupon_idstring · uuid
coupon_codestring
codestring
activeboolean
max_redemptionsinteger0 or absent = unlimited
redeemedinteger
expire_timestring · date-time
first_purchase_onlybooleanOnly a customer who has paid for nothing yet
one_per_customerboolean
min_amount_minorstring · int64A purchase under this amount cannot use the code; needs min_amount_currency
min_amount_currencystring
allowed_plansarray of stringPlan codes; empty means any
allowed_packsarray of stringCredit pack ids; empty means any
allowed_currenciesarray of stringEmpty means any
restore_on_reversalbooleanA void or full refund gives the use back to the count. Off by default
create_timestring · date-time