Installation
Add the SDK to your project with Cargo:Cargo.toml manually:
The SDK requires Rust 1.75 or later, leveraging modern async features for optimal performance.
Quick Start
The client reads your API key from theDODO_PAYMENTS_API_KEY environment variable by default. Initialize the client and create your first checkout session:
Core Features
Async First
Built on Tokio and reqwest with
async/await support throughoutStrong Typing
Strongly typed requests and responses for compile-time safety
Auto-Pagination
Stream every item across pages or advance one page at a time
Configurable
Configure environments, timeouts, and base URLs per client
Configuration
Environment Variables
By default,Client::from_env() reads your API key from the DODO_PAYMENTS_API_KEY environment variable and uses the default base URL unless you set DODO_PAYMENTS_BASE_URL:
Client::new returns a Result, so unwrap it with ? inside a function that returns dodopayments::Result:
Environments
The default base URL is
https://live.dodopayments.com. Select another environment with the Environment enum instead of hard-coding URLs:
DODO_PAYMENTS_API_KEY via from_env() while targeting a non-default environment, override it on the config:
Timeouts
The default request timeout is 30 seconds. Override it per client:Common Operations
Create a Checkout Session
Generate a checkout session:Manage Customers
Create and retrieve customer information:Handle Subscriptions
Create and manage recurring subscriptions:billing requires at minimum the two-letter ISO country code. customer is a CustomerRequest enum — pass AttachExisting for an existing customer or New for a new one. Amount fields such as product_price are in the lowest currency denomination (e.g., 2500 = $25.00 USD).Usage-Based Billing
Ingest Usage Events
Track custom events:List Usage Events
Pagination
List endpoints return a typed page whoseitems field holds the current page of results. Stream every item across all pages with into_stream:
get_next_page:
Error Handling
Every method returns adodopayments::Result<T>. Failures are represented by the dodopayments::Error enum. Match on it to handle API errors distinctly from transport errors:
Undocumented Endpoints
To call an endpoint not yet exposed as a typed method, use the low-levelrequest builder, which applies authentication and the base URL:
Resources
GitHub Repository
View source code and contribute
Crates.io
View the published crate and versions
API Reference
Complete API documentation
Discord Community
Get help and connect with developers
Support
Need help with the Rust SDK?- Discord: Join our community server for real-time support
- Email: Contact us at support@dodopayments.com
- GitHub: Open an issue on the repository