Create or replace a metric
Saves the whole definition: fields you leave out are cleared (allowed_properties becomes empty, status becomes active). event_key never changes, and aggregation can not change once the usage meter has the metric (409). It answers 201 when it creates the metric: then send name and unit_label too. Secret and trusted tokens may call it; a limited token may not (403).
AuthorizationBearer <token>A secret, trusted or limited token. See Authentication.
metric_id*stringThe metric id.
The whole metric.
application/json- body
metric_id?stringOptional. Defaults to a new id.
name*stringRequired.
event_key?stringThe metric_key your app sends. 1 to 64 of a-z 0-9 _ . -, unique in the account and mode, and it never changes. Defaults to name, which fails for most names (for example "AI tokens"), so send it.
unit_label*stringRequired.
aggregation*stringRequired. One of sum, gauge or latest (400, reference UbV70, for anything else). See the metric's aggregation.
"sum""gauge""latest"allowed_properties?array<string>Up to 20 property names.
status?stringDefaults to active.
"active""archived"billing_region?stringBilling region. Defaults to us.
"us""uk""eu"Success.
application/json- response
One thing you count and bill for. See https://docs.comecero.com/docs/usage-billing/metrics-and-aggregations
object?stringAlways metric.
metric_id?stringYour id, or met_ plus 32 characters.
name?stringShown on invoice lines.
event_key?stringThe metric_key usage events use. 1 to 64 of a-z 0-9 _ . -. Unique in the account and mode. Never changes.
unit_label?stringFor example token. Shown on invoice lines.
aggregation?stringsum adds up quantities. gauge keeps the highest reading of each hour and bills the highest hour. latest bills the last value before the period ends, carried in from before it if no new value was sent (0 if none was ever sent), a level such as seats or storage in use now: it is rated on its own and never added across periods or plans. Only sum metrics share an allowance and tiers across a plan change.
"sum""gauge""latest"allowed_properties?array<string>Up to 20 property names (1 to 64 of A-Z a-z 0-9 _) events may carry.
status?stringThe usage meter refuses events for archived metrics.
"active""archived"version?integerGoes up on every change.
synced_version?integerThe version the usage meter has.
aggregation_locked?booleantrue once the usage meter has the metric. aggregation can't change after that.
billing_region?stringBilling region. Defaults to us.
"us""uk""eu"test?booleanTest or live.
account_id?stringThe account.
date_created?stringWhen it was created.
date-timedate_modified?stringWhen it last changed.
date-timecurl -X PUT 'https://api.comecero.com/api/v1/usage/metrics/string' \ -H 'Content-Type: application/json' \ -d '{ "name": "AI tokens", "event_key": "ai_tokens", "unit_label": "token", "aggregation": "sum", "allowed_properties": [ "model", "region" ], "status": "active"}'{ "object": "metric", "metric_id": "met_ai_tokens", "name": "AI tokens", "event_key": "ai_tokens", "unit_label": "token", "aggregation": "sum", "allowed_properties": [ "model" ], "status": "active", "version": 1, "synced_version": 1, "aggregation_locked": true, "billing_region": "us", "test": false, "account_id": "AB1234", "date_created": "2026-11-01T09:00:00Z", "date_modified": "2026-11-01T09:00:00Z"}