meters

Stable. Describes behaviour that is built and covered by tests in this repository.

API reference

GET /v1/meters #

List meters (latest version of each code)

Not paged: the response is the complete list.

Responses

StatusMeaningBody
200OKListMetersResponse
Example response
{
  "meters": [
    {
      "code": "string",
      "aggregation": "AGGREGATION_SUM",
      "value_property": "string",
      "filter": {},
      "quantity_scale": 0,
      "unit_label": "tokens",
      "category": "AI",
      "version": 1,
      "create_time": "2026-11-03T10:15:00Z"
    }
  ]
}
curl
curl -X GET https://YOUR-API-ADDRESS/v1/meters \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY"

POST /v1/meters #

Create a meter, or the next version of an existing code

Request body

FieldTypeDescription
code requiredstring
aggregation requiredAGGREGATION_SUM | AGGREGATION_COUNT | AGGREGATION_MAX | AGGREGATION_UNIQUE | AGGREGATION_LASTHow a customer's events of a billing period combine into one quantity. SUM adds the quantities, COUNT counts the events, MAX keeps the largest quantity. UNIQUE counts the distinct values of the event property named by value_property (an event without the property is not counted; quantity_scale must be 0). LAST is the quantity of the latest event of the period by event_time, ties broken by event id; an event that arrives after the period's cutoff never changes it. A code cannot change into or out of UNIQUE or LAST in a later version.
value_propertystringRequired for SUM, MAX and LAST (the event property holding the quantity) and for UNIQUE (the property whose distinct values are counted)
filterobject
quantity_scaleintegerDecimal places, fixed per code
unit_label requiredstringAny unit of your choice: tokens, GB-h, seats, minutes
categorystringAny group of your choice to file the meter under (compute, storage, AI); changes nothing in metering or billing
Example
{
  "code": "string",
  "aggregation": "AGGREGATION_SUM",
  "unit_label": "tokens"
}

Responses

StatusMeaningBody
201CreatedMeter
400Error envelopeError
429Error envelopeError
Example response
{
  "code": "string",
  "aggregation": "AGGREGATION_SUM",
  "value_property": "string",
  "filter": {},
  "quantity_scale": 0,
  "unit_label": "tokens",
  "category": "AI",
  "version": 1,
  "create_time": "2026-11-03T10:15:00Z"
}
curl
curl -X POST https://YOUR-API-ADDRESS/v1/meters \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code":"string","aggregation":"AGGREGATION_SUM","unit_label":"tokens"}'

GET /v1/meters/{code} #

Get the latest version of a meter

Parameters

NameInTypeDescription
code requiredpathstring

Responses

StatusMeaningBody
200OKMeter
404Error envelopeError
Example response
{
  "code": "string",
  "aggregation": "AGGREGATION_SUM",
  "value_property": "string",
  "filter": {},
  "quantity_scale": 0,
  "unit_label": "tokens",
  "category": "AI",
  "version": 1,
  "create_time": "2026-11-03T10:15:00Z"
}
curl
curl -X GET https://YOUR-API-ADDRESS/v1/meters/<code> \
  -H "Authorization: Bearer $PAYRUDDER_API_KEY"

Models

CreateMeterRequest

FieldTypeDescription
code requiredstring
aggregation requiredAGGREGATION_SUM | AGGREGATION_COUNT | AGGREGATION_MAX | AGGREGATION_UNIQUE | AGGREGATION_LASTHow a customer's events of a billing period combine into one quantity. SUM adds the quantities, COUNT counts the events, MAX keeps the largest quantity. UNIQUE counts the distinct values of the event property named by value_property (an event without the property is not counted; quantity_scale must be 0). LAST is the quantity of the latest event of the period by event_time, ties broken by event id; an event that arrives after the period's cutoff never changes it. A code cannot change into or out of UNIQUE or LAST in a later version.
value_propertystringRequired for SUM, MAX and LAST (the event property holding the quantity) and for UNIQUE (the property whose distinct values are counted)
filterobject
quantity_scaleintegerDecimal places, fixed per code
unit_label requiredstringAny unit of your choice: tokens, GB-h, seats, minutes
categorystringAny group of your choice to file the meter under (compute, storage, AI); changes nothing in metering or billing

Error

FieldTypeDescription
error requiredobject

ListMetersResponse

FieldTypeDescription
meters requiredarray of Meter

Meter

FieldTypeDescription
code requiredstring
aggregation requiredAGGREGATION_SUM | AGGREGATION_COUNT | AGGREGATION_MAX | AGGREGATION_UNIQUE | AGGREGATION_LAST
value_property requiredstringRequired for SUM, MAX, UNIQUE and LAST
filter requiredobject
quantity_scale requiredintegerDecimal places, fixed per code
unit_label requiredstringAny unit of your choice: tokens, GB-h, seats, minutes
category requiredstringAny group of your choice to file the meter under (compute, storage, AI); changes nothing in metering or billing
version requiredinteger
create_time requiredstring · date-time