Skip to main content

Create billable metric

Route

POST
/api/v1/billable_metrics

Usage

LAGO_URL="https://api.getlago.com"
API_KEY="__YOUR_API_KEY__"

curl --location --request POST "$LAGO_URL/api/v1/billable_metrics" \
--header "Authorization: Bearer $API_KEY" \
--header 'Content-Type: application/json' \
--data-raw '{
"billable_metric": {
"name": "bm_name",
"code": "bm_code",
"description": "description",
"aggregation_type": "sum_agg",
"field_name": "amount_sum"
}
}'

Arguments

{
"billable_metric": {
"name": "bm_name",
"code": "bm_code",
"description": "description",
"aggregation_type": "sum_agg",
"field_name": "amount_sum"
}
}
AttributesTypeDescription
nameString      RequiredBillable metric name
codeString      RequiredCode identifying the billable metric
descriptionString      OptionalDescription of the billable metric
aggregation_typeString      RequiredAggregation type that is used in event calculations.
It can be count_agg (metered), sum_agg (metered), max_agg (metered), unique_count_agg (metered) or recurring_count_agg (persistent)
field_nameString      Required (optional only for count_agg aggregation type)Field name used in events.

Responses

The billable metric was created

Returns a billable metric object.