Polar automatically converts metered consumption into billing entries and generates invoices at the end of each billing cycle.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/polarsource/polar/llms.txt
Use this file to discover all available pages before exploring further.
Billing Workflow
Here’s how usage-based billing flows from events to invoices:Billing Entries
Billing entries are created during a billing period to track what will be invoiced.Entry Types
| Type | Description | When Created |
|---|---|---|
cycle | Regular subscription fee | Start of billing cycle |
proration | Partial period charge/credit | Subscription changes |
metered | Usage-based consumption | As events occur |
subscription_seats_increase | Additional seats added | Seat count increases |
subscription_seats_decrease | Seats removed (credit) | Seat count decreases |
Billing Entry Structure
Metered Billing Entries
For metered consumption:- amount:
nulluntil invoiced (calculated at billing cycle end) - start_timestamp: When consumption started being tracked
- end_timestamp: When the event occurred
- event_id: Reference to the usage event
Metered Pricing Configuration
Define how consumption is priced using product prices with metered units.Creating a Metered Price
When creating a product price, link it to a meter and define pricing tiers:- Base subscription: $49.00/month
- Metered usage: $0.01 per unit (after included credits)
Pricing Models
Flat Per-Unit Pricing
Single rate for all units:- Usage: 1,500 units
- Rate: $1.00 per unit
- Charge: 1,500 × 1,500.00**
Tiered Pricing
Different rates for usage ranges:- Usage: 12,500 units
- First 1,000: 1,000 × 1,000
- Next 9,000: 9,000 × 7,200
- Next 2,500: 2,500 × 1,250
- Total: $9,450.00
Volume Pricing
Rate applies to all units based on total:- Usage: 12,500 units
- Total volume tier: 10,001+
- Charge: 12,500 × 6,250.00**
Billing Cycle
Cycle Start
When a billing cycle begins:- Subscription renews: New cycle starts
- Credits are added: Meter credit benefits grant units
- Entries are created:
cycleentry for base subscription fee - Tracking begins: Metered billing entries start accumulating
During the Cycle
As events occur:- Events ingested: Usage events sent to Polar
- Meters updated: Customer meter balance updated
- Entries created: Metered billing entry for each event
- Balance tracked: Running total of consumption
Cycle End
When the billing cycle completes:Invoice Generation
Invoices combine subscription fees with metered charges.Invoice Structure
Line Item Labels
Polar automatically generates descriptive labels: For metered usage:API Requests (12,500 units × $0.001)GPT-4 Tokens (250,000 tokens × $0.00003)Storage (156.7 GB × $0.10)
API Requests (12,500 units, 10,000 included, 2,500 × $0.001)
Billing Reasons
| Reason | Description |
|---|---|
subscription_create | First invoice for new subscription |
subscription_cycle | Regular billing cycle renewal |
subscription_update | Immediate charge from plan change |
Aggregation and Summability
How consumption is calculated depends on the meter’s aggregation function.Summable Aggregations
Count and Sum aggregations are summable:- Can be computed per price tier
- Can be summed across price changes
Non-Summable Aggregations
Max, Min, Avg, and Unique are non-summable:- Must be computed across ALL events in the period
- Billed at currently active price
Mid-Cycle Price Changes
When a customer changes subscription prices mid-cycle:Proration for Static Prices
Metered Prices
For metered consumption: Summable aggregations:- Past consumption remains at old price
- New consumption uses new price
- Both billed at cycle end
- All consumption billed at current active price
- Past billing entries not re-calculated
- Overall aggregate (max/min/avg/unique) used
Customer Meter Balance vs. Billing
It’s important to understand the relationship:Customer Meter
- Tracks real-time balance
- Credits - Consumed = Balance
- Used for access control
- Updates immediately as events occur
Billing Entries
- Track what will be charged
- Created for billable consumption
- Amount calculated at cycle end
- Accounts for included credits
Example
Subscription includes 10,000 API credits, metered at $0.001/additional:| Time | Events | Customer Meter | Billing |
|---|---|---|---|
| Day 1 | 0 sent | Credited: 10,000 Consumed: 0 Balance: 10,000 | No entries |
| Day 15 | 7,500 | Credited: 10,000 Consumed: 7,500 Balance: 2,500 | 7,500 metered entries (within included) |
| Day 30 | 12,500 | Credited: 10,000 Consumed: 12,500 Balance: -2,500 | 12,500 metered entries Invoice: 2,500 × 2.50** |
Viewing Billing Entries
While there’s no direct API endpoint for billing entries, you can understand what will be billed:Query Meter Consumption
Check Customer Meter
Estimate Charges
Invoice Events
Polar emits events when invoices are generated:Best Practices
Transparent Pricing
- Show unit prices clearly: Display on your pricing page
- Explain included credits: Make base allowance obvious
- Provide examples: Show sample usage calculations
- Update estimates: Show real-time usage in dashboard
Customer Communication
- Mid-cycle alerts: Notify at 50%, 80%, 100% of credits
- Pre-invoice summary: Email usage summary before billing
- Invoice details: Break down charges clearly
- Usage analytics: Provide daily/weekly usage reports
Pricing Strategy
- Include base credits: Makes pricing easier to understand
- Use round numbers: 0.01, 0.00873
- Tier thoughtfully: Align tiers with customer segments
- Test pricing: A/B test different rate structures
Technical Implementation
- Monitor for anomalies: Alert on unusual spikes
- Validate before invoicing: Review high consumption before charging
- Handle edge cases: Consider rounding, minimums, maximums
- Archive old data: Keep historical billing data accessible
Common Scenarios
Freemium to Paid
Customer starts on free plan, upgrades mid-month:Overage Scenario
Customer exceeds included credits:Multi-Meter Billing
Customer has multiple metered prices:Troubleshooting
Usage Not Appearing on Invoice
- Check billing cycle: Events must occur during the cycle
- Verify meter is linked: Price must reference the meter
- Confirm price is active: Subscription must include the metered price
- Review filter: Ensure events match meter filter
Incorrect Amount Charged
- Verify pricing tiers: Check tier boundaries and rates
- Check included credits: Ensure credits are applied
- Review aggregation: Confirm aggregation function is correct
- Inspect events: Count actual events for the period
Meter Didn’t Reset
- Check reset event: Look for
meter.resetafter invoice - Verify cycle completion: Ensure billing cycle actually ended
- Review subscription status: Canceled subscriptions don’t reset
- Check for errors: Review logs for reset failures
Next Steps
Orders API
Access invoice and order data
Webhooks
Get notified of billing events