Create a metric
Responds
201 Created.
Examples
Count calls that succeeded:List metrics
{ "data": [ … ] }.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Define how events are aggregated into billable quantities
POST /v1/metrics
{
"name": "api_calls_total",
"description": "Total API calls",
"aggregation": {
"type": "count",
"filter": {},
"groupBy": []
}
}
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | The metric’s name. Prices refer to it. |
description | string | No | What the metric measures. |
aggregation.type | string | Yes | count, sum, max, count_distinct, or sql. |
aggregation.property | string | For sum, max, count_distinct | The event property to aggregate. Dot paths such as usage.tokens are allowed. |
aggregation.filter | object | No | Only count events whose properties match. |
aggregation.groupBy | string[] | No | Properties to group by. |
sql | string | For sql | A custom SQL expression. It is checked on creation, and an invalid one is rejected with 400. |
201 Created.
{
"name": "successful_calls",
"aggregation": {
"type": "count",
"filter": { "statusCode": 200 }
}
}
{
"name": "tokens_total",
"aggregation": {
"type": "sum",
"property": "tokens"
}
}
GET /v1/metrics
{ "data": [ … ] }.
PATCH /v1/metrics/:id
DELETE /v1/metrics/:id