Send a usage event
Early access. Not yet turned on for every account: until it is, this answers 404 not_found. Build against it now and ask us to turn it on.
Record one usage fact. Events are stored as sent and aggregated only when read, so a total is always recomputable from its events.
No Idempotency-Key is needed. The event’s own identifier dedupes:
resending one returns 200 with the stored original, unchanged,
whatever the resend carried. A new event returns 201.
Refusals are 422 with one of these codes: meter_not_found,
meter_archived, customer_not_found, timestamp_in_future (more
than 5 minutes ahead), missing_property (a unique_count meter’s
property is absent), invalid_value (a value that isn’t a whole
number from 0 to 1,000,000,000,000), usage_period_closed (the timestamp
falls in a period that has already been invoiced),
subscription_paused (the subscription that bills this meter was
paused at the timestamp), or invalid_field.
Authorizations
Use a Bouclay secret key (sk_test_..., sk_live_...) or restricted key
(rk_test_..., rk_live_...).
A secret key can call every endpoint. A restricted key can only call the
endpoints its scopes cover. A scope is {resource}:{access}, for example
customers:read or refunds:write, and write includes read. GET
requests need read access and everything else needs write, except
POST /subscriptions/{id}/items/{item}/preview, which only needs
subscriptions:read. A request outside the key's scopes gets 403 permission_denied naming the missing scope, and its Idempotency-Key
is not used up.
Publishable keys (pk_...) are rejected by server-side API endpoints. A
key's mode scopes what it can see and charge: a test key can never reach
a live card.
Body
The meter's event name. event_name is accepted too.
"api.request"
A Bouclay customer ID, or the externalRef you gave the customer.
"ctm_123"
Your unique ID for this event. Resending it is safe.
255"req_01J8ZQ"
When it happened. Defaults to now; at most 5 minutes in the future.
The amount, for sum, max, and last meters that read value. Whole numbers only; pick a unit that makes it one. A meter with a valueKey reads that property instead, under the same bounds.
0 <= x <= 1000000000000