The Monetization APIs are in preview and subject to change. Features and endpoints documented here may be modified as we refine the service based on customer feedback.
Meters aggregate usage data from your API. They watch for specific event types, extract numeric values, and sum them over configurable time windows.
How Meters Work
A meter is configured with:
- Event type - Which events to process (e.g.,
requests,tokens) - Value property - JSONPath to extract the numeric value from event data.
Events use
$.totalas the standard value property. - Aggregation - How to combine values (typically
SUM)
When events are ingested, the meter matches events by type, extracts the specified value, and aggregates it per customer over time.
Common Examples
API Request Counting
Track the total number of API requests:
Code
Each event contains the subscription ID as the subject and a total field
with the quantity to record:
Code
Token Usage
Track token consumption for AI applications:
Code
Each event reports a fixed quantity per request. For example, if a meter is configured to report 50 tokens per request:
Code
Data Transfer
Track bytes transferred:
Code
Naming Consistency
The meter eventType must match the key used in three places:
- The meter's
slugandeventType - The key in the monetization policy's
metersconfiguration - The
featureKeyon the plan's entitlement
If these don't match, usage is not tracked correctly against the subscription's entitlements.
Creating a Meter
Code
API Reference
For complete API operations (list, get, update, delete), see the Meters API Reference.