How to add usage via API?

Modified on: Thu, 25 May, 2023 at 1:26 PM

Scope

Add usage via API

What are the parameters required to create usage via API?


Summary

INVOICING METERED ITEM PRICES

While non-metered items are invoiced in a prepaid manner at the beginning of each billing cycle; for metered items, the charges are raised at the end of the billing term (postpaid). During the course of the billing period, usages can be added as and when they occur. For a given subscription_id and item_price_id, there can be only one usage record for a specific usage_date. At the end of each term, the invoice is generated with status as pending. Any remaining usage records can continue to be added to the subscription until the invoice closes automatically or is closed via an API call. If a usage record has erroneous information and you want to correct it, delete the usage and add it again.


Max Usages
The maximum number of usages that can be recorded for the entire lifetime of a subscription is 5000. Contact Support if you want this limit to be increased for your site
If there are no usages for an item price, the item price is not invoiced



Solution


usage[id]: This is an optional parameter. If not specified, Chargebee will automatically allocate an ID for the usage you create.


usage[item_price_id]: The id of the item price to which this usage belongs. The item price must be a part of the subscription or should have been part of it historically.


For example, if you are using the below addon's Price point as the product to charge usages, you need to pass the ID highlighted below to the usage[item_price_id] parameter, as the value: 



usage[usage_date]: You can pass the date in the DD/MM/YYYY format or MM/DD/YYYY format. Once you upload the sheet to perform the bulk operation, you will be able to set the format for the date parameter.


usage[quantity]: Usage quantity cannot be zero. The minimum value has to be 1. This does not have anything to do with how invoices are closed. The site wide setting you have set up for metered billing (settings> configure Chargebee> Metered Billing), is what will determine how invoices get closed. 

All details regarding the parameters to be filled in, are listed here.

Did you find it helpful? Yes No

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