202 Accepted and never rejects a well-formed event. There are no billing side-effects, no subscription requirements, and no timing constraints.
How it works
When you send an event toPOST /v0/events, Paygentic:
- Validates that the
typefield matches a billable metric configured in your organization - Returns
202 Acceptedimmediately - Paygentic deduplicates and stores the event
Before you begin
- At least one billable metric with an
eventTypeconfigured - An API key with
events:createpermission
Setting up a billable metric for metering
A billable metric becomes a meter definition by configuring three fields:| Field | Required | Description |
|---|---|---|
eventType | Yes | The type value your events will carry. Events with a non-matching type are rejected with 422. |
valueProperty | No | JSONPath expression into the event data payload. Extracts the numeric value to aggregate (e.g., $.tokens). Required for aggregations other than count. |
groupBy | No | A map of dimension names to JSONPath expressions. Allows slicing usage by properties like model or region. |
aggregation | Yes | How to combine values: sum, count, avg, min, max, unique_count, or latest. |
One billable metric = one measurement. To track multiple values from the same event (e.g., input tokens and output tokens separately), create multiple billable metrics pointing to the same
eventType with different valueProperty paths.Sending events
Send aPOST request to /v0/events for each unit of consumption:
Event fields
| Field | Required | Description |
|---|---|---|
type | Yes | Must match an eventType on one of your billable metrics. |
source | Yes | URI identifying the system sending the event (e.g., https://api.myapp.com). |
subject | Yes | The customer or entity the event relates to — typically a customerId. |
data | Yes | Arbitrary JSON object containing the metering payload. |
idempotencyKey | No | Your own deduplication key. If omitted, a unique key is generated. |
namespace | No | Organization ID. Defaults to your authenticated organization. |
timestamp | No | ISO 8601 event timestamp. Defaults to server receipt time. |
Response
Multi-dimensional metering
Thedata payload can carry as many fields as you need. Use groupBy on your billable metric to slice usage by dimension.
Example: track tokens per model
Billable metric configuration:
type: "ai.inference" contributes to the aggregate, and usage can be broken down by model or region when checking entitlement balances or querying analytics.
The
groupBy paths use JSONPath notation. $.model extracts the top-level model field from the event data object. Nested fields use dot notation: $.request.metadata.tier.Multiple metrics from one event stream
Multiple billable metrics can read from the sameeventType. This lets you track different aspects of the same operation without sending separate events.
Example: track input and output tokens separately from one AI inference event
Event payload:
Standalone metering (no plan required)
Meter events do not require a billing plan, a subscription, or even a customer account. The only requirement is a billable metric with a matchingeventType.
This makes meter events suitable for:
- Internal analytics — Track usage across your infrastructure before you’ve set up billing
- Rate limiting — Enforce per-customer limits without any billing integration
- Capacity planning — Instrument your system to understand consumption patterns
- Usage dashboards — Give customers visibility into their own usage
Using meters with metered entitlements
Meter events are the data source for metered entitlements. When a customer has a metered entitlement, the grant engine reads their aggregated meter data to determine how much quota they have remaining. To check whether a customer has remaining quota, useGET /v1/entitlements/{entitlementId}. For metered entitlements, this endpoint returns balance, usage, and period data inline. The entitlementId comes from the list entitlements response.
See Features and Entitlements — Metered Features for code examples, the full balance response schema, and hard vs soft limit configuration.
Idempotency
UseidempotencyKey to prevent duplicate events when retrying failed requests:
- If you send two events with the same
idempotencyKey, only the first is recorded - The deduplication window is 24 hours
- If you omit
idempotencyKey, the API generates a unique key for you (retries will create duplicate events)
Error handling
| Status | Condition |
|---|---|
202 Accepted | Event accepted and queued for processing |
400 Bad Request | Malformed request (e.g., invalid timestamp format) |
422 Unprocessable Entity | The type field does not match any billable metric in your organization |
401 Unauthorized | Missing or invalid API key |
403 Forbidden | API key lacks events:create permission for the target namespace |
A
422 response means you need to create a billable metric with the matching eventType before sending events of that type. Events with an unrecognized type are not queued.Next Steps
- Billable Metrics — Configure
eventType,valueProperty,groupBy, and aggregation - Features and Entitlements — Enforce usage quotas with metered entitlements
- Usage Events — Billing-first event model that triggers immediate payment