billable_metrics

Create a billable metric

Changed on

This endpoint creates a new billable metric representing a pricing component of your application.

post/billable_metrics

Request

Request body

Example request

{
  "billable_metric": {
    "name": "Storage",
    "code": "storage",
    "description": "GB of storage used in my application",
    "expression": "round((event.properties.ended_at - event.properties.started_at) * event.properties.units)",
    "rounding_function": "round",
    "rounding_precision": 2,
    "field_name": "gb",
    "aggregation_type": "sum_agg",
    "weighted_interval": "seconds",
    "filters": [
      {
        "key": "region",
        "values": [
          "us-east-1"
        ]
      }
    ]
  }
}

Response

Billable metric created

Example response

{
  "billable_metric": {
    "lago_id": "1a901a90-1a90-1a90-1a90-1a901a901a90",
    "name": "Storage",
    "code": "storage",
    "description": "GB of storage used in my application",
    "rounding_function": "round",
    "rounding_precision": 2,
    "created_at": "2022-09-14T16:35:31Z",
    "expression": "round((event.properties.ended_at - event.properties.started_at) * event.properties.units)",
    "field_name": "gb",
    "aggregation_type": "sum_agg",
    "weighted_interval": "seconds",
    "filters": [
      {
        "key": "region",
        "values": [
          "us-east-1"
        ]
      }
    ]
  }
}

Changes

    • info

      the response property / became required for the status

    • info

      the response property / became required for the status

    • info

      the response property / became required for the status

    • info

      the response property / became required for the status

    • info

      the response property / became required for the status

    • info

      the response property / became required for the status

    • breaking

      the response property / became nullable for the status

    • info

      the response property / became required for the status