Create a billable metric
Create billable metrics programmatically with this endpoint—an essential step in configuring your pricing and packaging in Metronome.
A billable metric is a customizable query that filters and aggregates events from your event stream. These metrics are continuously tracked as usage data enters Metronome through the ingestion pipeline. The ingestion process transforms raw usage data into actionable pricing metrics, enabling accurate metering and billing for your products.
Use this endpoint to:
- Create individual or multiple billable metrics as part of a setup workflow.
- Automate the entire pricing configuration process, from metric creation to customer contract setup.
- Define metrics using either standard filtering/aggregation or a custom SQL query.
Key response fields:
- The ID of the billable metric that was created
- The created billable metric will be available to be used in Products, usage endpoints, and alerts.
Usage guidelines:
- Metrics defined using standard filtering and aggregation are Streaming billable metrics, which have been optimized for ultra low latency and high throughput workflows.
- Use SQL billable metrics if you require more flexible aggregation options.
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The details of the billable metric to create.
The display name of the billable metric.
The SQL query associated with the billable metric. This field is mutually exclusive with aggregation_type, event_type_filter, property_filters, aggregation_key, and group_keys. If provided, these other fields must be omitted.
An optional filtering rule to match the 'event_type' property of an event.
A list of filters to match events to this billable metric. Each filter defines a rule on an event property. All rules must pass for the event to match the billable metric.
Specifies the type of aggregation performed on matching events.
count, Count, COUNT, latest, Latest, LATEST, max, Max, MAX, sum, Sum, SUM, unique, Unique, UNIQUE Specifies the type of aggregation performed on matching events. Required if sql is not provided.
Property names that are used to group usage costs on an invoice. Each entry represents a set of properties used to slice events into distinct buckets.
Custom fields to attach to the billable metric.
Response
Success