Skip to main content
lago_id
string<uuid>
required

Unique identifier of the billable metric created by Lago.

Example:

"1a901a90-1a90-1a90-1a90-1a901a901a90"

name
string
required

Name of the billable metric.

Example:

"Storage"

code
string
required

Unique code used to identify the billable metric associated with the API request. This code associates each event with the correct metric.

Example:

"storage"

description
string | null
required

Internal description of the billable metric.

Example:

"GB of storage used in my application"

recurring
boolean
required

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.
Example:

false

rounding_function
enum<string> | null
required

Rounding applied to the aggregated number of units. Possible values are round, ceil and floor. When it is not set, the units are not rounded.

Available options:
ceil,
floor,
round,
null
Example:

"round"

rounding_precision
integer | null
required

Number of decimal places kept when rounding_function is applied. It can be a positive or negative value, and it defaults to 0.

Example:

2

created_at
string<date-time>
required

Creation date of the billable metric.

Example:

"2022-09-14T16:35:31Z"

expression
string | null
required

Expression used to calculate the event units. The expression is evaluated for each event and the result is then used to calculate the total aggregated units.

Example:

"round((event.properties.ended_at - event.properties.started_at) * event.properties.units)"

field_name
string | null
required

Property of the billable metric used for aggregating usage data. It is null when aggregation_type is count_agg.

Example:

"gb"

aggregation_type
enum<string>
required

Aggregation method used to compute usage for this billable metric.

Available options:
count_agg,
sum_agg,
max_agg,
unique_count_agg,
weighted_sum_agg,
latest_agg
Example:

"sum_agg"

weighted_interval
enum<string> | null
required

Parameter exclusively utilized in conjunction with the weighted_sum_agg aggregation type. It serves to adjust the aggregation result by assigning weights and proration to the result based on time intervals.

Available options:
seconds,
null
Example:

"seconds"

filters
object[]
required