Coupons are discounts applied to invoices or invoice line items. A coupon discount can either be for a fixed amount or for a percentage of the amount of the invoice or line item.

API Index URL GET

https://{site}.chargebee.com/api/v2/coupons
id
Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.
string, max chars=50
name
The display name used in web interface for identifying the coupon.
string, max chars=50
invoice_name
Display name used in invoice. If it is not configured then name is used in invoice.
optional, string, max chars=100
discount_type
The type of discount.
enumerated string, default=percentage
Possible values are
fixed_amountThe specified amount will be given as discount.percentageThe specified percentage will be given as discount.
discount_percentage
Discount value in percentage.
optional, double, min=0.01, max=100.0
discount_amount
Discount value in cents.
optional, in cents, min=0
currency_code
The currency code (ISO 4217 format) of the coupon. Applicable for fixed_amount coupons alone.
optional, string, max chars=3
duration_type
Specifies the time duration this coupon is applicable.
enumerated string, default=forever
Possible values are
one_timeDiscount is applied once.foreverDiscount is applied for each billing cycle of the subscription.limited_periodDiscount is applied for the specified number of months.
duration_month
The duration in months for the coupon to be applied. Applicable only to limited period coupon.
optional, integer, min=1, max=240
valid_till
Date upto which the coupon can be applied to new subscriptions.
optional, timestamp(UTC) in seconds
max_redemptions
Maximum number of times this coupon can be redeemed.
optional, integer, min=1
status
Status of the coupon.
optional, enumerated string, default=active
Possible values are
activeCan be applied to a subscription.expiredCannot be applied to a subscription. A coupon may expire due to exceeding max redemptions or 'valid till' date is past. Existing associations remain unaffected.archivedCannot be applied to a subscription. Existing associations remain unaffected.deletedIndicates the coupon has been deleted.
apply_on
The invoice items for which this discounts need to be applied.
enumerated string
Possible values are
invoice_amountDiscount will be applied to the total invoice amount.each_specified_itemDiscount will be applied to each plan and addon item specified.
created_at
Timestamp indicating when this coupon is created.
timestamp(UTC) in seconds
archived_at
Timestamp indicating when this coupon was archived.
optional, timestamp(UTC) in seconds
resource_version
Version number of this resource. Each update of this resource results in incremental change of this number.
optional, long
updated_at
Timestamp indicating when this coupon was last updated. Note that this does not change when the 'redemptions' attribute is changed. This attribute will be present only if the resource has been updated after 2016-11-09.
optional, timestamp(UTC) in seconds
redemptions
The number of times this coupon has been redeemed.
optional, integer, min=0
invoice_notes
A customer-facing note added to all invoices associated with this API resource. This note becomes one among all the notes displayed on the invoice PDF.
optional, string, max chars=2000
item_constraints
Show attributes[+]
The list of items item constraints.
optional, list of item_constraint
Item constraint attributes
item_type
Item type for which this criteria is applicable for.
enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
constraint
Constraint applicable for the item.
enumerated string
Possible values are
noneCoupon not applicable to any items.allCoupon applicable to all items.specificCoupon applicable to specific items.criteriaCoupon applicable based on criteria.
item_price_ids
List of item price ids for which this coupon is applicable.
optional, jsonarray
item_constraint_criteria
Show attributes[+]
The list of items item constraint criteria.
optional, list of item_constraint_criteria
Item constraint criteria attributes
item_type
Item type for which this criteria is applicable for.
enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
currencies
List of currencies (ISO 4217 format) for which this coupon is applicable.
optional, jsonarray
item_family_ids
List of families for which this coupon is applicable.
optional, jsonarray
item_price_periods
List of frequencies for which this coupon is applicable. Allowed frequencies are [day, week, month, year].
optional, jsonarray
Create a new coupon.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/create_for_items \
     -u {site_api_key}:\
     -d id="summer_offer" \
     -d name="Summer Offer" \
     -d discount_percentage=10.0 \
     -d discount_type="percentage" \
     -d duration_type="forever" \
     -d apply_on="each_specified_item" \
     -d item_constraints[constraint][0]="all" \
     -d item_constraints[item_type][0]="plan"
copy
curl  https://{site}.chargebee.com/api/v2/coupons/create_for_items \
     -u {site_api_key}:\
     -d id="summer_offer" \
     -d name="Summer Offer" \
     -d discount_percentage=10.0 \
     -d discount_type="percentage" \
     -d duration_type="forever" \
     -d apply_on="each_specified_item" \
     -d item_constraints[constraint][0]="all" \
     -d item_constraints[item_type][0]="plan"

Sample Response [ JSON ]

