Attributes
- idstring
Unique identifier for the object.
- objectstring
String representing the object’s type. Objects of the same type share the same value.
- createdtimestamp
Time at which the object was created. Measured in seconds since the Unix epoch.
- customer_
mappingobject Fields that specify how to map a meter event to a customer.
- default_
aggregationobject The default settings to aggregate a meter’s events with.
- display_
namestring The meter’s name.
- event_
namestring The name of the meter event to record usage for. Corresponds with the
event_field on meter events.name - event_
time_ windownullable enum The time window which meter events have been pre-aggregated for, if any.
Possible enum valuesdayEvents are pre-aggregated in daily buckets.
hourEvents are pre-aggregated in hourly buckets.
- livemodeboolean
Has the value
trueif the object exists in live mode or the valuefalseif the object exists in test mode. - statusenum
The meter’s status.
Possible enum valuesactiveThe meter is active.
inactiveThe meter is inactive. No more events for this meter will be accepted. The meter cannot be attached to a price.
- status_
transitionsobject The timestamps at which the meter status changed.
- updatedtimestamp
Time at which the object was last updated. Measured in seconds since the Unix epoch.
- value_
settingsobject Fields that specify how to calculate a meter event’s value.
{ "id": "mtr_test_61Q8nQMqIFK9fRQmr41CMAXJrFdZ5MnA", "object": "billing.meter", "created": 1704824589, "customer_mapping": { "type": "by_id", "event_payload_key": "stripe_customer_id" }, "default_aggregation": { "formula": "sum" }, "display_name": "Search API Calls", "event_name": "ai_search_api", "event_time_window": null, "livemode": false, "status": "active", "status_transitions": { "deactivated_at": null }, "updated": 1704898330, "value_settings": { "event_payload_key": "value" }}Creates a billing meter.
Parameters
- default_
aggregationobjectRequired The default settings to aggregate a meter’s events with.
- display_
namestringRequired The meter’s name. Not visible to the customer.
The maximum length is 250 characters.
- event_
namestringRequired The name of the meter event to record usage for. Corresponds with the
event_field on meter events.name The maximum length is 100 characters.
- customer_
mappingobject Fields that specify how to map a meter event to a customer.
- event_
time_ windowenum The time window which meter events have been pre-aggregated for, if any.
Possible enum valuesdayEvents are pre-aggregated in daily buckets.
hourEvents are pre-aggregated in hourly buckets.
- value_
settingsobject Fields that specify how to calculate a meter event’s value.
Returns
Returns a billing meter.
{ "id": "mtr_test_61Q8nQMqIFK9fRQmr41CMAXJrFdZ5MnA", "object": "billing.meter", "created": 1704824589, "customer_mapping": { "type": "by_id", "event_payload_key": "stripe_customer_id" }, "default_aggregation": { "formula": "sum" }, "display_name": "Search API Calls", "event_name": "ai_search_api", "event_time_window": null, "livemode": false, "status": "active", "status_transitions": { "deactivated_at": null }, "updated": 1704824589, "value_settings": { "event_payload_key": "value" }}Updates a billing meter.
Parameters
- display_
namestring The meter’s name. Not visible to the customer.
The maximum length is 250 characters.
Returns
Returns a billing meter.
{ "id": "mtr_test_61Q8nQMqIFK9fRQmr41CMAXJrFdZ5MnA", "object": "billing.meter", "created": 1704824589, "customer_mapping": { "type": "by_id", "event_payload_key": "stripe_customer_id" }, "default_aggregation": { "formula": "sum" }, "display_name": "Updated Display Name", "event_name": "ai_search_api", "event_time_window": null, "livemode": false, "status": "active", "status_transitions": { "deactivated_at": null }, "updated": 1704898330, "value_settings": { "event_payload_key": "value" }}Retrieves a billing meter given an ID.
Parameters
No parameters.
Returns
Returns a billing meter.
{ "id": "mtr_test_61Q8nQMqIFK9fRQmr41CMAXJrFdZ5MnA", "object": "billing.meter", "created": 1704824589, "customer_mapping": { "type": "by_id", "event_payload_key": "stripe_customer_id" }, "default_aggregation": { "formula": "sum" }, "display_name": "Search API Calls", "event_name": "ai_search_api", "event_time_window": null, "livemode": false, "status": "active", "status_transitions": { "deactivated_at": null }, "updated": 1704898330, "value_settings": { "event_payload_key": "value" }}Retrieve a list of billing meters.
Parameters
- statusenum
Filter results to only include meters with the given status.
Possible enum valuesactiveThe meter is active.
inactiveThe meter is inactive. No more events for this meter will be accepted. The meter cannot be attached to a price.
More parameters
- ending_
beforestring - limitinteger
- starting_
afterstring
Returns
Returns a list of billing meters.
{ "object": "list", "data": [ { "id": "mtr_test_61Q8nQMqIFK9fRQmr41CMAXJrFdZ5MnA", "object": "billing.meter", "created": 1704824589, "customer_mapping": { "type": "by_id", "event_payload_key": "stripe_customer_id" }, "default_aggregation": { "formula": "sum" }, "display_name": "Search API Calls", "event_name": "ai_search_api", "event_time_window": null, "livemode": false, "status": "active", "status_transitions": { "deactivated_at": null }, "updated": 1704898330, "value_settings": { "event_payload_key": "value" } } ], "has_more": true, "url": "v1/billing/meters"}