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": "Storage",
"code": "storage",
"description": "GB of storage used in my application",
"aggregation_type": "sum_agg",
"recurring": false,
"field_name": "gb",
"weighted_interval": "seconds",
"filters": [
{
"key": "provider",
"values": ["us-east-1", "us-east-2", "eu-west-1"]
}
]
}
}'
{
"billable_metric": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Storage",
"code": "storage",
"recurring": false,
"created_at": "2022-09-14T16:35:31Z",
"aggregation_type": "sum_agg",
"description": "GB of storage used in my application",
"rounding_function": "round",
"rounding_precision": 2,
"expression": "round((ended_at - started_at) * units)",
"field_name": "gb",
"weighted_interval": "seconds",
"filters": [
{
"key": "region",
"values": [
"us-east-1"
]
}
]
}
}This endpoint updates an existing billable metric representing a pricing component of your application.
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": "Storage",
"code": "storage",
"description": "GB of storage used in my application",
"aggregation_type": "sum_agg",
"recurring": false,
"field_name": "gb",
"weighted_interval": "seconds",
"filters": [
{
"key": "provider",
"values": ["us-east-1", "us-east-2", "eu-west-1"]
}
]
}
}'
{
"billable_metric": {
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "Storage",
"code": "storage",
"recurring": false,
"created_at": "2022-09-14T16:35:31Z",
"aggregation_type": "sum_agg",
"description": "GB of storage used in my application",
"rounding_function": "round",
"rounding_precision": 2,
"expression": "round((ended_at - started_at) * units)",
"field_name": "gb",
"weighted_interval": "seconds",
"filters": [
{
"key": "region",
"values": [
"us-east-1"
]
}
]
}
}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": "Storage",
"code": "storage",
"description": "GB of storage used in my application",
"aggregation_type": "sum_agg",
"recurring": false,
"field_name": "gb",
"weighted_interval": "seconds",
"filters": [
{
"key": "provider",
"values": ["us-east-1", "us-east-2", "eu-west-1"]
}
]
}
}'
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Code of the existing billable metric.
"storage"
Billable metric payload
Show child attributes
Name of the billable metric.
"Storage"
Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
"storage"
Internal description of the billable metric.
"GB of storage used in my application"
Defines if the billable metric is persisted billing period over billing period.
true: the accumulated number of units calculated from the previous billing period is persisted to the next billing period.false: the accumulated number of units is reset to 0 at the end of the billing period.false.false
Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
Accepted function are ceil, concat and round as well as +, -, \ and * operations.
Round is accepting an optional second parameter to specify the number of decimal.
"round((ended_at - started_at) * units)"
Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are round, ceil and floor.
ceil, floor, round, "round"
Specifies the number of decimal places to which the rounding_function will be rounded. It can be a positive or negative value.
2
Property of the billable metric used for aggregating usage data. This field is not required for count_agg.
"gb"
Aggregation method used to compute usage for this billable metric.
count_agg, sum_agg, max_agg, unique_count_agg, weighted_sum_agg, latest_agg "sum_agg"
Parameter exclusively utilized in conjunction with the weighted_sum aggregation type. It serves to adjust the aggregation result by assigning weights and proration to the result based on time intervals. When this field is not provided, the default time interval is assumed to be in seconds.
seconds, "seconds"
Billable metric updated
Show child attributes
Unique identifier of the billable metric created by Lago.
"1a901a90-1a90-1a90-1a90-1a901a901a90"
Name of the billable metric.
"Storage"
Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
"storage"
Defines if the billable metric is persisted billing period over billing period.
true: the accumulated number of units calculated from the previous billing period is persisted to the next billing period.false: the accumulated number of units is reset to 0 at the end of the billing period.false.false
Creation date of the billable metric.
"2022-09-14T16:35:31Z"
Aggregation method used to compute usage for this billable metric.
count_agg, sum_agg, max_agg, unique_count_agg, weighted_sum_agg, latest_agg "sum_agg"
Internal description of the billable metric.
"GB of storage used in my application"
Refers to the numeric value or mathematical expression that will be rounded based on the calculated number of billing units. Possible values are round, ceil and floor.
ceil, floor, round, "round"
Specifies the number of decimal places to which the rounding_function will be rounded. It can be a positive or negative value.
2
Expression used to calculate the event units. The expression is evalutated for each event and the result is then used to calculate the total aggregated units.
"round((ended_at - started_at) * units)"
Property of the billable metric used for aggregating usage data. This field is not required for count_agg.
"gb"
Parameter exclusively utilized in conjunction with the weighted_sum aggregation type. It serves to adjust the aggregation result by assigning weights and proration to the result based on time intervals. When this field is not provided, the default time interval is assumed to be in seconds.
seconds, "seconds"