API Version
Product Catalog
Library

Addon-item and charge-item prices are purchased with plan-item prices in subscriptions. You can automate this process by configuring certain addons and charges as “attached” to certain plans. This is done at the “item” level. In other words, addon- and charge-items can be attached to plan-items.

Once the attachment is defined, while creating or updating a subscription, the addon- or charge-item prices are selected automatically based on the plan-item price selected . Let’s look at the details:

Addons

Addons can be attached to plans as recommended, mandatory or optional.

  • When an addon is attached as recommended for a plan, the addon is suggested to be applied to subscriptions for the plan in Checkout and Self-Serve Portal. Alternatively, if you build your own payment pages or have a sales team, you can suggest recommended addons to your customers or salespeople on your website or CRM respectively
  • When an addon is attached as mandatory for a plan, the addon gets applied to subscriptions for the plan compulsorily, unless removed explicitly. If you do not pass an item price for a mandatory addon when including the plan in a subscription, an addon-item price is automatically applied as explained below.
  • Attaching an addon as optional neither marks it as recommended or mandatory but allows you a way to set a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.

How auto-selection of the addon-item price works

Once an addon has been attached as mandatory, the addon-item price to be applied to the plan-item price is selected based on the following rule: The addon-item price with the same currency as that of the plan-item price and the longest compatible period is selected.

Here's an example:

Consider a plan Standard Cloud Storage has an addon Extra Storage attached to it. Note that each of the two are items. Now consider that they have item prices with the following periods and currencies:

Item price for “Standard Cloud Storage” plan-item:

  • Standard Cloud Storage, 3 years, AUD.

Item prices for “Extra Storage” addon-item:

  • Extra Storage, 1 year, EUR.
  • Extra Storage, 1 year, USD.
  • Extra Storage, 1 year, AUD.
  • Extra Storage, 18 months, AUD.
  • Extra Storage, 2 years, AUD.
  • Extra Storage, 30 months, AUD.

For the plan-item price (Standard Cloud Storage, 3 years, AUD), the addon-item prices with matching currencies are the last 4 from the above list:

  • Extra Storage, 1 year, AUD.
  • Extra Storage, 18 months, AUD.
  • Extra Storage, 2 years, AUD.
  • Extra Storage, 30 months, AUD.

From among them, the last two have periods that are incompatible with the plan-item price period of 3 years. From the remaining 2 addon-item prices, the one with the longest period is of 18 months. So, “Extra Storage, 18 months, AUD” is selected for mandatory application to the plan item price.

Charges

Charges can also be attached to plans. When doing so, you specify the event at which the charge is to be applied to the subscription. For some events that can occur multiple times in a subscription lifetime, you can also set whether to apply the charge each time the event occurs or just once.

There may be multiple item prices for a given attached charge. The item price that matches the currency of the plan-item price is automatically selected for application.

Here’s an example:

Consider a plan Standard Cloud Storage has a charge named Implementation Fee attached to it. Now consider their item prices below, with the following periods and currencies:

Item price for “Standard Cloud Storage” plan-item:

  • Standard Cloud Storage, 3 years, AUD.

Item prices for “Implementation Fee” charge-item:

  • Implementation Fee, USD.
  • Implementation Fee, AUD.
  • Implementation Fee, EUR.

From among the charge-item prices above, the one compatible with the plan-item price is “Implementation Fee, AUD” since it has the same currency as the plan-item price.


Sample attached item [ JSON ]

{ "created_at": 1594107081, "id": "c9109b84-732a-4093-b53d-0b9f31ccc11c", "item_id": "day-pass", "object": "attached_item", "parent_item_id": "basic", "quantity": 1, "resource_version": 1594107081871, "status": "active", "type": "mandatory", "updated_at": 1594107081 }

API Index URL GET

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

Model Class

id
string, max chars=100
The unique id for the attached item. Set to a random, immutable value automatically when the attached item is created.
parent_item_id
string, max chars=100
The id of the plan-item to which the item is attached.
item_id
string, max chars=100
The id of the item being attached.
type
enumerated string
The type of attachment for the addon. Only applicable for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
Show all values[+]
status
optional, enumerated string
The item state.
Possible values are
activeNew subscriptions can be created with the item.archivedNo new subscriptions allowed for the item.deletedNo subscriptions allowed for the item.
Show all values[+]
quantity
optional, integer, min=1
The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal
optional, string, max chars=33
The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
billing_cycles
optional, integer, min=1
The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.
The value set explicitly for billing_cycles while applying the addon to a subscription takes precedence over this attribute. This attribute, in turn, has a higher precedence than the value set for the addon-item price.

