HomeProduct DocsAPI ReferenceChangelog
RecurlyAPI GuidesRecurly.jsWebhooksAPI ReferenceSupportBook demo
API Reference

Create Coupon

Creates a new coupon. Please note: coupons cannot be updated after being created.

DISCOUNT IN DOLLARS
When specifying a discount amount as a flat amount, the currency must be specified with the amount in an array. For example:

<discount_type>dollars</discount_type>
<discount_in_cents>
  <USD>500</USD>
  <EUR>400</EUR>
  <GBP>300</GBP>
</discount_in_cents>

DISCOUNT IN PERCENTAGE
Percentage discounts only need to specify the discount percentage. For example:

<discount_type>percent</discount_type>
<discount_percent>10</discount_percent>

LIMITING TO SPECIFIC PLANS
If a coupon applies to all plans, it will also apply to any plans created in the future. To limit a coupon to specific plans, you may specify an array of plan codes. For example:

<applies_to_all_plans>false</applies_to_all_plans>
<plan_codes>
  <plan_code>silver</plan_code>
  <plan_code>gold</plan_code>
</plan_codes>

LIMITING TO SPECIFIC ITEMS
To limit a coupon to specific items, you may specify an array of item codes. For example:

<applies_to_all_items>false</applies_to_all_items>
<item_codes>
  <item_code>terracotta</item_code>
  <item_code>terrazzo</item_code>
  <item_code>marble</item_code>
</item_codes>

CREATING UNIQUE CODE TEMPLATES
If you are creating a bulk coupon, you will need to create a unique_code_template. Here are the rules:

  1. You must start the template with your coupon_code wrapped in single quotes.
  2. Outside of single quotes, use a 9 for a character that you want to be a random number.
  3. Outside of single quotes, use an "x" for a character that you want to be a random letter.
  4. Outside of single quotes, use an * for a character that you want to be a random number or letter.
  5. Use single quotes ' ' for characters that you want to remain static. These strings can be alphanumeric and may contain a - _ or +.
<coupon_code>thankyou</coupon_code>
<coupon_type>bulk</coupon_type>
<unique_code_template>'thankyou'99999999</unique_code_template>

This example will create a unique code like: thankyou41863675

Recent Requests
Log in to see full request history
TimeStatusUser Agent
Retrieving recent requests…
LoadingLoading…
Body Params
string
required

Unique code to identify and redeem the coupon. This code may only contain the following characters: [a-z A-Z 0-9 + - _ ]. Max of 50 characters.

string
required

Coupon name.

string

Description of the coupon on the hosted payment pages.

string
required

percent, dollars, or free_trial.

integer

Mapping of discount amounts by currency if discount_type is dollars. Max 10000000.

integer

Discount percentage if discount_type is percent.

string

Description of the coupon on the invoice.

date-time

Last date to redeem the coupon, defaults to no date.

boolean

DEPRECATED: Please use duration. If true, the coupon applies to the first invoice only.

integer

DEPRECATED: Please use temporal_unit and temporal_amount. Number of months after redemption that the coupon is valid, defaults to no date.

integer

Maximum number of accounts that may use the coupon before it can no longer be redeemed.

boolean
Defaults to true

The coupon is valid for all plans if true, defaults to true.

boolean
Defaults to false

The coupon is valid for all items if true, defaults to false.

string
Defaults to forever

forever, single_use, or temporal. If single_use, the coupon applies to the first invoice only. If temporal the coupon will apply to invoices for the duration determined by the temporal_unit and temporal_amount attributes.

string

day, week, month, or year. If duration is temporal then temporal_unit is multiplied by temporal_amount to define the duration that the coupon will be applied to invoices for.

integer

If duration is temporal then temporal_amount is an integer which is multiplied by temporal_unit to define the duration that the coupon will be applied to invoices for.

boolean
Defaults to false

The coupon is valid for one-time, non-plan charges if true, defaults to false.

string
Defaults to account

Whether the discount is for all eligible charges on the account, or only a specific subscription. Values are account or subscription.

integer

The number of times the coupon can be redeemed on a specific account. null is the default and means unlimited.

string
Defaults to single_code

Whether the coupon is single_code or bulk. Bulk coupons will require a unique_code_template and will generate unique codes through the generate endpoint.

string

The template for generating unique codes. See rules below for creating unique code templates.

plan_codes
array of strings

Array of plan_codes the coupon applies to, if applies_to_all_plans is false.

plan_codes
item_codes
array of strings

Array of item_codes the coupone applies to, if applies_to_all_items is false.

item_codes
integer

Only relevant when the coupon type is free_trial. The free_trial_amount is used together with free_trial_unit to define the length of a free trial coupon. For example, a 2 week free trial would be defined as free_trial_amount = 2 and free_trial_unit = Week.

string

Only relevant when the coupon type is free_trial. Allowed values are day or week or month. free_trial_unit is used together with free_trial_unit to define the length of a free trial coupon. For example, a 2 week free trial would be defined as free_trial_amount = 2 and free_trial_unit = Week.

Response

Language
Credentials
Basic
base64
:
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/xml