v2

latestOpenAPI 3.0.0raw.githubusercontent.com2026-02-16143114179.4 KB
Billable Metrics

Create a billable metric

Create a new billable metric for usage-based billing. Supported aggregation types: COUNT, SUM, MAX, UNIQUE_COUNT, LATEST, WEIGHTED_SUM.

post/api/billable-metrics

Request body

namestring required
codestring required

Unique metric code

descriptionstring
aggregationType'COUNT' | 'SUM' | 'MAX' | 'UNIQUE_COUNT' | 'LATEST' | 'WEIGHTED_SUM' required
fieldNamestring

Property key to aggregate (required for SUM, MAX, LATEST, WEIGHTED_SUM)

recurringboolean

If true, value carries forward across billing periods

Example request

{
  "name": "API Calls",
  "code": "api_calls",
  "description": "Number of API calls made",
  "aggregationType": "COUNT",
  "fieldName": "tokens",
  "filters": [
    {
      "key": "region",
      "values": [
        "us-east",
        "eu-west"
      ]
    }
  ]
}

Response

Billable metric created

idstring required
namestring required
codestring required
descriptionstring
aggregationType'COUNT' | 'SUM' | 'MAX' | 'UNIQUE_COUNT' | 'LATEST' | 'WEIGHTED_SUM' required
fieldNamestring
recurringboolean required
createdAtstring required
updatedAtstring required

Example response

{
  "id": "clx1234567890",
  "name": "API Calls",
  "code": "api_calls",
  "description": "Number of API calls made",
  "aggregationType": "COUNT",
  "fieldName": "tokens",
  "filters": [
    {
      "id": "clx1234567890",
      "key": "region",
      "values": [
        "us-east",
        "us-west",
        "eu"
      ]
    }
  ]
}