charge_on_event
enumerated string
Indicates when the item is charged. This attribute only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.
Show all values[+]
charge_once
boolean
Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This attribute only applies to charge-items.
created_at
timestamp(UTC) in seconds
The time at which this attached item was created.
resource_version
optional, long
Version number of this resource. The resource_version is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.
updated_at
optional, timestamp(UTC) in seconds
The time at which this attached item was last updated.
channel
optional, enumerated string
The subscription channel this object originated from and is maintained in.
Possible values are
webThe object was created (and is maintained) for the web channel directly in Chargebee via API or UI.app_storeThe object data is synchronized with data from in-app subscription(s) created in Apple App Store. Direct manipulation of this object via UI or API is disallowed.play_storeThe object data is synchronized with data from in-app subscription(s) created in Google Play Store. Direct manipulation of this object via UI or API is disallowed.
Show all values[+]
id id
string, max chars=100
The unique id for the attached item. Set to a random, immutable value automatically when the attached item is created.
parent_item_id parent_item_id
string, max chars=100
The id of the plan-item to which the item is attached.
item_id item_id
string, max chars=100
The id of the item being attached.
type type
enumerated string
The type of attachment for the addon. Only applicable for addon-items.
status status
optional, enumerated string
The item state.
quantity quantity
optional, integer, min=1
The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal quantity_in_decimal
optional, string, max chars=33
The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
billing_cycles billing_cycles
optional, integer, min=1
The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.
The value set explicitly for billing_cycles while applying the addon to a subscription takes precedence over this attribute. This attribute, in turn, has a higher precedence than the value set for the addon-item price.

charge_on_event charge_on_event
enumerated string
Indicates when the item is charged. This attribute only applies to charge-items.
charge_once charge_once
boolean
Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This attribute only applies to charge-items.
created_at created_at
timestamp(UTC) in seconds
The time at which this attached item was created.
resource_version resource_version
optional, long
Version number of this resource. The resource_version is updated with a new timestamp in milliseconds for every change made to the resource. This attribute will be present only if the resource has been updated after 2016-09-28.
updated_at updated_at
optional, timestamp(UTC) in seconds
The time at which this attached item was last updated.
channel channel
optional, enumerated string
The subscription channel this object originated from and is maintained in.

Creates an attached addon or a charge item for a plan.

Notes

Sample Request
# attach a mandatory addon item
curl  https://{site}.chargebee.com/api/v2/items/basic/attached_items \
     -u {site_api_key}:\
     -d item_id="day-pass" \
     -d type="MANDATORY" \
     -d quantity=1
# attach a charge item
curl  https://{site}.chargebee.com/api/v2/items/basic/attached_items \
     -u {site_api_key}:\
     -d item_id="ssl" \
     -d charge_on_event="SUBSCRIPTION_CREATION" \
     -d charge_once=true
copy
Click to Copy

Sample Response [ JSON ]

Show more...
{
    "attached_item": {
        "created_at": 1594107081,
        "id": "c9109b84-732a-4093-b53d-0b9f31ccc11c",
        "item_id": "day-pass",
        "object": "attached_item",
        "parent_item_id": "basic",
        "quantity": 1,
        "resource_version": 1594107081871,
        "status": "active",
        "type": "mandatory",
        "updated_at": 1594107081
    }
}

URL Format POST

https://{site}.chargebee.com/api/v2/items/{item-id}/attached_items

Method

item_id[]
required, string, max chars=100
The id of the addon or charge that is being attached to the plan-item.
type[]
optional, enumerated string
The type of attachment for the addon. Only applicable for addon-items and is a required parameter as well for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
Show all values[+]
billing_cycles[]
optional, integer, min=1
The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.

The value set explicitly for billing_cycles while applying the addon to a subscription takes precedence over this parameter. This parameter, in turn, has a higher precedence than the value set for the addon-item price.
quantity[]
optional, integer, min=1
The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal[]
optional, string, max chars=33
The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
charge_on_event[]
optional, enumerated string
Indicates when the item is charged. This parameter only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.
Show all values[+]
charge_once[]
optional, boolean
Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This parameter only applies to charge-items.
attached_item attached_item
always returned
Resource object representing attached_item

Sample admin console URL

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

Updates an attached addon or a charge item for a plan.

Notes

Sample Request
curl  https://{site}.chargebee.com/api/v2/attached_items/85943f11-6014-4ab5-990d-60c86a9c2893 \
     -u {site_api_key}:\
     -d parent_item_id="cb-demo" \
     -d type="RECOMMENDED"
copy
Click to Copy

Sample Response [ JSON ]

