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: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
Response
Reporting with your own customer ID (externalSubject)
If you don’t know — or don’t yet have — a Paygentic customer ID, report events withexternalSubject set to your own customer identifier instead of subject:
externalSubject against the externalId field on your customers (scoped to your organization):
- Customer already exists with
externalId: "acct-4521"— the event is linked to that customer at ingestion, exactly as if you had sent itssubject. - Customer doesn’t exist yet — the event is accepted and stored unlinked. When you later create a customer with
externalId: "acct-4521"(or set thatexternalIdon an existing customer), the stored events are linked to it retroactively. Linked events are invoiced normally as long as their timestamps fall within a billing period of the customer’s subscription.
externalSubject, then create the customer and subscription — usage reported before the customer existed is picked up at invoicing.
Notes and caveats:
subjectis preferred when you know the Paygentic customer ID;externalSubjectis a fallback.- Resolution by
externalSubjectis eventually consistent. After a customer’sexternalIdis removed or reassigned, events may still resolve to the previous customer for up to one hour. Usesubjectwhen immediate, unambiguous attribution is required. - Once an event is linked to a subject, it is never re-linked. Changing a customer’s
externalIdonly affects unlinked and future events, subject to the one-hour grace period above. - You can send both
subjectandexternalSubject;subjectwins and they must refer to the same customer. Sending asubjectof one customer with another customer’sexternalSubjectwill misattribute usage. - Retroactive linking completes within seconds of the customer being created/updated. In rare cases an event that was in flight at exactly that moment can remain unlinked; re-saving the customer’s
externalIdre-triggers linking.
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
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