Meters

Rename a meter and/or revise its definition. A rename is always allowed — the name is a label no aggregate depends on — but it must stay unique within the store (409 meter_name_taken). Definition changes (filter, aggregation, aggregation_property) are only accepted while the meter has processed no usage and has no associated purchase; otherwise the request is rejected with 409, because editing the definition would silently rewrite what already-recorded usage means. Send aggregation_property as null to clear it; omit it to leave it unchanged.

patch/v1/meters/{id}

Request

Path parameters

idstring required

Request body

namestring

New meter name. Renaming is allowed even after the meter has processed usage — the name is a label, not part of the definition. Must stay unique within the store. Omit to leave unchanged; null is rejected.

aggregation'count' | 'sum' | 'average' | 'min' | 'max' | 'unique'

New aggregation. Part of the meter definition, so it is only editable while the meter has processed no usage and has no associated purchase. Omit to leave unchanged; null is rejected.

aggregation_propertystring nullable

New aggregation property. Omit to leave unchanged; send null to clear it (only valid when the resulting aggregation is "count").

Example request

{
  "name": "Image generations (v2)",
  "aggregation": "sum",
  "aggregation_property": "tokens",
  "filter": {
    "conjunction": "and",
    "clauses": [
      {
        "property": "tier",
        "operator": "equals"
      }
    ]
  }
}

Response

Meter updated

idstring required

Meter ID

store_idstring required

Store ID

namestring required

Meter name

event_namestring required

Usage event name the meter consumes

aggregation'count' | 'sum' | 'average' | 'min' | 'max' | 'unique' required

Aggregation applied to matching events

aggregation_propertystring nullable required

Property the aggregation reduces; null for "count"

unit_labelstring required

Display unit

status'active' | 'archived' required

Whether the meter is active or archived

created_atstring required

Creation timestamp (ISO 8601)

updated_atstring required

Last update timestamp (ISO 8601)

Example response

{
  "id": "mtr_abc123",
  "store_id": "sto_abc123",
  "name": "Image generations",
  "event_name": "image.generated",
  "aggregation": "sum",
  "aggregation_property": "tokens",
  "filter": {
    "conjunction": "and",
    "clauses": [
      {
        "property": "tier",
        "operator": "equals"
      }
    ]
  },
  "unit_label": "images",
  "status": "active"
}

Changes