Show more...
{
    "attached_item": {
        "created_at": 1594107090,
        "id": "85943f11-6014-4ab5-990d-60c86a9c2893",
        "item_id": "day-pass",
        "object": "attached_item",
        "parent_item_id": "cb-demo",
        "quantity": 1,
        "resource_version": 1594107092592,
        "status": "active",
        "type": "recommended",
        "updated_at": 1594107092
    }
}

URL Format POST

https://{site}.chargebee.com/api/v2/attached_items/{attached-item-id}

Method

parent_item_id[]
required, string, max chars=100
The id of the parent item in the attachment relationship.
type[]
optional, enumerated string
The type of attachment for the addon. Only applicable for addon-items and is a required parameter as well for addon-items.
Possible values are
recommendedThe addon is recommended to go with the plan-item when using Checkout or Portal.mandatoryThe addon is attached automatically to the subscription for the plan-item unless explicitly removed via API.optionalThe addon is neither mandatory, nor recommended. This allows you to attach an addon so you can specify a quantity and billing_cycles for the addon, for when it is applied to subscriptions with the plan.
Show all values[+]
billing_cycles[]
optional, integer, min=1
The number of subscription billing cycles for which this item is attached when applied to a subscription. Applicable only for items of type addon. Requires addon billing cycles to be enabled for the site.

The value set explicitly for billing_cycles while applying the addon to a subscription takes precedence over this parameter. This parameter, in turn, has a higher precedence than the value set for the addon-item price.
quantity[]
optional, integer, min=1
The default quantity of the addon to be attached when the quantity is not specified while creating/updating the subscription.
quantity_in_decimal[]
optional, string, max chars=33
The decimal representation of the quantity of the addon. Returned for quantity-based addons when multi-decimal pricing is enabled.
charge_on_event[]
optional, enumerated string
Indicates when the item is charged. This parameter only applies to charge-items.
Possible values are
subscription_creationthe time of creation of the subscription.subscription_trial_startthe time when the trial period of the subscription begins.plan_activationsame as subscription activation, but also includes the case when the plan-item of the subscription is changed.subscription_activationthe moment a subscription enters an active or non-renewing state. Also includes reactivations of canceled subscriptions.
Show all values[+]
charge_once[]
optional, boolean
Indicates if the charge-item is to be charged only once or each time the charge_on_event occurs. This parameter only applies to charge-items.
attached_item attached_item
always returned
Resource object representing attached_item

Sample admin console URL

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

Retrieves details of an attached addon or a charge item.

Notes

Sample Request
curl  https://{site}.chargebee.com/api/v2/attached_items/a0d63a3a-4bea-4621-b4c9-1bb7f833a603 \
     -u {site_api_key}:\
     -d parent_item_id="cb-demo"
copy
Click to Copy

Sample Response [ JSON ]

Show more...
{
    "attached_item": {
        "charge_on_event": "plan_activation",
        "charge_once": true,
        "created_at": 1594107087,
        "id": "a0d63a3a-4bea-4621-b4c9-1bb7f833a603",
        "item_id": "ssl",
        "object": "attached_item",
        "parent_item_id": "cb-demo",
        "quantity": 1,
        "resource_version": 1594107087829,
        "status": "active",
        "updated_at": 1594107087
    }
}

URL Format GET

https://{site}.chargebee.com/api/v2/attached_items/{attached-item-id}

Method

parent_item_id[]
required, string, max chars=100
The id of the addon or charge that is being attached to the plan-item.
attached_item attached_item
always returned
Resource object representing attached_item

Sample admin console URL

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

Deletes an attached addon or a charge item.

Notes

Sample Request
curl  https://{site}.chargebee.com/api/v2/attached_items/bf0d81c1-eb45-4636-ad8e-5ab31099e325/delete \
     -u {site_api_key}:\
     -d parent_item_id="no-trial"
copy
Click to Copy

Sample Response [ JSON ]

Show more...
{
    "attached_item": {
        "charge_on_event": "plan_activation",
        "charge_once": true,
        "created_at": 1594107084,
        "id": "bf0d81c1-eb45-4636-ad8e-5ab31099e325",
        "item_id": "ssl",
        "object": "attached_item",
        "parent_item_id": "no-trial",
        "quantity": 1,
        "resource_version": 1594107085548,
        "status": "deleted",
        "updated_at": 1594107085
    }
}

URL Format POST

https://{site}.chargebee.com/api/v2/attached_items/{attached-item-id}/delete

Method

parent_item_id[]
required, string, max chars=100
The id of the addon or charge that is being attached to the plan-item.
attached_item attached_item
always returned
Resource object representing attached_item

