Contracts
Contracts are the active subscriptions between your customers and plans. They determine what a customer is billed for.What is a Contract?
A contract connects:- A customer who pays
- A plan that defines pricing
- Terms like start date and billing cycle
Contract Lifecycle
| State | Description |
|---|---|
ACTIVE | Customer is being billed according to the plan |
CANCELLED | Contract has been terminated, no future billing |
How Contracts Work
- Contract starts — First invoice is generated
- Base fee applied — Plan’s recurring fee added to invoice
- Usage accumulates — Events matching plan’s meters are tracked
- Billing cycle ends — Usage is finalized and invoiced
- Cycle repeats — Next invoice generated, usage resets
Creating Contracts
Required Fields
| Field | Description |
|---|---|
customerId | Which customer this contract is for |
planId | Which plan to subscribe them to |
startDate | When billing begins |
Optional Fields
| Field | Description |
|---|---|
endDate | When contract automatically ends (for fixed-term) |
billingCycleAnchor | Day of month for billing (e.g., always bill on the 1st) |
netTerms | Days until payment due (default: 0) |
Billing Cycle Anchor
The billing cycle anchor determines when invoices are generated. Example: Monthly plan with anchor on the 15thIf not specified, the billing cycle anchor defaults to the contract start
date.
Plan Changes
Customers can change plans mid-cycle:Upgrade Behavior
- Current invoice is finalized with prorated usage
- New plan takes effect immediately
- Prorated base fee for remainder of cycle
Downgrade Behavior
- New plan takes effect at next billing cycle
- Current cycle continues on old plan
- No proration (they paid for the current cycle)
Cancellation
When a contract is cancelled:- Immediate: Contract ends now, final invoice generated with usage to date
- End of period: Contract continues until billing cycle ends
Multiple Contracts
A customer can have multiple active contracts:- Different products (e.g., API access + Data platform)
- Separate billing for different teams or projects
- Gradual migration between plans
Contract vs Invoice
| Concept | Description |
|---|---|
| Contract | Ongoing relationship defining what to bill |
| Invoice | Point-in-time bill for a specific period |
Next Steps
How Usage-Based Billing Works
See how contracts fit into the full billing flow
Create Your First Contract
Step-by-step guide
Contracts API
API reference
Enterprise Billing
Custom rates and prepaid commitments
Plan Changes
Upgrade or downgrade
Cancellation
End a contract