- Rolling limits — Quotas measured in hours, days, or weeks instead of the billing period
- Parallel limits — Stack independent windows on one feature, such as a 5-hour limit and a weekly limit
- Amount-based quotas — Cap spend in currency, priced through your existing billing pipeline
- Exhaustion webhooks —
entitlement.grant.exhaustedfires when a window’s quota is used up - Overage billing — Usage beyond the quota lands on the arrears invoice automatically
Concepts
Configuring a Grant
Add the grant fields to a create entitlement or update entitlement request. The feature must be metered.cURL
Grant Config Fields
The grant config is all-or-nothing: set every field or none. On update,
clear_grant_config: true removes the config and returns the entitlement to legacy behavior.
A grant config whose duration is the billing period or longer is ignored at runtime — a window spanning the whole period is just the period quota. Use
usage_limit with usage_reset_period for that case.How Grant Windows Work
Windows are usage-anchored. Flexprice does not open a window on a fixed schedule; it opens one when usage arrives:- The first usage event past the covered range opens a window at that event’s timestamp. An event at 2:00 opens a window starting at 2:00, even if evaluation runs at 2:07.
- The window runs for the configured duration:
valid_to = valid_from + duration. - When the window ends, nothing happens until the next usage event — idle periods open no windows, so an inactive customer accumulates no grant rows.
- Windows never straddle billing cycles. A window that would end within an hour of the cycle boundary stretches to the boundary instead of leaving a short stub.
grant_status:
active— usage is below the quotaexhausted— usage reached the quota (usage >= quota)
valid_to has passed, regardless of how much quota was used.
Grant Object
Aggregation Modes
When a customer holds multiple grant configs on the same feature — a plan entitlement plus an addon entitlement, for example —aggregation_mode decides how they combine.
Additive
All configs merge into one window withquota = sum of quotas. Use this when an addon should top up the base allowance.
Example: The Pro plan grants 100K tokens per day. A booster addon grants another 50K per day. The customer gets one daily window with a 150K quota.
Parallel
Each config opens its own independent window with its own duration. All windows meter the same usage stream. A request is within limits only while every applicable window has quota left; exhausting any one window puts the feature into overage for the remainder of that window. Example: 1M tokens per 5 hours and 5M tokens per week, as two parallel configs. Heavy use exhausts the 5-hour window first; sustained use over days exhausts the weekly window even though no single 5-hour burst did.Use Cases
Rolling Rate Limits for an AI Product
Cap token consumption in a rolling window that has nothing to do with the monthly invoice — the pattern used by AI assistants that advertise “resets every 5 hours”."grant_duration_unit": "week" to layer a weekly ceiling on top of the burst limit.
Daily Spend Cap
Cap what a customer’s usage costs rather than how many units they consume. Theamount measure prices usage through your existing meter prices, so a mid-window price change is respected.
Plan Plus Booster Addon
Sell top-ups without new plumbing. The plan carries a grant config; the addon carries another on the same feature withadditive mode. Buying the addon raises the shared window’s quota by the addon’s amount. With parallel mode instead, the addon grants a separate window — useful when the addon’s allowance runs on its own clock.
Soft Limits With Billed Overage
Grants implement soft limits: usage is never blocked. When a window’s quota is crossed, usage recorded after the crossing is billed as overage on the subscription’s arrears invoice — quantity overage re-enters the pricer as billable units, amount overage lands directly as a charge. With parallel windows, overlapping overage periods are merged so a unit of usage is never billed twice.Overage folding skips line items with tiered prices, commitments, or true-up — those price against the full cycle, so grant overage on them falls back to the standard billing calculation.
Exhaustion Alerts
Evaluation runs after usage events arrive (debounced, ~5m30s by default). When a window’s usage reaches its quota, the grant flips toexhausted, one alert log is written, and a webhook fires. Recovery is not a state transition — a fresh window with a fresh quota simply opens when the next one starts.
Webhook Payload
Event type:entitlement.grant.exhausted