Show more...
{"coupon": { "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "created_at": 1517475969, "discount_percentage": 10, "discount_type": "percentage", "duration_type": "forever", "id": "summer_offer", "item_constraints": [ { "constraint": "all", "item_type": "plan" }, {..} ], "name": "Summer Offer", "object": "coupon", "redemptions": 0, "resource_version": 1517475969000, "status": "active", "updated_at": 1517475969 }}

URL Format POST

https://{site}.chargebee.com/api/v2/coupons/create_for_items
id
Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.
required, string, max chars=50
name
The display name used in web interface for identifying the coupon.
required, string, max chars=50
invoice_name
Display name used in invoice. If it is not configured then name is used in invoice.
optional, string, max chars=100
discount_type
The type of discount.
required, enumerated string, default=percentage
Possible values are
fixed_amountThe specified amount will be given as discount.percentageThe specified percentage will be given as discount.
discount_amount
Discount value in cents.
optional, in cents, min=0
currency_code
The currency code (ISO 4217 format) of the coupon. Applicable for fixed_amount coupons alone.
required if Multicurrency is enabled, string, max chars=3
discount_percentage
Discount value in percentage.
optional, double, min=0.01, max=100.0
apply_on
The invoice items for which this discounts need to be applied.
required, enumerated string
Possible values are
invoice_amountDiscount will be applied to the total invoice amount.each_specified_itemDiscount will be applied to each plan and addon item specified.
duration_type
Specifies the time duration this coupon is applicable.
required, enumerated string, default=forever
Possible values are
one_timeDiscount is applied once.foreverDiscount is applied for each billing cycle of the subscription.limited_periodDiscount is applied for the specified number of months.
duration_month
The duration in months for the coupon to be applied. Applicable only to limited period coupon.
optional, integer, min=1, max=240
valid_till
Date upto which the coupon can be applied to new subscriptions.
optional, timestamp(UTC) in seconds
max_redemptions
Maximum number of times this coupon can be redeemed.
optional, integer, min=1
invoice_notes
A customer-facing note added to all invoices associated with this API resource. This note becomes one among all the notes displayed on the invoice PDF.
optional, string, max chars=2000
meta_data
A set of key-value pairs stored as additional information for the subscription. Learn more.
optional, jsonobject
included_in_mrr
The coupon is included in MRR calculations for your site. This attribute is only applicable for coupons of duration_type = one_time and when the feature is enabled in Chargebee. Note: If the site-level setting is to exclude one-time coupons from MRR calculations, this value is always returned false.
optional, boolean
status
Status of the coupon.
optional, enumerated string, default=active
Possible values are
activeCan be applied to a subscription.archivedCannot be applied to a subscription. Existing associations remain unaffected.
+
item_constraints
Parameters for item_constraints. Multiple item_constraints can be passed by specifying unique indices.
pass parameters as item_constraints[<param name>][<idx:0..n>]
item_constraints[constraint][0..n]
Constraint applicable for the item.
required, enumerated string
Possible values are
noneCoupon not applicable to any items.allCoupon applicable to all items.specificCoupon applicable to specific items.criteriaCoupon applicable based on criteria.
item_constraints[item_type][0..n]
Item type for which this criteria is applicable for.
required, enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
item_constraints[item_price_ids][0..n]
List of item price ids for which this coupon is applicable.
optional, jsonarray
+
item_constraint_criteria
Parameters for item_constraint_criteria. Multiple item_constraint_criteria can be passed by specifying unique indices.
pass parameters as item_constraint_criteria[<param name>][<idx:0..n>]
item_constraint_criteria[item_type][0..n]
Item type for which this criteria is applicable for.
optional, enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
item_constraint_criteria[item_family_ids][0..n]
List of families for which this coupon is applicable.
optional, jsonarray
item_constraint_criteria[currencies][0..n]
List of currencies (ISO 4217 format) for which this coupon is applicable.
optional, jsonarray
item_constraint_criteria[item_price_periods][0..n]
Pass the item price period units for this criterion. period followed by period_units. Such as [1 day,1 week,3 month,6 month].
optional, jsonarray
Resource object representing coupon.
always returned
Update a coupon.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/sample_coupon/update_for_items \
     -u {site_api_key}:\
     -d discount_percentage=20.0 \
     -d item_constraints[constraint][0]="all" \
     -d item_constraints[item_type][0]="plan" \
     -d item_constraints[constraint][1]="all" \
     -d item_constraints[item_type][1]="addon"
copy
curl  https://{site}.chargebee.com/api/v2/coupons/sample_coupon/update_for_items \
     -u {site_api_key}:\
     -d discount_percentage=20.0 \
     -d item_constraints[constraint][0]="all" \
     -d item_constraints[item_type][0]="plan" \
     -d item_constraints[constraint][1]="all" \
     -d item_constraints[item_type][1]="addon"

Sample Response [ JSON ]

Show more...
{"coupon": { "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "created_at": 1517475969, "discount_percentage": 20, "discount_type": "percentage", "duration_type": "forever", "id": "sample_coupon", "item_constraints": [ { "constraint": "all", "item_type": "plan" }, {..} ], "name": "Sample Coupon", "object": "coupon", "redemptions": 0, "resource_version": 1517475969000, "status": "active", "updated_at": 1517475969 }}

URL Format POST

https://{site}.chargebee.com/api/v2/coupons/{coupon_id}/update_for_items
name
The display name used in web interface for identifying the coupon.
optional, string, max chars=50
invoice_name
Display name used in invoice. If it is not configured then name is used in invoice.
optional, string, max chars=100
discount_type
The type of discount.
optional, enumerated string, default=percentage
Possible values are
fixed_amountThe specified amount will be given as discount.percentageThe specified percentage will be given as discount.
discount_amount
Discount value in cents.
optional, in cents, min=0
currency_code
The currency code (ISO 4217 format) of the coupon. Applicable for fixed_amount coupons alone.
required if Multicurrency is enabled, string, max chars=3
discount_percentage
Discount value in percentage.
optional, double, min=0.01, max=100.0
apply_on
The invoice items for which this discounts need to be applied.
optional, enumerated string
Possible values are
invoice_amountDiscount will be applied to the total invoice amount.each_specified_itemDiscount will be applied to each plan and addon item specified.
duration_type
Specifies the time duration this coupon is applicable.
optional, enumerated string, default=forever
Possible values are
one_timeDiscount is applied once.foreverDiscount is applied for each billing cycle of the subscription.limited_periodDiscount is applied for the specified number of months.
duration_month
The duration in months for the coupon to be applied. Applicable only to limited period coupon.
optional, integer, min=1, max=240
valid_till
Date upto which the coupon can be applied to new subscriptions.
optional, timestamp(UTC) in seconds
max_redemptions
Maximum number of times this coupon can be redeemed.
optional, integer, min=1
invoice_notes
A customer-facing note added to all invoices associated with this API resource. This note becomes one among all the notes displayed on the invoice PDF.
optional, string, max chars=2000
meta_data
A set of key-value pairs stored as additional information for the subscription. Learn more.
optional, jsonobject
included_in_mrr
The coupon is included in MRR calculations for your site. This attribute is only applicable for coupons of duration_type = one_time and when the feature is enabled in Chargebee. Note: If the site-level setting is to exclude one-time coupons from MRR calculations, this value is always returned false.
optional, boolean
+
item_constraints
Parameters for item_constraints. Multiple item_constraints can be passed by specifying unique indices.
pass parameters as item_constraints[<param name>][<idx:0..n>]
item_constraints[constraint][0..n]
Constraint applicable for the item.
required, enumerated string
Possible values are
noneCoupon not applicable to any items.allCoupon applicable to all items.specificCoupon applicable to specific items.criteriaCoupon applicable based on criteria.
item_constraints[item_type][0..n]
Item type for which this criteria is applicable for.
required, enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
item_constraints[item_price_ids][0..n]
List of item price ids for which this coupon is applicable.
optional, jsonarray
+
item_constraint_criteria
Parameters for item_constraint_criteria. Multiple item_constraint_criteria can be passed by specifying unique indices.
pass parameters as item_constraint_criteria[<param name>][<idx:0..n>]
item_constraint_criteria[item_type][0..n]
Item type for which this criteria is applicable for.
optional, enumerated string
Possible values are
planPlan.addonAddon.chargeCharge.
item_constraint_criteria[item_family_ids][0..n]
List of families for which this coupon is applicable.
optional, jsonarray
item_constraint_criteria[currencies][0..n]
List of currencies (ISO 4217 format) for which this coupon is applicable.
optional, jsonarray
item_constraint_criteria[item_price_periods][0..n]
Pass the item price period units for this criterion. period followed by period_units. Such as [1 day,1 week,3 month,6 month].
optional, jsonarray
Resource object representing coupon.
always returned
List the available coupons.

URL Format GET

https://{site}.chargebee.com/api/v2/coupons
limit
The number of resources to be returned.
optional, integer, default=10, min=1, max=100
offset
Determines your position in the list for pagination. To ensure that the next page is retrieved correctly, always set offset to the value of next_offset obtained in the previous iteration of the API call.
optional, string, max chars=1000
sort_by[<sort-order>]
Sorts based on the specified attribute.
Supported attributes : created_at
Supported sort-orders : asc, desc

Example sort_by[asc] = "created_at"
This will sort the result based on the 'created_at' attribute in ascending(earliest first) order.
optional, string filter
Filter Params
For operator usages, see the Pagination and Filtering section.
id[<operator>]
Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.
Supported operators : is, is_not, starts_with, in, not_in

Example id[is] = "OFF2008"
optional, string filter
name[<operator>]
The display name used in web interface for identifying the coupon.
Supported operators : is, is_not, starts_with, in, not_in

Example name[is] = "Offer 10"
optional, string filter
discount_type[<operator>]
The type of discount. Possible values are : fixed_amount, percentage.
Supported operators : is, is_not, in, not_in

Example discount_type[is_not] = "fixed_amount"
optional, enumerated string filter
duration_type[<operator>]
Specifies the time duration this coupon is applicable. Possible values are : one_time, forever, limited_period.
Supported operators : is, is_not, in, not_in

Example duration_type[is] = "forever"
optional, enumerated string filter
status[<operator>]
Status of the coupon. Possible values are : active, expired, archived, deleted.
Supported operators : is, is_not, in, not_in

Example status[is] = "active"
optional, enumerated string filter
apply_on[<operator>]
The invoice items for which this discounts need to be applied. Possible values are : invoice_amount, each_specified_item.
Supported operators : is, is_not, in, not_in

Example apply_on[is] = "invoice_amount"
optional, enumerated string filter
created_at[<operator>]
Timestamp indicating when this coupon is created.
Supported operators : after, before, on, between

Example created_at[after] = "145222875"
optional, timestamp(UTC) in seconds filter
updated_at[<operator>]
To filter based on updated at. This attribute will be present only if the resource has been updated after 2016-11-09.
Supported operators : after, before, on, between

Example updated_at[after] = "1243545465"
optional, timestamp(UTC) in seconds filter
currency_code[<operator>]
The currency code (ISO 4217 format) of the coupon. Applicable for fixed_amount coupons alone.
Supported operators : is, is_not, starts_with, in, not_in

Example currency_code[is] = "USD"
optional, string filter
Resource object representing coupon.
always returned
next_offset
This attribute is returned only if more resources are present. To fetch the next set of resources use this value for the input parameter “offset”.
optional, string, max chars=1000
Retrieve a specific coupon using the id.

URL Format GET

https://{site}.chargebee.com/api/v2/coupons/{coupon_id}
Resource object representing coupon.
always returned

Sample admin console URL

https://{site}.chargebee.com/admin-console/coupons/123x

If no Subscriptions/Invoices are linked to this Coupon, the Coupon will be deleted from your Chargebee site. This action cannot be undone.

To ensure that existing Subscriptions/Invoices are not affected, Coupons associated with them will not be deleted, but moved to "Archived" state. Once a Coupon has been archived, it cannot be edited or used again and the Coupon cannot be unarchived. Unused Coupons codes will be deleted.

URL Format POST

https://{site}.chargebee.com/api/v2/coupons/{coupon_id}/delete
Resource object representing coupon.
always returned

Copies a coupon over from one site to another. Copying of archived coupons is not supported.

The item prices that are linked to the coupon in the source site are also linked to the coupon in the destination site. However, this will only work if those item prices exist and with the same ids, in the destination site. Hence, it is recommended that the item prices be copied over before copying the coupons.

The value for redemptions is not copied. It is set to 0 for the newly created coupon. Hence, if such a coupon had expired in the source site due to redemptions having reached max_redemptions, it’s status would be active in the destination site.


This API is not enabled for live sites by default. Please contact support@chargebee.com to get this enabled.

URL Format POST

https://{site}.chargebee.com/api/v2/coupons/copy
from_site
Your Chargebee site name having the coupon to be copied.
Note: Unless you are copying from a twin site (acme & acme-test are twin sites), please contact support@chargebee.com to have this white-listed.
required, string, max chars=50
id_at_from_site
Id of the coupon to be copied. The new coupon created in this site will have the same Id.
required, string, max chars=100
id
Id of copied coupon in this site.
optional, string, max chars=100
for_site_merging
If copy action is performed as part of Chargebee site merge action, pass the value as true.
Note: If this parameter is passed true coupon state, redmeptions, coupon set and coupon codes associated with this coupon will be copied.
optional, boolean, default=false
Resource object representing coupon.
always returned
Unarchives a specific coupon using the id.

URL Format POST

https://{site}.chargebee.com/api/v2/coupons/{coupon_id}/unarchive
Resource object representing coupon.
always returned