Docs
addons, remvoe, subscription, api, 2.0
How to remove addons from a subscription via API in PC 2.0?
40880096
2023-06-30T14:29:17Z
2023-07-18T10:11:34Z
358
0
0
260007
How to remove addons from a subscription via API in PC 2.0?
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”.