Skip to main content
POST
/
v1
/
coupons
Create a coupon
curl --request POST \
  --url https://api.yorlet.com/v1/coupons \
  --header 'Authorization: <api-key>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>",
  "amount_off": 123,
  "applies_to": {
    "invoice_item_types": []
  },
  "currency": "<string>",
  "duration_in_months": 2,
  "max_redemptions": 2,
  "metadata": {},
  "percent_off": 50.5,
  "redeem_by": 123
}
'
{
  "id": "<string>",
  "created": 123,
  "object": "coupon",
  "amount_off": 123,
  "applies_to": {
    "invoice_item_types": [
      "<string>"
    ]
  },
  "currency": "<string>",
  "duration": "<string>",
  "duration_in_months": 123,
  "max_redemptions": 123,
  "metadata": {},
  "name": "<string>",
  "percent_off": 123,
  "redeem_by": 123,
  "valid": true,
  "account": "<string>",
  "deleted": false,
  "times_redeemed": 0
}

Authorizations

Authorization
string
header
required

API Key authentication. Use "Bearer YOUR_API_KEY".

Body

application/json
name
string
required

Name of the coupon displayed to customers on, for instance, invoices or receipts.

amount_off
number

A positive integer representing the amount to subtract from an invoice total (required if percent_off is not passed).

applies_to
object

A hash containing directions for what this coupon will apply discounts to.

currency
string

Three-letter ISO code for the currency of the amount_off parameter (required if amount_off is passed).

duration
enum<string>

Specifies how long the discount will be in effect if used on a subscription.

Available options:
repeating,
once,
forever
duration_in_months
number

Required only if duration is repeating, in which case it must be a positive integer that specifies the number of months the discount will be in effect.

Required range: x >= 1
max_redemptions
number

A positive integer specifying the number of times the coupon can be redeemed before it is no longer valid.

Required range: x >= 1
metadata
object

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

percent_off
number

A positive float larger than 0, and smaller or equal to 100, that represents the discount the coupon will apply (required if amount_off is not passed).

Required range: 1 <= x <= 100
redeem_by
integer

Unix timestamp specifying the last time at which the coupon can be redeemed.

Response

200 - application/json

Create a coupon

id
string
required

Unique identifier for the object.

created
number
required

Time at which the object was created. Measured in seconds since the Unix epoch.

object
enum<string>
required
Available options:
coupon
amount_off
number | null
required

The fixed amount that will be taken off the subtotal of any invoices for this customer.

applies_to
object
required

Details on what the coupon can be applied to.

currency
string
required

Three-letter ISO currency code, in lowercase. Must be a supported currency.

duration
string | null
required

Describes how long a customer who applies this coupon will get the discount.

duration_in_months
number | null
required

If duration is repeating, the number of months the coupon applies. Null if coupon does not have a duration in months.

max_redemptions
number | null
required

Maximum number of times this coupon can be redeemed, in total, before it is no longer valid.

metadata
object
required

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.

name
string | null
required

Name of the coupon displayed to customers on, for instance, invoices or receipts.

percent_off
number | null
required

Percent that will be taken off the subtotal of any invoices for this customer for the duration of the coupon.

redeem_by
number | null
required

Date after which the coupon can no longer be redeemed.

valid
boolean
required

Whether the coupon is currently valid and can still be redeemed.

account
string

The account that the object belongs to. Only returned if the request is made with a valid Yorlet-Context header.

deleted
boolean
default:false

Only returned if the object has been deleted.

times_redeemed
number
default:0

Number of times this coupon has been applied to a customer.