Skip to content
  • Auto
  • Light
  • Dark
Talk to an expert

Create

Create a billable metric
post/v1/billable-metrics/create

Creates a new Billable Metric.

Body Parameters
namestring

The display name of the billable metric.

aggregation_keystring
optional

Specifies the type of aggregation performed on matching events. Required if sql is not provided.

aggregation_typeenum
optional
"COUNT" OR "LATEST" OR "MAX" OR 2 more

Specifies the type of aggregation performed on matching events.

Hide ParametersShow Parameters
"COUNT"
"LATEST"
"MAX"
"SUM"
"UNIQUE"
custom_fieldsmap
optional

Custom fields to attach to the billable metric.

event_type_filterin_valuesarray of stringnot_in_valuesarray of stringEventTypeFilter
optional

An optional filtering rule to match the 'event_type' property of an event.

group_keysarray of array of string
optional

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.

property_filtersarray of namestringexistsbooleanin_valuesarray of stringnot_in_valuesarray of stringPropertyFilter
optional

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.

sqlstring
optional

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.

Returns
dataidstringID
curl https://api.metronome.com/v1/billable-metrics/create \
    -H 'Content-Type: application/json' \
    -H "Authorization: Bearer $METRONOME_BEARER_TOKEN" \
    -d '{
          "name": "CPU Hours"
        }'
200 Example
{
  "data": {
    "id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
  }
}