Usage Events
are the mechanism by which Merchants
report their Customers
’ consumption of Billable Metrics
to Paygentic. Sending Usage Events
is the final step in the core loop, triggering real-time billing and payment deductions from the Consumer
’s Wallet
.
Role in Billing and Payments
Whenever aCustomer
interacts with your Product
in a way that consumes a Billable Metric
defined in their active Subscription
’s Plan
, you should report this consumption by sending a Usage Event
to Paygentic.
Upon receiving a valid Usage Event
, Paygentic processes it based on whether an entitlement is provided:
Standard Processing (Without Entitlement)
- Identifies the
Customer
and their activeSubscription
. - Looks up the
Plan
and thePrice
associated with thebillableMetricId
(s) reported in the event. - Calculates the cost based on the reported
quantity
and the applicablePrice
(considering the pricing model - standard, dynamic, volume, percentage). - Instantly deducts the calculated cost from the
Consumer
Organization
’sWallet
. - Instantly credits the calculated cost (minus any applicable fees) to the
Merchant
Organization
’sWallet
. - Records the transaction and updates analytics.
Entitlement-Based Processing
When anentitlementId
is included:
- Validates the entitlement exists and has remaining capacity.
- Calculates the cost using the same pricing logic.
- Deducts from the pre-reserved entitlement funds (not the wallet).
- Credits the merchant’s wallet immediately.
- Updates the entitlement’s remaining balance.
Usage Event Properties
AUsage Event
object contains several key pieces of information. Here are some of the most important ones:
The unique identifier automatically assigned to the event by Paygentic upon successful ingestion.
A unique key provided by the
Merchant
when creating the event. Paygentic uses this key to deduplicate events. If you send the same event (with the same idempotencyKey
) multiple times within a reasonable window, it will only be processed once, preventing accidental double-billing. It’s crucial to generate a unique key for each distinct usage occurrence.Optional ID of a pre-authorized entitlement (format:
com_*
). When provided, the usage is deducted from the entitlement’s reserved funds rather than directly from the wallet, guaranteeing payment availability.The ID of the
Customer
resource representing the relationship between the Merchant
and the Consumer
who consumed the resource.The ID of the
Merchant
Organization
reporting the usage.The timestamp (in ISO 8601 format) indicating when the usage actually occurred, as reported by the
Merchant
. This should be accurate and fall within the Customer
’s current billing period for their Subscription
.An array detailing the specific
Billable Metrics
consumed and their quantities in this event. See structure below.An object added by Paygentic after the event has been successfully processed and billed. It contains details like the calculated
price
(in smallest currency unit) and the ID of the internal billing transaction.Optional key-value pairs provided by the
Merchant
for storing additional context or internal references related to the event.Ingestion
Usage events are sent to Paygentic via its REST API.- Single Event: Use the Create Usage Event endpoint (
POST /usage
). - Multiple Events: For efficiency, you can send multiple events in one request using the Batch Create Usage Events endpoint (
POST /usage/batch
). - Edge Optimization: For improved performance, use edge endpoints like
https://edge-api.paygentic.com/v0/usage
or regional endpoints for 30-70% latency reduction.
Entitlement-Based Usage
Entitlements provide pre-authorized payment reservations that guarantee funds availability before usage occurs. When you include anentitlementId
in your usage event, Paygentic deducts from the reserved funds rather than directly from the wallet, ensuring payment is guaranteed.
- Guaranteed payment: Funds are reserved upfront, eliminating payment failures
- Lower latency: Regional entitlements enable ultra-fast processing via edge instances
- Better control: Set usage limits with
maxUses
parameter for multi-use entitlements
Required Fields at Ingestion
When sending a request to create a usage event, you must include:idempotencyKey
- Unique key to prevent duplicate processingcustomerId
- ID of the customer generating the usagemerchantId
- ID of the merchant organization (usually inferred from authentication)timestamp
- When the usage occurred (ISO 8601 format)properties
- Array detailing the billable metrics consumed
entitlementId
- ID of a pre-authorized entitlement to deduct from (format:com_*
)metadata
- Additional context or internal references
The properties
Array
This array is the core of the usage report. Each object within the array represents the consumption of one Billable Metric
.
The ID of the
Billable Metric
that was consumed.The amount of the
Billable Metric
’s unit that was consumed in this event (e.g., 1
for one API call, 1024
for 1024 tokens).Required for
dynamic
and percentage
pricing models.- For
dynamic
pricing: Specifies the total price (not per unit) to charge for the consumed quantity in this specific event. This price must fall within theminPrice
andmaxPrice
defined in thePrice
object. - For
percentage
pricing: Specifies the base amount (e.g., invoice total, transaction amount) on which the percentage is calculated. The actual charge will bebaseAmount * percentage
, bounded byminCharge
andmaxCharge
.
properties
array:
Timing and Idempotency
- Reporting Window: Ensure the
timestamp
you report falls within the current billing period of the customer’s activeSubscription
. Events reported outside this window may be rejected. - Idempotency: Always generate and send a unique
idempotencyKey
for each distinct usage event you intend to bill for. Retrying a failed request with the sameidempotencyKey
is safe.
Usage Events
accurately and promptly is key to leveraging Paygentic’s real-time billing capabilities.