How to remove addons from a subscription via API in PC 2.0?

Modified on: Tue, 18 Jul, 2023 at 3:41 PM

This article covers


How to remove an addon from a subscription using API in PC 2.0?


Solution


You need to call the Update subscription for items API call 

https://apidocs.chargebee.com/docs/api/subscriptions#update_subscription_for_items


You need to pass “subscription_items[item_price_id]” and “replace_items_list” parameters.


When we are passing "replace_items_list" to true, and do not pass any other parameter, it ideally removes all the addons attached to the plan.


For example, if a subscription has 2 addons, and when replace_items_list=true and no other subscription items are passed, it removes both the addons




All the above two addons are removed from the subscription



If replace_items_list=false and if any subscription items are passed, then it adds the addon.




If a subscription has 2 or more addons, and if you want to remove one addon, then you need to pass replace_items_list=true and pass addon item price id as subscription_items[item_price_id][1] which needs to be retained.

For example, a subscription has below 3 addons:


Addon needs to be removed is non-shippabble USD Monthly, then below would be the API call:




Hence, if the subscription has 2 addons and you want to remove 1 addon, you would need to just pass the addon that you need to retain and define the replace_addon_list parameter as "true".


Related Articles and Documentation

My customers cannot add addons to their existing subscription


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.
×