Overview
Credit grants define how credits are allocated to customers. They can be attached to plans (applying to all subscriptions) or directly to individual subscriptions for custom allocations.Grant Scope
Credit grants operate at two scopes:Plan-Scoped Grants
Scope:PLAN
Applied automatically when a customer subscribes to a plan. These are template grants that define what every subscriber receives.
Characteristics:
- Defined at the plan level
- Applied to all new subscriptions
- Cannot have
start_dateorend_date(uses subscription dates) - Requires
plan_id
- Onboarding credits for all new customers
- Monthly credit allowances included in a plan
- Trial credits for freemium plans
Subscription-Scoped Grants
Scope:SUBSCRIPTION
Applied directly to a specific subscription, allowing custom credit allocations.
Characteristics:
- Defined for a specific subscription
- Requires
subscription_idandstart_date - Optional
end_dateto limit grant duration - Can include
credit_grant_anchorfor custom billing alignment
- One-time promotional credits for a specific customer
- Custom credit packages as part of negotiations
- Compensation credits
Credit Grant Properties
Core Fields
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Descriptive name for the grant |
scope | string | Yes | PLAN or SUBSCRIPTION |
plan_id | string | Conditional | Required for plan-scoped grants |
subscription_id | string | Conditional | Required for subscription-scoped grants |
credits | decimal | Yes | Amount of credits to grant |
cadence | string | Yes | ONETIME or RECURRING |
expiration_type | string | Yes | How credits expire (see below) |
Conversion Rates
Grants can specify conversion rates to override wallet defaults:- If not specified, uses the target wallet’s conversion rates
- Allows grants to have different credit value than wallet default
Grant Cadence
One-Time Grants
Cadence:ONETIME
Credits are granted once when the subscription starts or the grant is created.
One-time grants do not require
period or period_count fields.Recurring Grants
Cadence:RECURRING
Credits are granted repeatedly based on the specified period.
DAILYWEEKLYMONTHLYQUARTERLYHALF_YEARLYANNUAL
end_date.
Credit Expiration
Expiration policies determine when granted credits become unavailable:Never Expire
Type:NEVER
Credits remain available until fully consumed.
Duration-Based Expiration
Type:DURATION
Credits expire after a fixed time period from when they’re granted.
DAYWEEKMONTHYEAR
Billing Cycle Expiration
Type:BILLING_CYCLE
Credits expire at the end of the customer’s billing period.
Billing cycle expiration aligns with the subscription’s billing schedule, not calendar months.
Creating Credit Grants
Create a plan-scoped grant
Define credits that all plan subscribers receive:This grant will automatically apply to all subscriptions created from this plan.
Grant Application Flow
Plan-Scoped Application
- Customer subscribes to a plan with credit grants
- Subscription is created
- FlexPrice identifies all active plan-scoped grants
- Grant applications are scheduled based on cadence
- Credits are added to customer’s wallet at scheduled time
Subscription-Scoped Application
- Credit grant is created with
subscription_id - Grant application is scheduled for
start_date - At scheduled time, credits are added to wallet
- For recurring grants, next application is scheduled
- Applications continue until
end_dateor subscription ends
Grant Applications
Each grant creates credit grant applications - scheduled events that add credits to wallets:PENDING- Scheduled, not yet executedCOMPLETED- Successfully added credits to walletFAILED- Application failed (will retry)SKIPPED- Skipped due to subscription status
Processing Applications
Applications are processed automatically via cron job:- Finds all pending applications scheduled for now or earlier
- Applies credits to customer wallets
- Creates wallet transactions
- Updates application status
- Schedules next application for recurring grants
Grant Priority
Thepriority field controls which credits are consumed first:
- Credits with lowest priority number
- If priority is the same, credits expiring soonest
- If both are the same, oldest credits first (FIFO)
- Priority 1: Promotional credits (use first)
- Priority 5: Plan-included credits
- Priority 10: Purchased credits (use last)
If
priority is null, credits are ordered by expiry date and creation time only.Managing Grants
Update Grant Metadata
Onlyname and metadata can be updated after creation:
Delete or End a Grant
For plan-scoped grants, deletion removes the grant from the plan:Cancel Future Applications
Cancel all pending applications for a subscription:Prepaid vs Promotional Credits
While the wallet system distinguishes between purchased and free credits, grant configuration determines the nature:Promotional/Free Credits
Use transaction reasonFREE_CREDIT_GRANT or SUBSCRIPTION_CREDIT_GRANT:
- Typically have expiration dates
- Higher priority for consumption
- Not refundable
- Shown separately in
credits_available_breakdown.free
Prepaid/Purchased Credits
Purchased credits usually go directly to wallets via top-up, not grants:- Rarely expire
- Lower priority (use promotional credits first)
- May be refundable
- Shown in
credits_available_breakdown.purchased
Best Practices
Grant Naming
- Use descriptive names: “Pro Plan Monthly Allowance” not “Grant 1”
- Include period for recurring grants: “Quarterly Platform Credits”
- Specify if promotional: “Q1 2024 Bonus Credits”
Expiration Strategy
- Plan credits: Use
BILLING_CYCLEto create urgency and predictable resets - Promotional credits: Use
DURATIONwith 30-90 days to encourage adoption - Purchased credits: Use
NEVERor very long duration (1+ years)
Priority Assignment
- Promotional credits: Priority 1-5 (consume first)
- Plan-included credits: Priority 5-10
- Purchased credits: Priority 10+ (preserve longest)
Testing Grants
- Create a test plan with a grant
- Create a test subscription
- Verify grant application was scheduled
- Manually trigger application processing
- Check wallet transactions
- Verify credits are available with correct expiry
Common Patterns
Freemium Trial Credits
Monthly Allowance with Rollover
Onboarding Bonus
Next Steps
Wallets
Learn about wallet management
Auto Top-Up
Configure automatic credit replenishment
Expiration
Manage credit expiration policies
Plans
Create plans with credit grants