API Reference
- Getting started
- Add-ons
- Analytics
- Billable metrics
- Coupons
- Credit notes
- Customer usage
- Customers
- Events
- Fees
- Invoices
- Organizations
- Payment requests
- Plans
- Resources
- Subscriptions
- Taxes
- Wallets
- Webhook endpoints
- Webhooks
Create a billable metric
This endpoint creates a new billable metric representing a pricing component of your application.
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Name of the billable metric.
Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
Internal description of the billable metric.
Defines if the billable metric is persisted billing period over billing period.
- If set to
true
: the accumulated number of units calculated from the previous billing period is persisted to the next billing period. - If set to
false
: the accumulated number of units is reset to 0 at the end of the billing period. - If not defined in the request, default value is
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.
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
.
Specifies the number of decimal places to which the rounding_function
will be rounded. It can be a positive or negative value.
Property of the billable metric used for aggregating usage data. This field is not required for count_agg
.
Aggregation method used to compute usage for this billable metric.
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
.
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
Name of the billable metric.
Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
Internal description of the billable metric.
Defines if the billable metric is persisted billing period over billing period.
- If set to
true
: the accumulated number of units calculated from the previous billing period is persisted to the next billing period. - If set to
false
: the accumulated number of units is reset to 0 at the end of the billing period. - If not defined in the request, default value is
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.
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
Specifies the number of decimal places to which the rounding_function
will be rounded. It can be a positive or negative value.
Property of the billable metric used for aggregating usage data. This field is not required for count_agg
.
Aggregation method used to compute usage for this billable metric.
count_agg
, sum_agg
, max_agg
, unique_count_agg
, weighted_sum_agg
, latest_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
Response
Unique identifier of the billable metric created by Lago.
Name of the billable metric.
Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.
Defines if the billable metric is persisted billing period over billing period.
- If set to
true
: the accumulated number of units calculated from the previous billing period is persisted to the next billing period. - If set to
false
: the accumulated number of units is reset to 0 at the end of the billing period. - If not defined in the request, default value is
false
.
Creation date of the billable metric.
Aggregation method used to compute usage for this billable metric.
count_agg
, sum_agg
, max_agg
, unique_count_agg
, weighted_sum_agg
, latest_agg
Number of active subscriptions using this billable metric.
Number of draft invoices for which this billable metric is listed as an invoice item.
Number of plans using this billable metric.
Internal description of the billable metric.
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
Specifies the number of decimal places to which the rounding_function
will be rounded. It can be a positive or negative value.
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.
Property of the billable metric used for aggregating usage data. This field is not required for count_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
Was this page helpful?