Coupons are discounts codes that you can configure and apply to subscriptions.

Sample coupon [ JSON ]

{ "id": "beta", "name": "Beta Signup Offer", "discount_type": "percentage", "discount_percentage": 20.0, "duration_type": "limited_period", "duration_month": 12, "max_redemptions": 100, "status": "active", "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "plan_constraint": "all", "addon_constraint": "none", "created_at": 1485518240, "object": "coupon", "redemptions": 0 }

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.
plan_constraint
Plans the coupon can be applied to.
enumerated string
Possible values are
noneCoupon not applicable to any plans.allCoupon applicable to all plans.specificCoupon applicable to specific plan(s).not_applicableCoupon only applicable to invoice amount and not any plans.
addon_constraint
Addons the coupon can be applied to.
enumerated string
Possible values are
noneCoupon not applicable to any addons.allCoupon applicable to all addons.specificCoupon applicable to specific addon(s).not_applicableCoupon only applicable to invoice amount and not any addons.
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. This attribute will be present only if the resource has been updated after 2016-09-28.
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
plan_ids
List of plan ids for which this coupon is applicable.
optional, list of string
addon_ids
List of addon ids for which this coupon is applicable.
optional, list of string
redemptions
The number of times this coupon has been redeemed.
optional, integer, min=0
invoice_notes
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
meta_data
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
Create a new coupon.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons \
     -u {site_api_key}: \
     -d id="sample_offer" \
     -d name="Sample Offer" \
     -d discount_type="fixed_amount" \
     -d discount_amount="500" \
     -d apply_on="invoice_amount" \
     -d duration_type="forever"
copy
curl  https://{site}.chargebee.com/api/v2/coupons \
     -u {site_api_key}: \
     -d id="sample_offer" \
     -d name="Sample Offer" \
     -d discount_type="fixed_amount" \
     -d discount_amount="500" \
     -d apply_on="invoice_amount" \
     -d duration_type="forever"

Sample Response [ JSON ]

{"coupon": { "id": "sample_offer", "name": "Sample Offer", "discount_type": "fixed_amount", "discount_amount": 500, "duration_type": "forever", "status": "active", "apply_discount_on": "not_applicable", "apply_on": "invoice_amount", "plan_constraint": "not_applicable", "addon_constraint": "not_applicable", "created_at": 1485518333, "updated_at": 1485518333, "resource_version": 1485518333000, "object": "coupon", "redemptions": 0, "currency_code": "USD" }}

URL Format POST

https://{site}.chargebee.com/api/v2/coupons
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.
plan_constraint
Plans the coupon can be applied to.
optional, enumerated string
Possible values are
noneCoupon not applicable to any plans.allCoupon applicable to all plans.specificCoupon only applicable to specified plans. If used, it is mandatory to specify the plan(s).
addon_constraint
Addons the coupon can be applied to.
optional, enumerated string
Possible values are
noneCoupon not applicable to any addons.allCoupon applicable to all addons.specificCoupon only applicable to specified addons. If used, it is mandatory to specify the addon(s).
plan_ids[0..n]
Identifier of the plan.
optional, list of string
addon_ids[0..n]
Identifier of the addon.
optional, list of string
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
Invoice Notes for this resource. Read More.
optional, string, max chars=1000
meta_data
Additional data about this resource can be stored here in the JSON Format. Learn more.
optional, jsonobject
Resource object representing coupon.
always returned
List the available coupons.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5" \
     --data-urlencode duration_type[is]="forever" \
     --data-urlencode status[is_not]="active" \
     --data-urlencode sort_by[asc]="created_at"
copy
curl  https://{site}.chargebee.com/api/v2/coupons \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5" \
     --data-urlencode duration_type[is]="forever" \
     --data-urlencode status[is]="active" \
     --data-urlencode sort_by[asc]="created_at"

Sample Response [ JSON ]

{ "list": [ {"coupon": { "id": "sample_offer", "name": "Sample Offer", "discount_type": "fixed_amount", "discount_amount": 500, "duration_type": "forever", "status": "active", "apply_discount_on": "not_applicable", "apply_on": "invoice_amount", "plan_constraint": "not_applicable", "addon_constraint": "not_applicable", "created_at": 1485518333, "updated_at": 1485518333, "resource_version": 1485518333000, "object": "coupon", "redemptions": 0, "currency_code": "USD" }}, {..} ], "next_offset": "[\"1485518333000\",\"80000000012\"]" }

URL Format GET

https://{site}.chargebee.com/api/v2/coupons
limit
Limits the number of resources to be returned.
optional, integer, default=10, min=1, max=100
offset
Allows you to fetch the next set of resources. The value used for this parameter must be the value returned for next_offset parameter in the previous 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>]
To filter based on Coupon Id.
Supported operators : is, is_not, starts_with, in, not_in

