Skip to main content

Update Billable metric

Route

PUT
/api/v1/billable_metrics/:code

Usage

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

curl --location --request PUT "$LAGO_URL/api/v1/billable_metrics/:code" \
--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",
"group": {
"key": "region",
"value": ["USA", "EUROPE"]
}
}
}'

Arguments

{
"billable_metric": {
"name": "bm_name",
"code": "bm_code",
"description": "description",
"aggregation_type": "sum_agg",
"field_name": "amount_sum",
"group": {
"key": "country",
"values": ["france", "italy", "spain"]
}
}
}
AttributesTypeDescription
nameString      OptionalBillable metric name.
codeString      OptionalCode identifying the billable metric.
It won't be updated if billable metric is attached to any subscriptions
descriptionString      OptionalDescription of the billable metric
aggregation_typeString      OptionalAggregation 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)
It won't be updated if billable metric is attached to any subscriptions
field_nameString      OptionalField name used in events.
It won't be updated if billable metric is attached to any subscriptions
groupObject      OptionalGroup (one or two dimensions) for pricing differently the billable metric

Group - One dimension

AttributesTypeDescription
keyString      RequiredName of the event's field used for grouping
valuesArray      RequiredArray of string representing all possible values

Example:

{
"group": {
"key": "country",
"values": ["france", "italy", "spain"]
}
}

Group - Two dimensions

AttributesTypeDescription
keyString      RequiredName of the first event's field used for grouping
valuesArray      RequiredArray of objects representing all possible values

Values:

AttributesTypeDescription
nameString      RequiredValue for the first dimension of the group
keyArray      RequiredName of the second event's field used for grouping
valuesArray      RequiredArray of string representing all possible values of the second dimension

Example:

{
"group": {
"key": "cloud",
"values": [
{
"name": "AWS",
"key": "region",
"values": ["USA", "EUROPE"]
}, {
"name": "Google",
"key": "region",
"values": ["USA"]
}
]
}
}

Responses

The billable metric was successfully updated

Returns an billable metric object.