Menu
Delete A Usage
Delete a usage
/subscriptions/{subscription-id}/delete_usageUse it in a workflow
- Add a step and choose the Chargebee connector.
- Pick the Delete A Usage action (under Chargebee API).
- Fill in the fields below, then reference the result from later steps as
{{deleteAUsage.response.data}}.
Request
Path parameters
subscription-idstringrequiredHeaders
chargebee-request-origin-devicestringThe device from which the customer has made the request
chargebee-request-origin-userstring (email)The email address of your customer/user. Use this when the email address has only ASCII characters.
chargebee-request-origin-user-encodedstring (email)The Base64-encoded email address of your customer/user. Use this if the email address has UTF-8 characters. When this header is provided, the header chargebee-request-origin-user is ignored.
chargebee-request-origin-ipstringThe IP address of the customer where the request originated
chargebee-event-actionsstringskip all actions to be done on the events
One ofall-disabled
chargebee-event-emailstringskip only emails
One ofall-disabled
chargebee-event-webhookstringskip only webhooks
One ofall-disabled
chargebee-business-entity-idstringIf the site has multiple business entities, you can use this custom HTTP header to specify the business entity for which Chargebee should perform the operation.
Request body
Enter the body as JSON in the step's Body field.
idstringrequiredA unique and immutable id for the usage. If not provided, it is autogenerated.
{
"id": null
}
Response
Returns 200 with an object. Read it in later steps with {{deleteAUsage.response.data.<field>}}.
usageobject<div class="api-description"><div class="alert alert-info"><p class="mb-2"><strong class="font-semibold">Advanced Usage-Based Billing</strong></p><p class="mb-2">For high-scale usage ingestion, use <a href="https://www.chargebee.com/docs/billing/2.0/usage-based-billing/understanding-usages" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">Advanced Usage-Based Billing</a> with the <a href="/docs/api/usage_events" class="text-blue-600 hover:text-blue-800 underline">Usage Events API</a>. The Usage Events API supports schemaless event ingestion at scale, including <a href="/docs/api/usage_events/create-a-usage-event" class="text-blue-600 hover:text-blue-800 underline">individual events</a>, <a href="/docs/api/usage_events/ingest-usages-in-batch" class="text-blue-600 hover:text-blue-800 underline">batch ingestion</a>, and <a href="/docs/api/usage_files/usage-file-object" class="text-blue-600 hover:text-blue-800 underline">usage file ingestion</a>.</p></div><p class="mb-2">The Usages API is used to record usage for metered item prices in a subscription. This API is only applicable when Automated Metered Billing is enabled in Chargebee.</p><p class="mb-2">Metered items are those that are billed based on the service usage. Common examples include:</p><ul class="list-disc list-outside ml-6 my-4 space-y-2"> <li class="text-base leading-relaxed">Internet data services.</li> <li class="text-base leading-relaxed">SMS send/receive services.</li> <li class="text-base leading-relaxed">API services that are billed for the number of API calls made, say, per month.</li> </ul><p class="mb-2">An <a href="/docs/api/items" class="text-blue-600 hover:text-blue-800 underline">item</a> is marked metered by setting its <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">metered</code> attribute as <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">true</code>. Only recurring items can be can be set as <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">metered</code>. Recurring items are those of <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">type</code> <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">plan</code> or <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">addon</code>. A subscription can have both metered and non-metered items. The usages API (described in this page), is used to add, retrieve and delete usages for the metered items in a subscription.</p><h4>Invoicing Metered Item Prices</h4><p class="mb-2">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, <a href="/docs/api/usages/create-a-usage" class="text-blue-600 hover:text-blue-800 underline">usages can be added</a> as and when they occur. For a given <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">subscription_id</code> and <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">item_price_id</code>, there can be only one usage record for a specific <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">usage_date</code>. At the end of each term, the invoice is generated with <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">status</code> as <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">pending</code>. Any remaining usage records can continue to be added to the subscription until the invoice <a href="https://www.chargebee.com/docs/billing/2.0/usage-based-billing/metered_billing#configuring-metered-billing" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">closes automatically</a> or is <a href="/docs/api/invoices/close-a-pending-invoice" class="text-blue-600 hover:text-blue-800 underline">closed via an API call</a>. If a usage record has erroneous information and you want to correct it, <a href="/docs/api/usages/delete-a-usage" class="text-blue-600 hover:text-blue-800 underline">delete the usage</a> and add it again.</p><div class="warning alert alert-warning"><p class="mb-2"><strong class="font-semibold">Max Usages</strong></p><ul class="list-disc list-outside ml-6 my-4 space-y-2"> <li class="text-base leading-relaxed">Legacy metered billing applies per-subscription usage limits over the subscription lifetime. <a href="https://www.chargebee.com/docs/billing/2.0/kb/getting-started/how-to-contact-chargebees-support-team?utm_source=docs_api&utm_medium=content&utm_campaign=support" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">Contact Support</a> for the limit applicable to your site or to request an increase. For high-volume usage at scale, see <a href="https://www.chargebee.com/docs/billing/2.0/usage-based-billing/understanding-usages" target="_blank" rel="noopener noreferrer" class="text-blue-600 hover:text-blue-800 underline">Usage-Based Billing</a>.</li> <li class="text-base leading-relaxed">If there are no usages for an item price, the item price is not invoiced.</li> </ul></div></div>
idstringA unique and immutable id for the usage. If not provided, it is autogenerated.
usage_dateinteger (unix-time)required<p class="mb-2">The time at which this usage occurred. Chargebee bills only those usages whose <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">usage_date</code> falls within a time when the subscription <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">status</code> was <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">active</code> or <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">non_renewing</code>. However, the remaining usage records are still stored and are <a href="/docs/api/usages/retrieve-a-usage">retrievable</a>.</p> <p class="mb-2"><strong class="font-semibold">Note:</strong> If <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">usage_date</code> corresponds to a time already invoiced, then it is stored but never invoiced unless the <a href="/docs/api/subscriptions/regenerate-an-invoice">invoice is regenerated</a> .</p>
subscription_idstringrequiredThe id of the [subscription](/docs/api/subscriptions) to which this usage record belongs.
item_price_idstringrequiredThe id of the [item price](/docs/api/item_prices) to which this usage belongs. The item price must be a part of the subscription or should have been part of it historically.
invoice_idstring<p class="mb-2">When the usage has been invoiced, this is the <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">id</code> of the <a href="/docs/api/invoices">invoice</a>. This is cleared when the invoice is <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">voided</code> or deleted.</p>
line_item_idstring<p class="mb-2">When the usage has been invoiced, this is the <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">id</code> of the <code><a href="/docs/api/invoices/invoice-object#line_items">invoice.line_item</a></code> that the usage is for. This is cleared when the invoice is <code><a href="/docs/api/invoices/void-an-invoice">voided</a></code> or <a href="/docs/api/invoices/delete-an-invoice">deleted</a> .</p>
quantitystringrequiredThe quantity specified for this usage record.
sourcestringThe source from which the usage record was created. \* admin_console - Operation made through the Chargebee admin UI \* api - Operation made through the API \* bulk_operation - Operation that are triggerd through bulk operation.
One ofadmin_consoleapibulk_operation
notestringA note for this usage record. This note is not displayed on any customer-facing document or interface such as [invoice PDFs](/docs/api/invoices/retrieve-invoice-as-pdf) or [Hosted Pages](/docs/api/hosted_pages) .
resource_versioninteger (int64)<p class="mb-2">Version number of this resource. The <code class="bg-gray-100 text-gray-800 font-medium border border-gray-300 rounded px-1.5 py-0.5 mx-1 text-sm font-mono whitespace-nowrap">resource_version</code> 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.</p>
updated_atinteger (unix-time)Timestamp indicating when this usage resource was last updated.
created_atinteger (unix-time)requiredTimestamp indicating when the item was created.
{
"usage": null
}
Need more? See the Chargebee guide for connection setup and behaviour shared by every action.