API Version
Product Catalog
Library

A discount, just like coupons, represents a deduction from the amounts in an invoice. While coupons are typically used by your customers, discounts can be directly applied to subscriptions by your sales team while negotiating new deals or upgrades. If the negotiations are on the price itself, the price override feature helps adjust the price further.

Although a discount appears as a deduction on an invoice, it is applied to a subscription while creating or updating the subscription. Every discount in Chargebee is attached to only one subscription.

Note:

  • The sum of the line-item-level and invoice-level coupons together for a subscription, cannot exceed 10.
  • When discounts are enabled in Chargebee, the multi-coupons feature is automatically activated.

Adding a discount

Subscriptions

A discount can be added to a subscription by calling either Create subscription or Update subscription. Once added, the discount is applied to all subsequent invoices if apply_on is set to invoice_amount. When apply_on = specific_item_price, the discount is applied (as a discount.line_item_discount) in each invoice of the subscription that contains the specified item.

Invoices

A discount can be added to an invoice using Create invoice for items and one-time charges using the discounts parameter.

Quotes

A discount can be added to a quote using the following operations:

Estimates

A discount can be added to an estimate using the following endpoints:

Removing a discount

Subscriptions

A discount can be removed by calling Update subscription with the relevant discounts[operation_type][] set to remove. Also, discounts that have duration_type as one_time or limited_period are removed automatically upon expiry.

Quotes

A discount can be removed from a quote using the following operations:

Estimates

A discount can be removed from an estimate using the following operation:

Listing discounts

A discount is associated with exactly one subscription. You can fetch all the discounts currently attached to a subscription by calling the List discounts for a subscription API or by passing include_discounts as true while creating, importing, updating or retrieving a subscription.

Order of application of coupons and discounts

When both coupons and discounts are applied simultaneously to a subscription or one-time invoice, they’re applied in the following order:

Summary

Description

1

Line-level, fixed amount coupons

coupon with apply_on = each_specified_item and discount_type = flat

2

Line-level, fixed amount discounts

discount with apply_on = specific_item_price and type = fixed_amount

3

Line-level, percentage coupons

coupon with apply_on = each_specified_item and discount_type = percentage

4

Line-level, percentage discounts

discount with apply_on = specific_item_price and type = percentage

5

Invoice-level, fixed amount coupons

coupon with apply_on = invoice_amount and discount_type = flat

6

Invoice-level, fixed amount discounts

discount with apply_on = invoice_amount and type = fixed_amount

7

Invoice-level, percentage coupons

coupon with apply_on = invoice_amount and discount_type = percentage

8

Invoice-level, percentage discounts

discount with apply_on = invoice_amount and type = percentage


For example, consider the following scenario:

A subscription is created with:

  • a plan price of $200 per month
  • an addon price of $20 per month
  • a flat $5 invoice discount
  • a 1% off coupon on the addon
  • a flat $2 coupon on the invoice

The above coupons and discount are applied in the following order:

Discount or coupon applied

Subtotal at each step

1

Initial subtotal (plan price + addon price)

$200 + $20 = $220

2

1% off coupon on the addon

$200 + $(20 - 0.02) = $200 + $19.98 = $219.98

3

Flat $2 coupon on the invoice

$219.98 - $2 = $217.98

4

Flat $5 invoice discount

$217.98 - $5 = $212.98

Sample discount [ JSON ]

{ "id": "__dev__KyVmqWSHMbJxp2", "name": "__dev__KyVmqWSHMbJxp2", "invoice_name": "10% Off", "percentage": 10, "duration_type": "limited_period", "period": 3, "period_unit": "month", "apply_on": "specific_item_price", "item_price_id": "plan1", "included_in_mrr": "true", "created_at": 1605792731, "updated_at": 1605792731, "resource_version": 1605792731000, "applied_count": 1, "object": "discounts", "apply_till": 1599831828 }

API Index URL GET

https://{site}.chargebee.com/api/v2/discounts

Model Class