Example id[is] = "OFF2008"
optional, string filter
name[<operator>]
To filter based on Coupon Name.
Supported operators : is, is_not, starts_with, in, not_in

Example name[is_not] = "Offer 10"
optional, string filter
discount_type[<operator>]
To filter based on Coupon Discount Type. Possible values are : fixed_amount, percentage.
Supported operators : is, is_not, in, not_in

Example discount_type[is] = "fixed_amount"
optional, enumerated string filter
duration_type[<operator>]
To filter based on Coupon Duration Type. 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>]
To filter based on Coupon Status. 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>]
To filter based on Coupon Apply On. 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>]
To filter based on Coupon Created At.
Supported operators : after, before, on, between

Example created_at[on] = "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[before] = "1243545465"
optional, timestamp(UTC) in seconds 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.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/beta \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/coupons/beta \
     -u {site_api_key}:

Sample Response [ JSON ]

{"coupon": { "id": "beta", "name": "Beta Signup Offer", "discount_type": "percentage", "discount_percentage": 20.0, "duration_type": "limited_period", "duration_month": 12, "max_redemptions": 100, "status": "active", "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "plan_constraint": "all", "addon_constraint": "none", "created_at": 1485518240, "object": "coupon", "redemptions": 0 }}

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/beta

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.

Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/beta/delete \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/coupons/beta/delete \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"coupon": { "id": "beta", "name": "Beta Signup Offer", "discount_type": "percentage", "discount_percentage": 20.0, "duration_type": "limited_period", "duration_month": 12, "max_redemptions": 100, "status": "archived", "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "plan_constraint": "all", "addon_constraint": "none", "created_at": 1485518240, "archived_at": 1485518333, "object": "coupon", "redemptions": 0 }}

URL Format POST

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

Creates a coupon in this site by copying its configurations from another site. Copying of archived coupons is not supported.

Note:
  • The plans and addons (refer plan_constraint, plan_ids, addon_constraint, addon_ids) that are linked will also be copied. E.g. in the source site, the coupon C1 has P1 and P2 as applicable plans. Now, if in the destination site only the plan P1 is present, the newly created coupon will have only P1 as the applicable plan. So we recommend that you copy the necessary plans and addons before copying the coupons.
  • The 'redemptions' count is not copied. It will be 0 for the newly created coupon. Hence, if you are copying a Expired coupon (expired because max_redemptions is reached), its status will be 'Active' when created.
This API is not enabled for live sites by default. Please contact support@chargebee.com to get this enabled.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/copy \
     -u {site_api_key}: \
     -d from_site="acme-test" \
     -d id_at_from_site="OFF25"
copy
curl  https://{site}.chargebee.com/api/v2/coupons/copy \
     -u {site_api_key}: \
     -d from_site="acme-test" \
     -d id_at_from_site="OFF25"

Sample Response [ JSON ]

{"coupon": { "id": "cbdemo_earlybird", "name": "Early Bird", "discount_type": "fixed_amount", "discount_amount": 1000, "duration_type": "limited_period", "duration_month": 12, "status": "active", "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "plan_constraint": "all", "addon_constraint": "none", "created_at": 1485518333, "updated_at": 1485518333, "resource_version": 1485518333000, "object": "coupon", "redemptions": 0, "currency_code": "USD" }}

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.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupons/beta/unarchive \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/coupons/beta/unarchive \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"coupon": { "id": "10percent", "name": "10 Percent Off", "discount_type": "percentage", "discount_percentage": 10.0, "duration_type": "limited_period", "duration_month": 12, "max_redemptions": 100, "status": "active", "apply_discount_on": "not_applicable", "apply_on": "each_specified_item", "plan_constraint": "all", "addon_constraint": "none", "created_at": 1485518333, "updated_at": 1485518333, "resource_version": 1485518333000, "object": "coupon", "redemptions": 0 }}

URL Format POST

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