Overview
The Autumn Python SDK provides a type-safe interface for managing customers, subscriptions, usage tracking, and billing. This guide covers common use cases and patterns.Quick Start
Customer Management
Get or Create a Customer
Theget_or_create method is idempotent and updates customer data if they already exist:
List Customers
Update a Customer
Delete a Customer
Usage Tracking
Check Feature Access
Check if a customer can access a feature before allowing the action:Check and Track Atomically
Combine checking and tracking in a single request for atomic operations:Track Usage
Record usage after an action occurs:Entity-Scoped Usage
Track usage scoped to specific entities (seats, projects, workspaces):Subscription Management
Attach a Plan
Subscribe a customer to a plan:Attach Multiple Plans
Subscribe to multiple plans in a single subscription:Preview Plan Changes
Show customers the cost before making changes:Update a Subscription
Customer Portal
Create a session for customers to manage their billing:Setup Payment Method
Balance Management
Create a Balance
Manually create or grant balances:Update a Balance
Plans and Features
Create a Plan
List Plans
Create a Feature
List Features
Events and Analytics
List Usage Events
Aggregate Events
Referral Programs
Create a Referral Code
Redeem a Referral Code
Async/Await Support
All methods have async equivalents with_async suffix:
Error Handling
The SDK raises specific exceptions for different error cases:Common Error Patterns
Best Practices
1. Use Context Managers
Always usewith statements to ensure proper resource cleanup:
2. Reuse Client Instances
Create one client instance and reuse it:3. Use Type Hints
The SDK includes full type hints for better IDE support:4. Handle Errors Gracefully
Always implement error handling for production code:5. Use Environment-Specific Configuration
Next Steps
API Reference
Explore the complete API documentation
Webhook Events
Learn how to handle webhook events
TypeScript SDK
Check out the TypeScript SDK
Examples
View example implementations