Sample admin console URL

https://{site}.chargebee.com/admin-console/attached_items/123x
Returns a list of attached items satisfying all the conditions specified in the filter parameters below. The list is sorted by the date of creation in descending order (latest first).

Notes

Sample Request
curl  https://{site}.chargebee.com/api/v2/items/basic/attached_items \
     -G  \
     -u {site_api_key}:\
     --data-urlencode limit=10
copy
Click to Copy

Sample Response [ JSON ]

Show more...
{
    "list": [
        {
            "attached_item": {
                "charge_on_event": "subscription_creation",
                "charge_once": true,
                "created_at": 1594107083,
                "id": "9e2b1598-ade1-45ec-87a3-f5fb847b2b9e",
                "item_id": "ssl",
                "object": "attached_item",
                "parent_item_id": "basic",
                "resource_version": 1594107083189,
                "status": "active",
                "updated_at": 1594107083
            }
        },
        {..}
    ]
}

URL Format GET

https://{site}.chargebee.com/api/v2/items/{item-id}/attached_items

Method

limit[]
optional, integer, default=10, min=1, max=100
The number of resources to be returned.
offset[]
optional, string, max chars=1000
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.
Filter Params
For operator usages, see the Pagination and Filtering section.
id[<operator>]
optional, string filter
Filter attached items based on their id. Possible values are :
Supported operators : is, is_not, starts_with, in, not_in

Example id[is] = "bec0c324-adb6-44d3-ad4f-694f449be97c"
id[is][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
id[is_not][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
id[starts_with][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
id[in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
id[not_in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
item_id[<operator>]
optional, string filter
Filter attached items based on the item_id of the item being attached. Possible values are :
Supported operators : is, is_not, starts_with, in, not_in

Example item_id[is] = "basic"
item_id[is][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
item_id[is_not][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
item_id[starts_with][operator]
optional, string, min chars=1 filter
Possible values are :
Supported operators :

Example
item_id[in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
item_id[not_in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
type[<operator>]
optional, enumerated string filter
Filter attached items based on the type of attached item. Possible values are : recommended, mandatory, optional
Supported operators : is, is_not, in, not_in

Example type[is] = "mandatory"
type[is][operator]
optional, enumerated string filter
Possible values are : recommended, mandatory, optional
Supported operators :

Example
type[is_not][operator]
optional, enumerated string filter
Possible values are : recommended, mandatory, optional
Supported operators :

Example
type[in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
type[not_in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
item_type[<operator>]
optional, enumerated string filter
To filter based on the type of of the attached item. Possible values are : plan, addon, charge
Supported operators : is, is_not, in, not_in

Example item_type[is] = "plan"
item_type[is][operator]
optional, enumerated string filter
Possible values are : plan, addon, charge
Supported operators :

Example
item_type[is_not][operator]
optional, enumerated string filter
Possible values are : plan, addon, charge
Supported operators :

Example
item_type[in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
item_type[not_in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
charge_on_event[<operator>]
optional, enumerated string filter
Indicates when the item is charged. This attribute only applies to charge-items. Possible values are : subscription_creation, subscription_trial_start, plan_activation, subscription_activation, contract_termination, on_demand
Supported operators : is, is_not, in, not_in

Example charge_on_event[is] = "subscription_creation"
charge_on_event[is][operator]
optional, enumerated string filter
Possible values are : subscription_creation, subscription_trial_start, plan_activation, subscription_activation, contract_termination, on_demand
Supported operators :

Example
charge_on_event[is_not][operator]
optional, enumerated string filter
Possible values are : subscription_creation, subscription_trial_start, plan_activation, subscription_activation, contract_termination, on_demand
Supported operators :

Example
charge_on_event[in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
charge_on_event[not_in][operator]
optional, string filter
Possible values are :
Supported operators :

Example
updated_at[<operator>]
optional, timestamp(UTC) in seconds filter
Filter attached items based on when the attached items were last updated. Possible values are :
Supported operators : after, before, on, between

Example updated_at[after] = "1243545465"
updated_at[after][operator]
optional, timestamp(UTC) in seconds filter
Possible values are :
Supported operators :

Example
updated_at[before][operator]
optional, timestamp(UTC) in seconds filter
Possible values are :
Supported operators :

Example
updated_at[on][operator]
optional, timestamp(UTC) in seconds filter
Possible values are :
Supported operators :

Example
updated_at[between][operator]
optional, string filter
Possible values are :
Supported operators :

Example
attached_item attached_item
always returned
Resource object representing attached_item
next_offset next_offset
optional, string, max chars=1000
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`.

Sample admin console URL

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