Usage reporting
The Stigg SDK allows you to report usage measurements for metered features. The reported usage is used to track, limit, and bill the customer’s usage of metered features.Calculated usage
Report pre-aggregated usage values calculated by your application. This is useful for features like seats or storage. You provide the customer ID, the metered feature ID, and the usage value. Optionally, specify a resource ID and update behavior - by default the value represents the change in usage (delta), but you can also set the usage to an absolute value.Synchronous credit balance updates
When the reported feature is credit-backed,reportUsage also returns a credit object in the response containing the updated credit balance — immediately, before the asynchronous metering pipeline completes. The deduction is applied optimistically (write-back cache strategy): the response reflects the balance as if the usage has already settled, and reconciliation to the exact source-of-truth value happens in the background.
This makes reportUsage the right choice for strict, real-time credit enforcement (e.g., AI token consumption, per-call API billing), while reportEvent remains the choice for high-volume, eventually-consistent use cases.
reportUsage | reportEvent | |
|---|---|---|
| Latency | Sub-second | ~10 seconds |
| Credit balance in response | Yes — optimistic, immediate | No |
| Volume | Lower | Higher |
| Best for | Strict enforcement, real-time UX | High-volume metering, less strict enforcement |
Raw events
Report raw events from your application, which Stigg filters and aggregates to calculate customer usage. This is useful for features like monthly active users (MAUs). You provide the customer ID, event name, and an idempotency key for deduplication. Optionally, include dimensions (key-value pairs for filtering and aggregation), a resource ID, and a timestamp.Metering and aggregation capabilities
Paywall data
Retrieve paywall data for rendering a public pricing page or customer-facing paywall. Returns plans with their entitlements, pricing, trial configurations, compatible add-ons, and product metadata.Cost estimation
Estimating new subscription cost
Estimate the cost of a new subscription before the customer commits. Useful for displaying pricing previews.Estimating subscription update cost
Estimate the cost of updating an existing subscription (e.g., changing seat count or add-ons), including a proration breakdown.Promotional entitlements
Granting promotional entitlements
Grant time-limited or custom-period promotional entitlements to customers, with optional usage limits and reset periods.Revoking promotional entitlements
Revoke previously granted promotional entitlements from a customer.Coupons
Retrieve available coupons, including their discount values, types, and metadata.Credits
Grant credits
Grant credits to a customer’s credit pool. SetgrantType to PAID for purchased credits or PROMOTIONAL for free or incentive credits. Pass resourceId to credit a resource-specific pool rather than the global pool.
Void credit grant
Cancel an active credit grant by its ID. Any remaining credits in the grant are immediately removed from the customer’s balance.Query credit usage
Retrieve a customer’s credit consumption history as a time-series. UsetimeRange for preset windows or startDate/endDate for an exact range. Break down consumption by any dimension key from your usage events using groupBy (up to 3 keys). Pass resourceId to scope the query to a specific resource pool.
groupBy is set, each series entry includes a tags array instead of featureId/featureName:
Query credit ledger
Retrieve the append-only ledger of all credit events for a customer — grants, deductions, expirations, and revocations in chronological order. PassresourceId to scope to a resource-specific pool.
Query credit grants
List all credit grants for a customer, with optional filtering by resource and currency.List available dimension keys
Retrieve the dimension keys that exist on a customer’s credit usage events. Usesearch to filter by keyword. This powers the searchable Group by dropdown in analytics UIs.
Credit auto-recharge
Configure automatic credit recharge for customers. When a customer’s credit balance drops belowthresholdValue, Stigg automatically tops up to targetBalance. Set isEnabled: false to disable recharge without losing the configuration.
