Skip to main content
POST
Typescript (SDK)
Track records usage events to decrement a customer’s balance. Use this to meter feature consumption like API calls, messages sent, or credits used.

Common Use Cases

Body Parameters

Response

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Headers

x-api-version
string
default:2.3.0
required

Body

application/json
customer_id
string
required

The ID of the customer.

feature_id
string

The ID of the feature to track usage for. Required if event_name is not provided.

entity_id
string

The ID of the entity for entity-scoped balances (e.g., per-seat limits).

event_name
string

Event name to track usage for. Use instead of feature_id when multiple features should be tracked from a single event.

Minimum string length: 1
value
number

The amount of usage to record. Defaults to 1. Use negative values to credit balance (e.g., when removing a seat).

properties
object

Additional properties to attach to this usage event.

timestamp
integer

Unix timestamp in milliseconds to use for the usage event. Defaults to the current time.

Required range: 0 < x <= 9007199254740991
overage_behavior
enum<string>

How to handle usage that exceeds the available balance. "cap" (default) deducts only what fits, stopping at zero. "overflow" deducts the full value: the balance can go negative and usage limits do not clamp the deduction, though spend limits still apply.

Available options:
cap,
overflow
async
boolean

If true, enqueue the event for asynchronous processing and return 204 immediately. The response will not include balance information.

lock
object

Response

OK

customer_id
string
required

The ID of the customer whose usage was tracked.

value
number
required

The amount of usage that was recorded.

balance
object | null
required

The updated balance for the tracked feature. Null if tracking by event_name that affects multiple features.

Example:
entity_id
string

The ID of the entity, if entity-scoped tracking was performed.

event_name
string

The event name that was tracked, if event_name was used instead of feature_id.

balances
object

Map of feature_id to updated balance for the tracked feature and any related features (e.g. linked credit systems). Value is null when the customer has no balance for that feature.

deductions
object[]

Per-balance breakdown of what this event deducted. A single event can consume from multiple balance rows when credit systems or rollovers are involved; this surfaces each one so callers can build per-feature usage views without polling.