Overview
Flowglad tracks feature entitlements and consumption so you can gate premium functionality or enforce usage-based plans. UsecheckFeatureAccess for toggle features, or checkUsageBalance and createUsageEvent for usage-based features. Learn how to validate access before rendering protected experiences.
How to use
- For
checkFeatureAccess(available on client & server): provide thefeatureSlugto check for and optionally refine the result to a specific subscription by passing in asubscriptionIdforrefinementParams. Returns a boolean. - For
checkUsageBalance(available on client & server): provide theusageMeterSlugto check for and optionally refine the result to a specific subscription by passing in asubscriptionIdforrefinementParams. Returns either{ availableBalance: number }ornullif not found. - For
createUsageEvent(available on client & server): provide exactly one ofpriceSlug,priceId,usageMeterSlug, orusageMeterIdto identify the usage price. UsingusageMeterSlugorusageMeterIdresolves to the meter’s default price. All events will have apriceIdin the response.- Client: The SDK auto-resolves
subscriptionIdfrom the current subscription, defaultsamountto 1, and auto-generatestransactionIdfor idempotency. You can optionally override any of these. - Server: You must provide
subscriptionId,transactionId, andamountexplicitly, along with optionalpropertiesandusageDate. The optionalpropertiesfield is for usage meters with count distinct aggregation type. See here for more details on the parameters.
- Client: The SDK auto-resolves
What you can do
- Query customer’s feature access using the client or server SDK
- Fetch usage balances for metered features and display remaining quota.
- Combine entitlement checks with subscription state for robust authorization logic
Example: Feature Access Check
- Client
- Server
Example: Usage Balance Check
- Client
- Server
Example: Recording Usage
- Client
- Server