Create meter
const url = 'http://localhost:8080/v1/meters';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"event_name":"example","name":"example","unit":"unit","aggregation":"sum"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url http://localhost:8080/v1/meters \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "event_name": "example", "name": "example", "unit": "unit", "aggregation": "sum" }'Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Header Parameters
Section titled “Header Parameters”Makes the call safe to retry. Send a unique value (a UUID works) and
the same value on every retry. For 24 hours, a repeat with the same
key, method, path and body gets the first response again, with an
Idempotent-Replayed: true header, instead of running again. The
error cases are in docs/api-surface.md. The usage routes do not take
it: each usage event carries its own idempotency_key.
Request Bodyrequired
Section titled “Request Bodyrequired”object
The event_name usage events will send for this meter. Letters, digits, - and _; at most 100 characters.
How the meter rolls its events into one quantity per billing period. Fixed once the meter has a usage event.
Responses
Section titled “Responses”Meter created
object
The event_name usage events send for this meter.
How the meter rolls its events into one quantity per billing
period. Every price of the meter bills under it. last
is the latest event by timestamp, then by id. Fixed once the
meter has a usage event (see has_usage).
Whether the meter has usage events. Once it has, its
aggregation cannot change. Held usage for its event_name
does not count until it is released. Returned when you create,
get or update one meter; the meter list leaves it out. A create
or update that succeeded leaves it out if it could not be read.
Example
{ "aggregation": "sum"}