Skip to main content
Entitlement grants add time-boxed quotas on top of entitlements. A regular entitlement gives a customer a usage limit per billing period; a grant config turns it into a quota per window — “1M tokens per 5 hours” or “$50 of compute per day” — independent of the billing cycle. Flexprice opens a concrete grant window when usage starts, tracks consumption against the quota, fires a webhook when the quota is exhausted, and bills usage beyond the quota as overage on the invoice. Benefits:
  • 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 webhooksentitlement.grant.exhausted fires 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.
Grant configs are validated at write time:
  • The feature must be metered. Meters with MAX aggregation or bucketed aggregation are not supported.
  • All grant configs on one feature must share the same grant_measure and the same aggregation_mode. Additive configs must also share the same duration.
  • amount grants require flat per-unit pricing on the meter — tiered prices are rejected.
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:
  1. 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.
  2. The window runs for the configured duration: valid_to = valid_from + duration.
  3. When the window ends, nothing happens until the next usage event — idle periods open no windows, so an inactive customer accumulates no grant rows.
  4. 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.
Each grant tracks two states in grant_status:
  • active — usage is below the quota
  • exhausted — usage reached the quota (usage >= quota)
Expiry is not a status. A grant is closed when 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 with quota = 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”.
Add a second parallel config with "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. The amount measure prices usage through your existing meter prices, so a mid-window price change is respected.
The customer gets $50 of compute per day. Alert on exhaustion, or let usage continue and bill the excess as overage.

Plan Plus Booster Addon

Sell top-ups without new plumbing. The plan carries a grant config; the addon carries another on the same feature with additive 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 to exhausted, 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

Webhook Fields

Link features to plans

Webhooks