id
string, max chars=50
An immutable unique id for the discount. It is always auto-generated.
invoice_name
optional, string, max chars=100
The name of the discount as it should appear on customer-facing pages and documents such as invoices and hosted pages. This is auto-generated based on the type, amount, and currency_code of the discount. For example, it can be 10% off or 10$ off.
type
enumerated string, default=percentage
The type of discount. Possible value are:
Possible values are
fixed_amountThe specified amount will be given as discount.percentageThe specified percentage will be given as discount.
Show all values[+]
percentage
optional, double, min=0.01, max=100.0
The percentage of the original amount that should be deducted from it. Only applicable when discount.type is percentage.
amount
optional, in cents, min=0
The value of the discount. The format of this value depends on the kind of currency. This is only applicable when discount.type is fixed_amount.
currency_code
optional, string, max chars=3
The currency code (ISO 4217 format) of the discount. This is only applicable when discount.type is fixed_amount.
duration_type
enumerated string, default=forever
Specifies the time duration for which this discount is attached to the subscription.
Possible values are
one_timeThe discount stays attached to the subscription till it is applied on an invoice once. It is removed after that from the subscription.foreverThe discount is attached to the subscription and applied on the invoices till it is explicitly removed.limited_periodThe discount is attached to the subscription and applied on the invoices for a limited duration. This duration starts from the point it is applied to an invoice for the first time and expires after a period specified by period and period_unit.
Show all values[+]
period
optional, integer, min=1
The duration of time for which the discount is attached to the subscription, in period_units. Applicable only when duration_type is limited_period.
period_unit
optional, enumerated string
The unit of time for period. Applicable only when duration_type is limited_period.
Possible values are
dayA period of 24 hours.weekA period of 7 days.monthA period of 1 calendar month.yearA period of 1 calendar year.
Show all values[+]
included_in_mrr
boolean
The discount is included in MRR calculations for your site. This attribute is only applicable when duration_type is one_time and when the feature is enabled in Chargebee. Also, If the site-level setting is to exclude one-time discounts from MRR calculations, this value is always returned false.
apply_on
enumerated string
The amount on the invoice to which the discount is applied.
Possible values are
invoice_amountThe discount is applied to the invoice sub_total.specific_item_priceThe discount is applied to the invoice.line_item.amount that corresponds to the item price specified by item_price_id.
Show all values[+]
item_price_id
optional, string, max chars=100
The id of the item price in the subscription to which the discount is to be applied. Relevant only when apply_on = specific_item_price.
created_at
timestamp(UTC) in seconds
Timestamp indicating when this discount is created.
apply_till
optional, timestamp(UTC) in seconds
Specifies till when the limited period discount is applicable. This attribute will be sent in the response only for limited_period duration type discount.
applied_count
optional, integer
Specifies the number of times the discount has been applied.
coupon_id
string, max chars=100

Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.

Note:

When the coupon ID contains a special character; for example: #, the API returns an error. Make sure that you encode the coupon ID in the path parameter before making an API call.


index
integer, min=0
The index number of the subscription to which the item price is added. Provide a unique number between 0 and 4 (inclusive) for each subscription that is to be created.
id id
string, max chars=50
An immutable unique id for the discount. It is always auto-generated.
invoice_name invoice_name
optional, string, max chars=100
The name of the discount as it should appear on customer-facing pages and documents such as invoices and hosted pages. This is auto-generated based on the type, amount, and currency_code of the discount. For example, it can be 10% off or 10$ off.
type type
enumerated string, default=percentage
The type of discount. Possible value are:
percentage percentage
optional, double, min=0.01, max=100.0
The percentage of the original amount that should be deducted from it. Only applicable when discount.type is percentage.
amount amount
optional, in cents, min=0
The value of the discount. The format of this value depends on the kind of currency. This is only applicable when discount.type is fixed_amount.
currency_code currency_code
optional, string, max chars=3
The currency code (ISO 4217 format) of the discount. This is only applicable when discount.type is fixed_amount.
duration_type duration_type
enumerated string, default=forever
Specifies the time duration for which this discount is attached to the subscription.
period period
optional, integer, min=1
The duration of time for which the discount is attached to the subscription, in period_units. Applicable only when duration_type is limited_period.
period_unit period_unit
optional, enumerated string
The unit of time for period. Applicable only when duration_type is limited_period.
included_in_mrr included_in_mrr
boolean
The discount is included in MRR calculations for your site. This attribute is only applicable when duration_type is one_time and when the feature is enabled in Chargebee. Also, If the site-level setting is to exclude one-time discounts from MRR calculations, this value is always returned false.
apply_on apply_on
enumerated string
The amount on the invoice to which the discount is applied.
item_price_id item_price_id
optional, string, max chars=100
The id of the item price in the subscription to which the discount is to be applied. Relevant only when apply_on = specific_item_price.
created_at created_at
timestamp(UTC) in seconds
Timestamp indicating when this discount is created.
apply_till apply_till
optional, timestamp(UTC) in seconds
Specifies till when the limited period discount is applicable. This attribute will be sent in the response only for limited_period duration type discount.
applied_count applied_count
optional, integer
Specifies the number of times the discount has been applied.
coupon_id coupon_id
string, max chars=100

Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.

Note:

When the coupon ID contains a special character; for example: #, the API returns an error. Make sure that you encode the coupon ID in the path parameter before making an API call.


index index
integer, min=0
The index number of the subscription to which the item price is added. Provide a unique number between 0 and 4 (inclusive) for each subscription that is to be created.