| Command | Description |
|---|---|
v2 billable-metrics create | Create a metric. |
v2 billable-metrics get <code> | Retrieve a metric. |
v2 billable-metrics list | List metrics, newest first. |
v2 billable-metrics update <code> | Partial update. patch is the same operation sent as PATCH. |
v2 billable-metrics delete <code> | Soft-delete a metric. Confirmation-gated. |
create
| Flag | Description |
|---|---|
--name, --code | Display name and the code events reference. Required. |
--aggregation-type | count_agg, sum_agg, max_agg, unique_count_agg, weighted_sum_agg, latest_agg. Required. |
--field-name | Event property to aggregate. Required for every type except count_agg. |
--recurring true | Carry values across billing periods. |
--filters | JSON array of {"key","values"} dimensions. Product filters select from these values. |
--expression | Compute the value from event properties before aggregation. |
--rounding-function, --rounding-precision | Round aggregated values. round, ceil or floor. |
--weighted-interval seconds | Required for weighted_sum_agg. |
update and delete
Once a metric is attached to a plan, onlyname, description and permitted filter changes are accepted. Locked fields return 422, exit 5. Filter values referenced by product filters cannot be removed.
delete soft-deletes the metric with its charges and alerts. A metric referenced by a product filter cannot be deleted.
See billable metrics for aggregation behavior.
# Count every event
lago v2 billable-metrics create --name "API calls" --code api_calls \
--aggregation-type count_agg --recurring false
# Sum a property, with a filter dimension
lago v2 billable-metrics create --name Tokens --code llm_tokens \
--aggregation-type sum_agg --field-name tokens \
--filters '[{"key":"model","values":["small","large"]}]'
lago v2 billable-metrics get api_calls
lago v2 billable-metrics get api_calls --query 'billable_metric.aggregation_type'
# Filters are returned only when expanded
lago v2 billable-metrics get llm_tokens --expands filters --query 'billable_metric.filters[].key'
lago v2 billable-metrics list --limit 20
lago v2 billable-metrics list --all --output json | jq -r '.billable_metrics[].code'
lago v2 billable-metrics update api_calls --name "API requests"
lago v2 billable-metrics delete api_calls --confirm api_calls
LAGO_ID 1a901a90-1a90-1a90-1a90-1a901a901a90
CODE api_calls
NAME API calls
{
"billable_metric": {
"aggregation_type": "count_agg",
"code": "api_calls",
"created_at": "2026-12-01T09:30:00Z",
"deleted_at": null,
"description": null,
"expression": null,
"field_name": null,
"lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
"name": "API calls",
"recurring": false,
"rounding_function": null,
"rounding_precision": null,
"updated_at": "2026-12-01T09:30:00Z",
"weighted_interval": null
}
}
Error: confirmation required for api_calls
Suggestion: Pass --confirm "api_calls" or rerun in an interactive terminal.