This resource allows you to record usage events, which are essential for usage-based billing. These events track customer consumption and calculate charges based on actual usage. You can send usage data to Chargebee using two endpoints: Ingest a Usage Event for individual events and Ingest Usage Events in Batch for bulk submissions.
The usage event resource payload is schema-less, providing the flexibility to adapt to your unique business requirements. Because usage events are not directly tied to a pricing plan, this resource enables independent tracking of feature consumption. Events are processed and associated with relevant features as usage data. This information is used for billing alongside entitlements, items(such as plans or addons), or item prices to generate invoices. This decoupling of usage data from the product catalog provides flexibility in defining and monetizing usage beyond predefined pricing models. Additionally, this API supports feature usage analytics, churn prediction, and other insights.
Note:
- Learn more about the use cases associated with this resource.
- Learn more about the Usage-based Billing.
- Learn more about ingesting usage events from Amazon S3.
Sample usage event [ JSON ]
{
"usage_timestamp": "179506024062",
"subscription_id": "SUB-1",
"deduplication_id": "usage-301513005",
"properties": {
"input_tokens": 1100,
"output_tokens": 7400,
"token_ratio": 6.73,
"model_name": "gpt-3.5",
"prompt_type": "code_completion",
"temperature": 0.6,
"top_p": 0.85,
"frequency_penalty": 0.4,
"presence_penalty": 0.15,
"fine_tuned": false,
"response_time_ms": 180,
"completion_success_rate_percent": 99.1,
"api_endpoints": "generateCompletion",
"cpu_usage_percent": 65,
"memory_usage_mb": 2200,
"webhook_events_sent": 45
}
}
API Index URL GET
https://{site}.ingest.chargebee.com/api/v2/usage_events
string, max chars=50 The unique identifier of a subscription.
string, max chars=36 An identifier used by the Chargebee's customer to distinguish between multiple events generated at the same timestamp for a single subscription_id
.
The combination of usage_timestamp
, subscription_id
, and deduplication_id
uniquely identifies each event.
Example:
If 3 events are generated for subscription_id
= sub-1
at 2025-04-01T00:00:00.000Z
, each event must have a distinct deduplication_id
.
long The timestamp indicating when this usage occurred, represented as Epoch time in milliseconds.
Example: 1738732394123
represents the timestamp for February 5, 2025, at 05:13:14.123 UTC. Note: The timestamp must be within the last 12 hours.
jsonobject A schema-less field that accepts any JSON-formatted data to define the attributes of the ingested event. It is a requirement to structure the data in a flat format wherever possible for better compatibility with downstream processing.
We strongly encourage using unique field names—particularly for fields intended for metering purposes. This approach enhances clarity and maintainability in the future.
For example, a field named status
,
-
Can represent string
values such as accepted
or processing
in one context.
-
In another scenario, it might hold numeric values, such as HTTP response codes like 200
, 300
, or 400
.
This is a list of the event types we currently support. We will continue
to add more events moving forward. All events follow a uniform pattern -
<resource>_<event_name>. The resources that will be
present in the event content are provided beneath each event type's
description.
Note: If consolidated invoicing is enabled, the
attributes invoice.subscription_id and
credit_note.subscription_id should not be used
(as it will not be present if the invoice / credit note has lines from
multiple subscriptions). Instead to know the related subscriptions,
their line_items' subscription_id attribute should be referred.
string, max chars=50 The unique identifier of a subscription.
string, max chars=36 An identifier used by the Chargebee's customer to distinguish between multiple events generated at the same timestamp for a single subscription_id
.
The combination of usage_timestamp
, subscription_id
, and deduplication_id
uniquely identifies each event.
Example:
If 3 events are generated for subscription_id
= sub-1
at 2025-04-01T00:00:00.000Z
, each event must have a distinct deduplication_id
.
long The timestamp indicating when this usage occurred, represented as Epoch time in milliseconds.
Example: 1738732394123
represents the timestamp for February 5, 2025, at 05:13:14.123 UTC. Note: The timestamp must be within the last 12 hours.
jsonobject A schema-less field that accepts any JSON-formatted data to define the attributes of the ingested event. It is a requirement to structure the data in a flat format wherever possible for better compatibility with downstream processing.
We strongly encourage using unique field names—particularly for fields intended for metering purposes. This approach enhances clarity and maintainability in the future.
For example, a field named status
,
-
Can represent string
values such as accepted
or processing
in one context.
-
In another scenario, it might hold numeric values, such as HTTP response codes like 200
, 300
, or 400
.
This endpoint ingests a usage event into Chargebee.
This API is not enabled for live sites by default. Please contact
support to get this enabled.
Sample Response [ JSON ]
Show more...
{
"usage_event": {
"deduplication_id": "usage-6315161283",
"subscription_id": "S-300000001",
"usage_timestamp": "1737612931000",
"properties": {
"input_tokens": 1200,
"output_tokens": 7200,
"token_ratio": 6,
"model_name": "gpt-4",
"prompt_type": "text_completion",
"temperature": 0.8,
"top_p": 0.9,
"frequency_penalty": 0.2,
"presence_penalty": 0.1,
"fine_tuned": false,
"response_time_ms": 150,
"completion_success_rate_percent": 98.6,
"api_endpoints": "generateCompletion",
"cpu_usage_percent": 68,
"memory_usage_mb": 2100,
"webhook_events_sent": 42
}
}
}
URL Format
POST
https://{site}.ingest.chargebee.com/api/v2/usage_events
required, string, max chars=36 An identifier used by the Chargebee's customer to distinguish between multiple events generated at the same timestamp for a single subscription_id
.
The combination of usage_timestamp
, subscription_id
, and deduplication_id
uniquely identifies each event.
Example:
If 3 events are generated for subscription_id
= sub-1
at 2025-04-01T00:00:00.000Z
, each event must have a distinct deduplication_id
.
required, string, max chars=50 The unique identifier of a subscription.
Note: - If an existing
subscription_id
is provided, usage data is recorded against it. - If the subscription does not exist yet in Chargebee, a new
subscription_id
can be used, and the subscription can be imported later, once the usage is successfully recorded. - During invoice generation, recorded usage linked to the
subscription_id
will be applied to the invoice.
required, long The timestamp indicating when this usage occurred, represented as Epoch time in milliseconds.
Example: 1738732394123
represents the timestamp for February 5, 2025, at 05:13:14.123 UTC. Note: The timestamp must be within the last 12 hours.
required, jsonobject A schema-less field that accepts any JSON-formatted data to define the attributes of the ingested event. It is a requirement to structure the data in a flat format wherever possible for better compatibility with downstream processing.
We strongly encourage using unique field names—particularly for fields intended for metering purposes. This approach enhances clarity and maintainability in the future.
For example, a field named status
,
-
Can represent string
values such as accepted
or processing
in one context.
-
In another scenario, it might hold numeric values, such as HTTP response codes like 200
, 300
, or 400
.
always returned required
Resource object representing usage_event
Sample admin console URL
https://{site}.chargebee.com/admin-console/usage_events/123x
This endpoint ingests a batch of usage events into Chargebee.
Note:
You can ingest 500 events in a batch ingestion, each 1 KB in size. This means a single API request will efficiently handle 500 KB of data.
Limit: 10,000 events per minute.
This API is not enabled for live sites by default. Please contact
support to get this enabled.
Sample Response [ JSON ]
Show more...
{
"batch_id": "178be7d4-9723-480e-ac18-cf7916181646",
"failed_events": [
{
"subscription_id": "448000000002",
"usage_timestamp": "1736076560644",
"properties": {
"input_tokens": 1340,
"output_tokens": 6800,
"token_ratio": 5.07,
"model_name": "gpt-4-turbo",
"prompt_type": "chat_completion",
"temperature": 0.7,
"top_p": 0.8,
"frequency_penalty": 0.3,
"presence_penalty": 0.2,
"fine_tuned": true,
"response_time_ms": 140,
"completion_success_rate_percent": 96.2,
"api_endpoints": "generateSummary",
"cpu_usage_percent": 72,
"memory_usage_mb": 1950,
"webhook_events_sent": 38
}
},
{..}
]
}
URL Format
POST
https://{site}.ingest.chargebee.com/api/v2/batch/usage_events
optional, array Parameters for events. Multiple events can be passed by specifying unique indices.
Parameters for events. Multiple events can be passed by specifying unique indices.
pass parameters as events[{<param name> : <value>,<param name> : <value> ...}]
required, string, max chars=36 required, string, max chars=50 required, timestamp(UTC) in seconds
always returned required, string, max chars=36
The unique identifier for the batch of usage events processed.
Sample admin console URL
https://{site}.chargebee.com/admin-console/usage_events/123x