Coupon codes are used along with existing coupons in ChargeBee. You can create a coupon set using a bunch of coupon codes and this coupon set will be associated with an existing coupon. A coupon code can only be applied to a single subscription and cannot be re-used.

Using coupon codes you can distribute several unique codes for a single main coupon, when you are running promotions.

Sample coupon code [ JSON ]

{ "object": "coupon_code", "coupon_id": "beta", "status": "not_redeemed", "coupon_set_name": "Promo Coupon Codes", "code": "CBCC4356" }
code
Unique coupon code that can be redeemed only once.
string, max chars=50
status
Status of the coupon code.
enumerated string, default=not_redeemed
Possible values are
not_redeemedCan be applied to a subscription.redeemedCannot be applied to a subscription as the coupon code has been already used.archivedCannot be applied to a subscription as it has been made inactive.
coupon_id
Id of the main coupon resource.
string, max chars=50
coupon_set_name
Coupon set name to which this coupon code would be grouped under. If the coupon set with the passed name is not present, a new coupon set will be created.
string, max chars=50
Create a new coupon code and associate it to an existing main coupon resource.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupon_codes \
     -u {site_api_key}: \
     -d coupon_id="beta" \
     -d coupon_set_name="Launch Promotion" \
     -d code="CBCC435"
copy
curl  https://{site}.chargebee.com/api/v2/coupon_codes \
     -u {site_api_key}: \
     -d coupon_id="beta" \
     -d coupon_set_name="Launch Promotion" \
     -d code="CBCC435"

Sample Response [ JSON ]

{"coupon_code": { "object": "coupon_code", "coupon_id": "beta", "status": "not_redeemed", "coupon_set_name": "Launch Promotion", "code": "CBCC435" }}

URL Format POST

https://{site}.chargebee.com/api/v2/coupon_codes
coupon_id
Id of the main coupon resource.
required, string, max chars=50
coupon_set_name
Coupon set name to which this coupon code would be grouped under. If the coupon set with the passed name is not present, a new coupon set will be created.
required, string, max chars=50
code
Unique coupon code that can be redeemed only once.
required, string, max chars=50
Resource object representing coupon_code.
always returned
Retrieve a coupon code for a code.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupon_codes/CBCC4356 \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/coupon_codes/CBCC4356 \
     -u {site_api_key}:

Sample Response [ JSON ]

{"coupon_code": { "object": "coupon_code", "coupon_id": "beta", "status": "not_redeemed", "coupon_set_name": "Promo Coupon Codes", "code": "CBCC4356" }}

URL Format GET

https://{site}.chargebee.com/api/v2/coupon_codes/{coupon_code_code}
Resource object representing coupon_code.
always returned
List the available coupon codes.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupon_codes \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5"
copy
curl  https://{site}.chargebee.com/api/v2/coupon_codes \
     -G  \
     -u {site_api_key}: \
     --data-urlencode limit="5"

Sample Response [ JSON ]

{ "list": [ {"coupon_code": { "object": "coupon_code", "coupon_id": "beta", "status": "not_redeemed", "coupon_set_name": "Launch Promotion", "code": "CBCC435" }}, {..} ], "next_offset": "[\"83000000001\"]" }

URL Format GET

https://{site}.chargebee.com/api/v2/coupon_codes
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
Filter Params
For operator usages, see the Pagination and Filtering section.
code[<operator>]
To filter based on CouponCode Code.
Supported operators : is, is_not, starts_with, in, not_in

Example code[is_not] = "OFF2009"
optional, string filter
coupon_id[<operator>]
To filter based on CouponCode Id.
Supported operators : is, is_not, starts_with, in, not_in

Example coupon_id[is] = "OFF20"
optional, string filter
coupon_set_name[<operator>]
To filter based on Coupon Set Name.
Supported operators : is, is_not, starts_with

Example coupon_set_name[is_not] = "OFF20"
optional, string filter
status[<operator>]
To filter based on CouponCode Status. Possible values are : not_redeemed, redeemed, archived.
Supported operators : is, is_not, in, not_in

Example status[is] = "redeemed"
optional, enumerated string filter
Resource object representing coupon_code.
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
Archives a coupon code thereby making it inactive. The archived coupon code cannot be applied to any subscription.
Sample Request
curl  https://{site}.chargebee.com/api/v2/coupon_codes/CBCC4356/archive \
     -X POST  \
     -u {site_api_key}:
copy
curl  https://{site}.chargebee.com/api/v2/coupon_codes/CBCC4356/archive \
     -X POST  \
     -u {site_api_key}:

Sample Response [ JSON ]

{"coupon_code": { "object": "coupon_code", "coupon_id": "beta", "status": "archived", "coupon_set_name": "Promo Coupon Codes", "code": "CBCC4356" }}

URL Format POST

https://{site}.chargebee.com/api/v2/coupon_codes/{coupon_code_code}/archive
Resource object representing coupon_code.
always returned