A billing meter usage event represents an aggregated view of a customer’s billing meter events within a specified timeframe.
Attributes
- objectstring
String representing the object’s type. Objects of the same type share the same value.
- dataarray of objects
The aggregated meter usage data for the specified customer and time range.
- data_
refreshed_ attimestamp Timestamp indicating how fresh the data is. Measured in seconds since the Unix epoch.
- livemodeboolean
Has the value
true
if the object exists in live mode or the valuefalse
if the object exists in test mode.
{ "object": "billing.analytics.meter_usage", "data_refreshed_at": 1735689000, "livemode": false, "data": [ { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733097600, "bucket_end_time": 1733184000, "meter_id": "mtr_1234567890abcdef", "bucket_value": 1500, "dimensions": { "model": "gpt-4" } }, { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733184000, "bucket_end_time": 1733270400, "meter_id": "mtr_1234567890abcdef", "bucket_value": 2250, "dimensions": { "model": "gpt-4" } }, { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733270400, "bucket_end_time": 1733356800, "meter_id": "mtr_1234567890abcdef", "bucket_value": 1875, "dimensions": { "model": "gpt-4" } } ]}
Returns aggregated meter usage data for a customer within a specified time interval. The data can be grouped by various dimensions and can include multiple meters if specified.
Parameters
- customerstringRequired
The customer id to fetch meter usage data for.
- end_
timetimestampRequired The timestamp from when to stop aggregating meter events (exclusive). Must be aligned with minute boundaries.
- start_
timetimestampRequired The timestamp from when to start aggregating meter events (inclusive). Must be aligned with minute boundaries.
- metersarray of objects
An array of meter parameters to specify which meters to include in the usage data. If not specified, usage across all meters for the customer is included.
- timezonestring
The timezone to use for the start and end times. Defaults to UTC if not specified.
- value_
grouping_ windowenum Specifies what granularity to use when aggregating meter usage events. If not specified, a single event would be returned for the specified time range.
Possible enum valuesday
hour
month
week
Returns
Aggregated meter usage data for a customer in the specified time interval.
{ "object": "billing.analytics.meter_usage", "data_refreshed_at": 1735689000, "livemode": false, "data": [ { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733097600, "bucket_end_time": 1733184000, "meter_id": "mtr_1234567890abcdef", "bucket_value": 1500, "dimensions": { "model": "gpt-4" } }, { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733184000, "bucket_end_time": 1733270400, "meter_id": "mtr_1234567890abcdef", "bucket_value": 2250, "dimensions": { "model": "gpt-4" } }, { "object": "billing.analytics.meter_usage_row", "bucket_start_time": 1733270400, "bucket_end_time": 1733356800, "meter_id": "mtr_1234567890abcdef", "bucket_value": 1875, "dimensions": { "model": "gpt-4" } } ]}
A credit grant is an API resource that documents the allocation of some billing credits to a customer.
Related guide: Billing credits
Indicates the billing credit balance for billing credits granted to a customer.