Skip to main content
The Rust SDK provides convenient, async-first access to the Dodo Payments REST API from applications written in Rust. It offers strongly typed requests and responses, built-in pagination helpers, and configurable timeouts and environments.

Installation

Add the SDK to your project with Cargo:
Or add it to your 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 the DODO_PAYMENTS_API_KEY environment variable by default. Initialize the client and create your first checkout session:
Always store your API keys securely using environment variables. Never hardcode them in your source code.

Core Features

Async First

Built on Tokio and reqwest with async/await support throughout

Strong 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:
You can also configure the client explicitly. 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:
To keep reading the API key from 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 whose items field holds the current page of results. Stream every item across all pages with into_stream:
Or advance one page at a time with get_next_page:

Error Handling

Every method returns a dodopayments::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-level request 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?

Contributing

We welcome contributions! Check the contributing guidelines to get started.
Last modified on June 20, 2026