Subscription model
Subscriptions are built on a hierarchical model:Subscriptions
The top-level container represents a customer’s ongoing relationship with your service. Each subscription:- Belongs to a specific customer and account
- Must have at least one subscription phase
- Derives its start and end dates from its phases
- Tracks billing cycles through phase transitions
Subscription phases
Time-bounded periods within a subscription that define different billing terms:- Start date — when this phase begins
- End date — when this phase ends (optional for the final phase)
- Multiple items — each phase can contain multiple subscription items
- Validation — phases cannot overlap and must be sequential
Subscription phase items
Individual billable items within each phase:- Price reference — links to a specific product price
- Quantity — how many units of this item (default: 1)
- Price override — optional custom pricing that overrides the base price
- Billing type — recurring or one-time charges
- Validation — each phase must have at least one item, and all recurring items must share the same interval
Key features
Datetime precision
The subscription system uses full datetime fields (not just dates) for phase boundaries, enabling:- Hourly billing — cloud computing, parking, co-working spaces
- Daily subscriptions — equipment rentals, temporary access
- Precise transitions — exact moment when trials end and billing begins
- No ambiguity — clear timezone-aware datetime boundaries
Automatic validation
Built-in validations prevent billing errors:- No overlaps — phases cannot overlap in time
- No gaps — phases must connect seamlessly (
end_date= nextstart_date) - Sequential integrity — phases automatically validated for proper ordering
- Interval consistency — all recurring items in a phase must have matching intervals
- Price constraints — overrides must be non-negative ($0 allowed for free trials)
Billing cycle anchors
Billing cycle anchors control when recurring charges occur. See Billing cycles for details.Creating a subscription
Minimum requirements
To create a subscription, you need:- Account — the business account that owns the subscription
- Customer — the customer receiving the subscription
- At least one phase with a start date
- At least one phase item linking to a price
Basic subscription
Multi-phase subscription
Validation rules
Subscription level
- Must have at least one subscription phase
- Cannot exist without phases at any time
Phase level
- Must have at least one subscription phase item
- Start date required on all phases
- End date required if subsequent phases exist
- Phases cannot overlap
- Phases must be sequential without gaps — the
end_dateof one phase must exactly match thestart_dateof the next - Supports hourly, daily, weekly, monthly, and yearly precision
Phase item level
- Must reference a valid price
- Quantity must be a positive integer (minimum 1)
- Price overrides must be non-negative (can be $0.00 for free trials)
- All recurring items in a phase must have the same interval type and count
Sequential phases
When creating multi-phase subscriptions, phases must connect seamlessly:Hourly subscription example
Interval consistency
All recurring items within a single subscription phase must have consistent billing intervals. This prevents ambiguity in invoice generation and billing calculations.Valid configurations
Invalid configurations
Non-recurring items are exempt from interval consistency rules. One-time charges can coexist with any recurring interval type within the same phase.
Database structure
start_date and end_date are datetime fields (not date fields), enabling precise time-based billing for hourly and daily subscriptions.Key methods
Pricing flexibility
Price overrides
Phase items can override the base price of a product:- Use case: promotional pricing, volume discounts, custom contracts, free trials
- Validation: must be non-negative (>= 0), can be $0.00 for free trials
- Fallback: uses the product’s base price if no override is set (nil)
Quantity support
Each phase item supports configurable quantities:- Use case: per-seat licensing, usage-based billing, bulk purchases
- Calculation:
quantity x (overridden_price_amount || price.amount)
Billing intervals
Phase items inherit billing behavior from their associated prices:- Recurring: monthly, weekly, yearly billing cycles
- One-time: charges that appear only once per phase
Phase transitions
Subscriptions automatically transition between phases based on date ranges:Real-world scenarios
SaaS with trial, onboarding, and growth path
SaaS with trial, onboarding, and growth path
Education platform with semester-based billing
Education platform with semester-based billing
Fitness membership with commitment rewards
Fitness membership with commitment rewards
Professional services with project phases
Professional services with project phases
Subscription box with introductory offer
Subscription box with introductory offer
Enterprise software with usage-based scaling
Enterprise software with usage-based scaling
Best practices
- Sequential phases — ensure the
end_dateof one phase exactly matches thestart_dateof the next - Clear transition points — define specific datetimes for phase transitions, considering time zones
- Consistent intervals — all recurring items within a phase must have the same interval type and count
- Value progression — each phase should provide clear value changes to justify pricing changes
- Test your phases — validate that phases connect properly and intervals are consistent before deploying to production
- Grace periods — consider buffer time between phases for major pricing increases (but ensure no gaps in datetime terms)
- Communication — notify customers before phase transitions that affect pricing
- Price override validation — price overrides can be $0.00 (free trials) but not negative
- Last phase open-ended — the final phase can have
end_date: nilfor ongoing subscriptions
Related pages
Billing cycles
Control when recurring charges occur with billing cycle anchors.
Invoice generation
How invoices are automatically generated from subscriptions.