Introduction
Welcome to the documentation of the DodoPayments Rust SDK.
This library provides a high-performance, type-safe interface to interact with the DodoPayments API. This guide will help you integrate payments into your Rust application.
Keeping developer experience, type safety, and robust error handling in mind, this SDK makes integration simple and reliable.
Contributing
DodoPayments Rust SDK is open source. You can find the source code on GitHub and issues and feature requests can be posted on the GitHub issue tracker. If you’d like to contribute, please raise an issue on the GitHub and considfer opening a pull request.
License
The SDK source and documentation are released under the MIT License
Quick Start
This guide will help you get started with the DodoPayments Rust SDK and make your first API request.
By the end of this guide, you’ll have a basic setup ready and will be able to interact with DodoPayments directly from your Rust application.
Installation
- Install via CLI
#![allow(unused)] fn main() { cargo add dodopayments_rust }
- Manual Installation by adding in your
Cargo.toml
#![allow(unused)] fn main() { dodopayments_rust = "2.0.0" }
Initialize client
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; }
Make your first request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.payments().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Addons
Create Addon
Create a new addon product that can be attached to subscription products.
Request
use dodopayments_rust::{models::CreateAddonRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .addons() .create() .body(CreateAddonRequest { name: "Premium Support".to_string(), price: 99, ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
currency | Currency | The currency of the Addon |
description | object | Optional description of the Addon |
name | string | Name of the Addon |
price | integer | Amount of the addon |
tax_category | TaxCategory | Tax category applied to this Addon |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | Unique identifier for the business to which the addon belongs. |
created_at | string | Created time |
currency | Currency | Currency of the Addon |
description | object | Optional description of the Addon |
id | string | id of the Addon |
image | object | Image of the Addon |
name | string | Name of the Addon |
price | integer | Amount of the addon |
tax_category | TaxCategory | Tax category applied to this Addon |
updated_at | string | Updated time |
Create a new addon
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Addon Detail
Retrieve detailed information about a specific addon.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let addon_id = "addon_xxxxxxxxxx"; let resp = client.addons().id(addon_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Addon Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | Unique identifier for the business to which the addon belongs. |
created_at | string | Created time |
currency | Currency | Currency of the Addon |
description | object | Optional description of the Addon |
id | string | id of the Addon |
image | object | Image of the Addon |
name | string | Name of the Addon |
price | integer | Amount of the addon |
tax_category | TaxCategory | Tax category applied to this Addon |
updated_at | string | Updated time |
Retrieve a specific addon
500 Status
Something went wrong :(
Get Addons
Retrieve a comprehensive list of all available addons.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.addons().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<AddonResponse> |
List all addons
500 Status
Something went wrong :(
Update Addon
Modify the details of an existing addon.
Request
use dodopayments_rust::{models::PatchAddonRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let addon_id = "addon_xxxxxxxxxx"; let resp = client .addons() .id(addon_id) .update() .body(PatchAddonRequest { name: Some("Updated Addon".to_string()), price: Some(19), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Addon Id |
Body
| Field | Type | Description |
|---|---|---|
currency | object | |
description | object | Description of the Addon, optional and must be at most 1000 characters. |
image_id | object | Addon image id after its uploaded to S3 |
name | object | Name of the Addon, optional and must be at most 100 characters. |
price | object | Amount of the addon |
tax_category | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | Unique identifier for the business to which the addon belongs. |
created_at | string | Created time |
currency | Currency | Currency of the Addon |
description | object | Optional description of the Addon |
id | string | id of the Addon |
image | object | Image of the Addon |
name | string | Name of the Addon |
price | integer | Amount of the addon |
tax_category | TaxCategory | Tax category applied to this Addon |
updated_at | string | Updated time |
Patch update an addon
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Update Addon Image
Update images for an existing addon.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let addon_id = "addon_xxxxxxxxxx"; let resp = client.addons().id(addon_id).update_image().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Addon Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
image_id | string | |
url | string |
Generate presigned upload URL for addon image
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Balance Ledger
Get Balance Ledger Entries
List all customer balances for a specific credit entitlement.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.balance_ledgers_entries().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
credit_entitlement_id | string | Credit Entitlement ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CustomerCreditBalanceResponse> |
List of customer balances
404 Status
Credit entitlement not found
500 Status
Something went wrong :(
Brands
Create Brand
Create a new brand.
Request
use dodopayments_rust::{models::CreateBrandRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .brands() .create() .body(CreateBrandRequest { name: Some("My Brand".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
description | object | |
name | object | |
statement_descriptor | object | |
support_email | object | |
url | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
brand_id | string | |
business_id | string | |
description | object | |
enabled | boolean | |
image | object | |
name | object | |
reason_for_hold | object | Incase the brand verification fails or is put on hold |
statement_descriptor | string | |
support_email | object | |
url | object | |
verification_enabled | boolean | |
verification_status | BrandVerificationStatus |
Created Brand
Get Brand Detail
Retrieve a specific brand by ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let brand_id = "brand_xxxxxxxxxx"; let resp = client.brands().id(brand_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Brand Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
brand_id | string | |
business_id | string | |
description | object | |
enabled | boolean | |
image | object | |
name | object | |
reason_for_hold | object | Incase the brand verification fails or is put on hold |
statement_descriptor | string | |
support_email | object | |
url | object | |
verification_enabled | boolean | |
verification_status | BrandVerificationStatus |
Get a single brand
404 Status
Brand not found
Get Brands
List all brands.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.brands().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<BrandResponse> | List of brands for this business |
List all brands
Update Brand
Update an existing brand's details.
Request
use dodopayments_rust::{models::PatchBrandRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let brand_id = "brand_xxxxxxxxxx"; let resp = client .brands() .id(brand_id) .update() .body(PatchBrandRequest { name: Some("Updated Brand".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Brand Id |
Body
| Field | Type | Description |
|---|---|---|
description | object | |
image_id | object | The UUID you got back from the presigned‐upload call |
name | object | |
statement_descriptor | object | |
support_email | object | |
url | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
brand_id | string | |
business_id | string | |
description | object | |
enabled | boolean | |
image | object | |
name | object | |
reason_for_hold | object | Incase the brand verification fails or is put on hold |
statement_descriptor | string | |
support_email | object | |
url | object | |
verification_enabled | boolean | |
verification_status | BrandVerificationStatus |
Updated Brand
403 Status
Primary brand cannot be updated via this API
404 Status
Brand not found
Update Brand Image
Update the images associated with a brand.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let brand_id = "brand_xxxxxxxxxx"; let resp = client .brands() .id(brand_id) .update_brand_image() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Brand Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
image_id | string | UUID that will be used as the image identifier/key suffix |
url | string | Presigned URL to upload the image |
Generate presigned upload URL for brand image
Checkout Sessions
Create Checkout
Unified endpoint for creating checkout sessions for all types of billing requirements.
Request
use dodopayments_rust::{ models::{CreateCheckoutSessionRequest, ProductItemReq}, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .checkout_session() .create() .body(CreateCheckoutSessionRequest { product_cart: vec![ProductItemReq { product_id: "prod_xxxxxxxxxx".to_string(), quantity: 1, addons: None, amount: None, }], return_url: Some("https://example.com/success".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
Checkout session successfully created
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Preview Checkout Session
Preview a checkout session to calculate pricing, taxes, and totals without creating an actual session.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_key = std::env::var("DODO_API_KEY")?;
let client = DodoPaymentsClientBuilder::new()
.bearer_token(&api_key)
.enviroment("test_mode")
.build()?;
println!("Note: preview_checkout requires complex request types.");
println!("See create_checkout.rs for checkout session creation example.");
Ok(())
}
Responses
200 Status
Checkout session preview calculated successfully
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Checkout Details
Retrieve details of a specific checkout session by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let checkout_id = "checkout_xxxxxxxxxx"; let resp = client .checkout_session() .id(checkout_id) .retrieve() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
Checkout session successfully fetched
404 Status
Not found
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Credit Entitlements
Create Credit Entitlement
Create a new credit entitlement for the authenticated business.
Each entitlement defines how credits behave in terms of expiration, rollover, and overage.
Business Logic
- A unique ID with prefix
cde_is automatically generated for the entitlement - Created and updated timestamps are automatically set
- Currency is required when price_per_unit is set
- price_per_unit is required when overage_enabled is true
- rollover_timeframe_count and rollover_timeframe_interval must both be set or both be null
Request
use dodopayments_rust::{ models::CreateCreditEntitlementRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .credit_entitlements() .create() .body(CreateCreditEntitlementRequest { name: "Basic Credits".to_string(), description: Some("Monthly credit allocation".to_string()), unit: "credits".to_string(), price_per_unit: Some("1.00".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
currency | object | |
description | object | Optional description of the credit entitlement |
expires_after_days | object | Number of days after which credits expire (optional) |
max_rollover_count | object | Maximum number of times credits can be rolled over |
name | string | Name of the credit entitlement |
overage_behavior | object | |
overage_enabled | boolean | Whether overage charges are enabled when credits run out |
overage_limit | object | Maximum overage units allowed (optional) |
precision | integer | Precision for credit amounts (0-10 decimal places) |
price_per_unit | object | Price per credit unit |
rollover_enabled | boolean | Whether rollover is enabled for unused credits |
rollover_percentage | object | Percentage of unused credits that can rollover (0-100) |
rollover_timeframe_count | object | Count of timeframe periods for rollover limit |
rollover_timeframe_interval | object | |
unit | string | Unit of measurement for the credit (e.g., "API Calls", "Tokens", "Credits") |
Responses
201 Status
Credit entitlement created successfully
| Field | Type | Description |
|---|---|---|
business_id | string | - |
created_at | string | - |
currency | object | - |
description | object | - |
expires_after_days | object | - |
id | string | - |
max_rollover_count | object | - |
name | string | - |
overage_behavior | object | Controls how overage is handled at billing cycle end. |
overage_enabled | boolean | - |
overage_limit | object | - |
precision | integer | - |
price_per_unit | object | Price per credit unit |
rollover_enabled | boolean | - |
rollover_percentage | object | - |
rollover_timeframe_count | object | - |
rollover_timeframe_interval | object | - |
unit | string | - |
updated_at | string | - |
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Delete Credit Entitlement
Soft-delete a credit entitlement by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .delete() .send() .await?; println!("Credit entitlement deleted successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Credit Entitlement ID |
Responses
200 Status
Credit entitlement deleted successfully
404 Status
Credit entitlement not found
410 Status
Credit entitlement is already deleted
500 Status
Something went wrong :(
Get Credit Entitlement Detail
Retrieve a specific credit entitlement by its ID.
settings for expiration, rollover, and overage policies.
Business Logic
- Only non-deleted credit entitlements can be retrieved through this
- The entitlement must belong to the authenticated business (business_id check)
- Deleted entitlements return a 404 error and must be retrieved via the list with
deleted=true
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .retrieve() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Credit Entitlement ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
currency | object | |
description | object | |
expires_after_days | object | |
id | string | |
max_rollover_count | object | |
name | string | |
overage_behavior | CbbOverageBehavior | Controls how overage is handled at billing cycle end. |
overage_enabled | boolean | |
overage_limit | object | |
precision | integer | |
price_per_unit | object | Price per credit unit |
rollover_enabled | boolean | |
rollover_percentage | object | |
rollover_timeframe_count | object | |
rollover_timeframe_interval | object | |
unit | string | |
updated_at | string |
Credit entitlement details
404 Status
Credit entitlement not found
500 Status
Something went wrong :(
Get Credit Entitlements
List all credit entitlements for the authenticated business with pagination support.
entitlements. By default, only non-deleted entitlements are returned.
Business Logic
- Results are ordered by creation date in descending order (newest first)
- Only entitlements belonging to the authenticated business are returned
- The
deletedparameter controls visibility of soft-deleted entitlements - Pagination uses offset-based pagination (offset = page_number * page_size)
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.credit_entitlements().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CreditEntitlementResponse> |
Credit Entitlements List
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Customer Credit Balance
Get a specific customer's balance for a credit entitlement.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let customer_id = "cus_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .customer_id(customer_id) .retrieve_customer_balance() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
credit_entitlement_id | string | Credit Entitlement ID |
customer_id | string | Customer ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
balance | string | |
created_at | string | |
credit_entitlement_id | string | |
customer_id | string | |
id | string | |
last_transaction_at | object | |
overage | string | |
updated_at | string |
Customer balance details
404 Status
Credit entitlement or balance not found
500 Status
Something went wrong :(
Get Customer Credit Grants
List credit grants for a customer under a specific credit entitlement.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let customer_id = "cus_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .customer_id(customer_id) .list_customer_grants() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
credit_entitlement_id | string | Credit Entitlement ID |
customer_id | string | Customer ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CreditGrantResponse> |
List of customer grants
404 Status
Credit entitlement not found
500 Status
Something went wrong :(
Get Customer Credit Ledger
List ledger entries for a customer under a specific credit entitlement.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; # Path Parameters | Parameter | Type | Description | | :--- | :--- | :--- | | `credit_entitlement_id` | `string` | `Credit Entitlement ID` | | `customer_id` | `string` | `Customer ID` | #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let customer_id = "cus_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .customer_id(customer_id) .list_customer_ledger() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
credit_entitlement_id | string | Credit Entitlement ID |
customer_id | string | Customer ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CreditLedgerEntryResponse> |
List of ledger entries
404 Status
Credit entitlement not found
500 Status
Something went wrong :(
Undelete Credit Entitlement
Restore a previously deleted credit entitlement.
making it available again through standard list and get s.
Business Logic
- Only deleted credit entitlements can be restored
- The query filters for
deleted_at IS NOT NULL, so non-deleted entitlements will result in 0 rows affected - If no rows are affected (entitlement doesn't exist, doesn't belong to business, or is not deleted), returns 500
- The
updated_attimestamp is automatically updated on successful restoration - Once restored, the entitlement becomes immediately available in the standard list and get s
- All configuration settings are preserved during delete/restore operations
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .undelete() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Credit Entitlement ID |
Responses
200 Status
Credit Entitlement Restored Successfully
500 Status
Something went wrong :(
Update Credit Entitlement
Update an existing credit entitlement with partial data.
provided in the request body will be updated; all other fields remain unchanged. This supports nullable fields using the double option pattern.
Business Logic
- Only non-deleted credit entitlements can be updated
- Fields set to
nullexplicitly will clear the database value (using double option pattern) - The
updated_attimestamp is automatically updated on successful modification - Changes take effect immediately but do not retroactively affect existing credit grants
- The merged state is validated: currency required with price, rollover timeframe fields together, price required for overage
Request
use dodopayments_rust::{ models::PatchCreditEntitlementRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .update() .body(PatchCreditEntitlementRequest { name: Some("Updated Credits".to_string()), description: Some("Updated credit allocation".to_string()), unit: Some("credits".to_string()), price_per_unit: Some("1.00".to_string()), currency: None, expires_after_days: None, max_rollover_count: None, overage_behavior: None, overage_enabled: None, overage_limit: None, rollover_enabled: None, rollover_percentage: None, rollover_timeframe_count: None, rollover_timeframe_interval: None, }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Credit Entitlement ID |
Body
| Field | Type | Description |
|---|---|---|
currency | object | |
description | object | Optional description of the credit entitlement |
expires_after_days | object | Number of days after which credits expire |
max_rollover_count | object | Maximum number of times credits can be rolled over |
name | object | Name of the credit entitlement |
overage_behavior | object | |
overage_enabled | object | Whether overage charges are enabled when credits run out |
overage_limit | object | Maximum overage units allowed |
price_per_unit | object | Price per credit unit |
rollover_enabled | object | Whether rollover is enabled for unused credits |
rollover_percentage | object | Percentage of unused credits that can rollover (0-100) |
rollover_timeframe_count | object | Count of timeframe periods for rollover limit |
rollover_timeframe_interval | object | |
unit | object | Unit of measurement for the credit (e.g., "API Calls", "Tokens", "Credits") |
Responses
200 Status
Credit entitlement updated successfully
404 Status
Credit entitlement not found
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Customers
Create Customer
Create a new customer in your Dodo Payments account.
Request
use dodopayments_rust::{models::CreateCustomerRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .customers() .create() .body(CreateCustomerRequest { email: "customer@example.com".to_string(), name: "John Doe".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
email | string | |
metadata | Metadata | Additional metadata for the customer |
name | string | |
phone_number | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
customer_id | string | |
email | string | |
metadata | Metadata | Additional metadata for the customer |
name | string | |
phone_number | object |
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Create Customer Credit Ledger Entry
Add or deduct monetary funds in a customer's wallet using entry_type 'credit' or 'debit'.
Request
use dodopayments_rust::{ models::{CreateLedgerEntryRequest, LedgerEntryType}, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let entitlement_id = "ent_xxxxxxxxxx"; let customer_id = "cus_xxxxxxxxxx"; let resp = client .credit_entitlements() .id(entitlement_id) .customer_id(customer_id) .create_customer_ledger_entry() .body(CreateLedgerEntryRequest { amount: "100".to_string(), entry_type: LedgerEntryType::Credit, reason: None, idempotency_key: None, expires_at: None, metadata: None, }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer ID |
Body
| Field | Type | Description |
|---|---|---|
amount | integer | |
currency | Currency | Currency of the wallet to adjust |
entry_type | CustomerLedgerEntryType | Type of ledger entry - credit or debit |
idempotency_key | object | Optional idempotency key to prevent duplicate entries |
reason | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
balance | integer | |
created_at | string | |
currency | Currency | |
customer_id | string | |
updated_at | string |
400 Status
Insufficient balance for debit
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Create Customer Portal Session
Create a session of the Customer Portal for a specific customer.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let customer_id = "cus_xxxxxxxxxx"; let resp = client .customers() .id(customer_id) .create_customer_portal() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
link | string |
Successfully send email to customer (if they exist)
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Customer Detail
Get detailed information about a specific customer.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let customer_id = "cus_xxxxxxxxxx"; let resp = client.customers().id(customer_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
customer_id | string | |
email | string | |
metadata | Metadata | Additional metadata for the customer |
name | string | |
phone_number | object |
500 Status
Something went wrong :(
Get Customer Wallet Ledger Entries
List wallet ledger entries (fund additions and deductions) for a specific customer.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let customer_id = "cus_xxxxxxxxxx"; let resp = client .customers() .id(customer_id) .retrieve_customer_wallet_ledger_entries() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CustomerWalletTransactionResponse> |
500 Status
Something went wrong :(
Get Customer Wallets
Retrieve monetary wallet balances associated with a specific customer. Wallets hold real funds (USD, EUR, etc.).
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let customer_id = "cus_xxxxxxxxxx"; let resp = client .customers() .id(customer_id) .list_customer_wallets() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CustomerWalletResponse> | |
total_balance_usd | integer | Sum of all wallet balances converted to USD (in smallest unit) |
500 Status
Something went wrong :(
Get Customers
Get a list of all customers associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.customers().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<CustomerResponse> |
Customers List
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Update Customer
Update a customer's information.
Request
use dodopayments_rust::{models::PatchCustomerRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let customer_id = "cus_xxxxxxxxxx"; let resp = client .customers() .id(customer_id) .update() .body(PatchCustomerRequest { name: Some("Updated Name".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
customer_id | string | Customer Id |
Body
| Field | Type | Description |
|---|---|---|
email | object | |
metadata | object | |
name | object | |
phone_number | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
customer_id | string | |
email | string | |
metadata | Metadata | Additional metadata for the customer |
name | string | |
phone_number | object |
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Discounts
Create Discount
Create a discount for your account.
Request
use dodopayments_rust::{ models::{CreateDiscountRequest, DiscountType}, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .discounts() .create() .body(CreateDiscountRequest { amount: 10, r#type: DiscountType::Percentage, ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
amount | integer | The discount amount. - If discount_type is not percentage, amount is in USD cents. For example, 100 means $1.00. Only USD is allowed. - If discount_type is percentage, amount is in basis points. For example, 540 means 5.4%. Must be at least 1. |
code | object | Optionally supply a code (will be uppercased). - Must be at least 3 characters if provided. - If omitted, a random 16-character code is generated. |
expires_at | object | When the discount expires, if ever. |
name | object | |
preserve_on_plan_change | boolean | Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change) |
restricted_to | object | List of product IDs to restrict usage (if any). |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
type | DiscountType | The discount type (e.g. percentage, flat, or flat_per_unit). |
usage_limit | object | How many times this discount can be used (if any). Must be >= 1 if provided. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | integer | The discount amount. - If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). - Otherwise, this is USD cents (e.g., 100 => $1.00). |
business_id | string | The business this discount belongs to. |
code | string | The discount code (up to 16 chars). |
created_at | string | Timestamp when the discount is created |
discount_id | string | The unique discount ID |
expires_at | object | Optional date/time after which discount is expired. |
name | object | Name for the Discount |
preserve_on_plan_change | boolean | Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change) |
restricted_to | array<string> | List of product IDs to which this discount is restricted. |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
times_used | integer | How many times this discount has been used. |
type | DiscountType | The type of discount, e.g. percentage, flat, or flat_per_unit. |
usage_limit | object | Usage limit for this discount, if any. |
-
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
Created discount
- If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Delete Discount
Delete a discount from your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let discount_id = "dis_xxxxxxxxxx"; let resp = client.discounts().id(discount_id).delete().send().await?; println!("Discount deleted successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
discount_id | string | Discount Id |
Responses
204 Status
Soft-deleted discount (no content)
404 Status
Discount not found or already deleted
500 Status
Something went wrong :(
Get Discount By Code
Validate and retrieve a discount by its code name (e.g. 'SAVE20') instead of using the internal discount ID.
This allows real-time validation directly against the API using the human-readable discount code instead of requiring the internal discount_id.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let discount_code = ""; let resp = client .discounts() .code(discount_code) .retrieve_by_code() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
code | string | The discount code (e.g., 'SAVE20') |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | integer | The discount amount. - If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). - Otherwise, this is USD cents (e.g., 100 => $1.00). |
business_id | string | The business this discount belongs to. |
code | string | The discount code (up to 16 chars). |
created_at | string | Timestamp when the discount is created |
discount_id | string | The unique discount ID |
expires_at | object | Optional date/time after which discount is expired. |
name | object | Name for the Discount |
preserve_on_plan_change | boolean | Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change) |
restricted_to | array<string> | List of product IDs to which this discount is restricted. |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
times_used | integer | How many times this discount has been used. |
type | DiscountType | The type of discount, e.g. percentage, flat, or flat_per_unit. |
usage_limit | object | Usage limit for this discount, if any. |
-
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
Fetched discount by code
- If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
404 Status
Discount code not found or soft-deleted
422 Status
Discount code expired or usage limit exceeded
500 Status
Something went wrong :(
Get Discount Detail
Validate a discount code to check if it is valid and can be applied.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let discount_id = "dis_xxxxxxxxxx"; let resp = client.discounts().id(discount_id).validate().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
discount_id | string | Discount Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | integer | The discount amount. - If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). - Otherwise, this is USD cents (e.g., 100 => $1.00). |
business_id | string | The business this discount belongs to. |
code | string | The discount code (up to 16 chars). |
created_at | string | Timestamp when the discount is created |
discount_id | string | The unique discount ID |
expires_at | object | Optional date/time after which discount is expired. |
name | object | Name for the Discount |
preserve_on_plan_change | boolean | Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change) |
restricted_to | array<string> | List of product IDs to which this discount is restricted. |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
times_used | integer | How many times this discount has been used. |
type | DiscountType | The type of discount, e.g. percentage, flat, or flat_per_unit. |
usage_limit | object | Usage limit for this discount, if any. |
-
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
Fetched discount by ID
- If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
404 Status
Not found / or soft-deleted
500 Status
Something went wrong :(
Get Discounts
Retrieve a list of all discounts associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.discounts().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<DiscountResponse> | Array of active (non-deleted) discounts for the current page. |
List of active Discounts
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Update Discount
Update a discount in your account.
Request
use dodopayments_rust::{models::PatchDiscountRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let discount_id = "dis_xxxxxxxxxx"; let resp = client .discounts() .id(discount_id) .update() .body(PatchDiscountRequest { amount: Some(15), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
discount_id | string | Discount Id |
Body
| Field | Type | Description |
|---|---|---|
amount | object | If present, update the discount amount: - If discount_type is percentage, this represents basis points (e.g., 540 = 5.4%). - Otherwise, this represents USD cents (e.g., 100 = $1.00). Must be at least 1 if provided. |
code | object | If present, update the discount code (uppercase). |
expires_at | object | |
name | object | |
preserve_on_plan_change | object | Whether this discount should be preserved when a subscription changes plans. If not provided, the existing value is kept. |
restricted_to | object | If present, replaces all restricted product IDs with this new set. To remove all restrictions, send empty array |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
type | object | |
usage_limit | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | integer | The discount amount. - If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). - Otherwise, this is USD cents (e.g., 100 => $1.00). |
business_id | string | The business this discount belongs to. |
code | string | The discount code (up to 16 chars). |
created_at | string | Timestamp when the discount is created |
discount_id | string | The unique discount ID |
expires_at | object | Optional date/time after which discount is expired. |
name | object | Name for the Discount |
preserve_on_plan_change | boolean | Whether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change) |
restricted_to | array<string> | List of product IDs to which this discount is restricted. |
subscription_cycles | object | Number of subscription billing cycles this discount is valid for. If not provided, the discount will be applied indefinitely to all recurring payments related to the subscription. |
times_used | integer | How many times this discount has been used. |
type | DiscountType | The type of discount, e.g. percentage, flat, or flat_per_unit. |
usage_limit | object | Usage limit for this discount, if any. |
-
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to -
If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
Updated discount
- If
discount_typeispercentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to
404 Status
Discount not found or soft-deleted
500 Status
Something went wrong :(
Disputes
Get Dispute Detail
Get detailed information about a specific dispute.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let dispute_id = "dispute_xxxxxxxxxx"; let resp = client.disputes().id(dispute_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
dispute_id | string | Dispute Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | string | The amount involved in the dispute, represented as a string to accommodate precision. |
business_id | string | The unique identifier of the business involved in the dispute. |
created_at | string | The timestamp of when the dispute was created, in UTC. |
currency | string | The currency of the disputed amount, represented as an ISO 4217 currency code. |
customer | CustomerLimitedDetailsResponse | The customer who filed the dispute |
dispute_id | string | The unique identifier of the dispute. |
dispute_stage | DisputeStage | The current stage of the dispute process. |
dispute_status | DisputeStatus | The current status of the dispute. |
is_resolved_by_rdr | object | Whether the dispute was resolved by Rapid Dispute Resolution |
payment_id | string | The unique identifier of the payment associated with the dispute. |
reason | object | Reason for the dispute |
remarks | object | Remarks |
500 Status
Something went wrong :(
Get Disputes
Get a list of all disputes associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.disputes().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<ListDisputeResponse> |
500 Status
Something went wrong :(
Events
Get Event Deatils
Get a specific usage event by its ID.
- Debugging specific event ingestion issues
- Retrieving event details for customer support
- Validating that events were processed correctly
- Getting the complete metadata for an event
Event ID Format:
The event ID should be the same value that was provided during event ingestion via the /events/ingest .
Event IDs are case-sensitive and must match exactly.
Response Details:
The response includes all event data including:
- Complete metadata key-value pairs
- Original timestamp (preserved from ingestion)
- Customer and business association
- Event name and processing information
Example Usage:
GET /events/api_call_12345
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let event_id = "evt_xxxxxxxxxx"; let resp = client.usage_events().id(event_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
event_id | string | Unique event identifier (case-sensitive, must match the ID used during ingestion) |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
customer_id | string | |
event_id | string | |
event_name | string | |
metadata | object | |
timestamp | string |
Event retrieved successfully
401 Status
Unauthorized - invalid or missing API key
404 Status
Event not found - no event exists with the specified ID for your business
422 Status
Unprocessable entity - invalid event ID format
Get Events
Get a list of all usage events.
- Debugging event ingestion issues
- Analyzing customer usage patterns
- Building custom analytics dashboards
- Auditing billing-related events
Filtering Options:
- Customer filtering: Filter by specific customer ID
- Event name filtering: Filter by event type/name
- Meter-based filtering: Use a meter ID to apply the meter's event name and filter criteria automatically
- Time range filtering: Filter events within a specific date range
- Pagination: Navigate through large result sets
Meter Integration:
When using meter_id, the automatically applies:
- The meter's configured
event_namefilter - The meter's custom filter criteria (if any)
- If you also provide
event_name, it must match the meter's event name
Example Queries:
- Get all events for a customer:
?customer_id=cus_abc123 - Get API request events:
?event_name=api_request - Get events from last 24 hours:
?start=2024-01-14T10:30:00Z&end=2024-01-15T10:30:00Z - Get events with meter filtering:
?meter_id=mtr_xyz789 - Paginate results:
?page_size=50&page_number=2
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.usage_events().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<Event> |
Events retrieved successfully
400 Status
Invalid request - invalid query parameters, conflicting meter/event names, or malformed dates
401 Status
Unauthorized - invalid or missing API key
404 Status
Meter not found - the specified meter_id does not exist
422 Status
Unprocessable entity - validation errors in query parameters
Ingest Event
Ingest events for usage-based billing.
- Usage-based billing and metering
- Analytics and reporting
- Customer behavior tracking
Important Notes:
- Duplicate Prevention:
- Duplicate
event_idvalues within the same request are rejected (entire request fails) - Subsequent requests with existing
event_idvalues are ignored (idempotent behavior)
- Duplicate
- Rate Limiting: Maximum 1000 events per request
- Time Validation: Events with timestamps older than 1 hour or more than 5 minutes in the future will be rejected
- Metadata Limits: Maximum 50 key-value pairs per event, keys max 100 chars, values max 500 chars
Example Usage:
{
"events": [
{
"event_id": "api_call_12345",
"customer_id": "cus_abc123",
"event_name": "api_request",
"timestamp": "2024-01-15T10:30:00Z",
"metadata": {
"": "/api/v1/users",
"method": "GET",
"tokens_used": "150"
}
}
]
}
Request
use dodopayments_rust::{models::IngestEventsRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .usage_events() .ingest() .body(IngestEventsRequest { ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
events | array<EventInput> | List of events to be pushed |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
ingested_count | integer |
Events ingested successfully
400 Status
Invalid request - validation errors, duplicate event IDs, or invalid timestamps
401 Status
Unauthorized - invalid or missing API key
413 Status
Payload too large - request exceeds maximum allowed size
422 Status
Unprocessable entity - malformed JSON or schema validation errors
429 Status
Too many requests - rate limit exceeded
Licenses
Activate License
Activate a license for the user.
Request
use dodopayments_rust::{ models::ActivateLicenseKeyRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .licenses() .activate() .body(ActivateLicenseKeyRequest { license_key: "lic_xxxxxxxxxx".to_string(), name: "My Device".to_string(), }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
license_key | string | |
name | string |
Responses
201 Status
License key instance created
| Field | Type | Description |
|---|---|---|
business_id | string | Business ID |
created_at | string | Creation timestamp |
customer | object | Limited customer details associated with the license key. |
id | string | License key instance ID |
license_key_id | string | Associated license key ID |
name | string | Instance name |
product | object | Related product info. Present if the license key is tied to a product. |
403 Status
License key cannot be activated (inactive)
404 Status
License key not found
422 Status
License key activation limit reached
500 Status
Something went wrong :(
Deactivate License
Deactivate a license for the user.
Request
use dodopayments_rust::{ models::DeactivateLicenseKeyRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .licenses() .deactivate() .body(DeactivateLicenseKeyRequest { license_key: "lic_xxxxxxxxxx".to_string(), license_key_instance_id: "lki_xxxxxxxxxx".to_string(), }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
license_key | string | |
license_key_instance_id | string |
Responses
200 Status
License key instance deactivated successfully
403 Status
License key instance not found or does not belong to this license key
404 Status
License key not found
500 Status
Something went wrong :(
Get License Key
Retrieve the details of a specific license key by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let license_key_id = "lic_xxxxxxxxxx"; let resp = client .licenses() .license_keys() .id(license_key_id) .retrieve() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | License key ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
activations_limit | object | The maximum number of activations allowed for this license key. |
business_id | string | The unique identifier of the business associated with the license key. |
created_at | string | The timestamp indicating when the license key was created, in UTC. |
customer_id | string | The unique identifier of the customer associated with the license key. |
expires_at | object | The timestamp indicating when the license key expires, in UTC. |
id | string | The unique identifier of the license key. |
instances_count | integer | The current number of instances activated for this license key. |
key | string | The license key string. |
payment_id | string | The unique identifier of the payment associated with the license key. |
product_id | string | The unique identifier of the product associated with the license key. |
status | LicenseKeyStatus | The current status of the license key (e.g., active, inactive, expired). |
subscription_id | object | The unique identifier of the subscription associated with the license key, if any. |
License key found
404 Status
License key not found
500 Status
Something went wrong :(
Get License Key Instance
Retrieve details of a specific license key instance by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let license_key_id = "lic_xxxxxxxxxx"; let instance_id = "lki_xxxxxxxxxx"; let resp = client .licenses() .license_keys() .id(license_key_id) .license_key_instances() .id(instance_id) .retrieve() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | License key instance ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
id | string | |
license_key_id | string | |
name | string |
License key instance found
404 Status
License key instance not found
500 Status
Something went wrong :(
Get License Key Instances
Retrieve a list of instances for a specific license key.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let license_key_id = "lic_xxxxxxxxxx"; let resp = client .licenses() .license_keys() .id(license_key_id) .license_key_instances() .list() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<LicenseKeyInstanceResponse> |
500 Status
Something went wrong :(
Get Licenses
Retrieve a list of license keys associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.licenses().license_keys().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<LicenseKeyResponse> |
500 Status
Something went wrong :(
Update License Key
Update a license key by its ID.
Request
use dodopayments_rust::{ models::PatchLicenseKeyRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let license_key_id = "lic_xxxxxxxxxx"; let resp = client .licenses() .license_keys() .id(license_key_id) .update() .body(PatchLicenseKeyRequest { activations_limit: Some(10), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | License key ID |
Body
| Field | Type | Description |
|---|---|---|
activations_limit | object | The updated activation limit for the license key. Use null to remove the limit, or omit this field to leave it unchanged. |
disabled | object | Indicates whether the license key should be disabled. A value of true disables the key, while false enables it. Omit this field to leave it unchanged. |
expires_at | object | The updated expiration timestamp for the license key in UTC. Use null to remove the expiration date, or omit this field to leave it unchanged. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
activations_limit | object | The maximum number of activations allowed for this license key. |
business_id | string | The unique identifier of the business associated with the license key. |
created_at | string | The timestamp indicating when the license key was created, in UTC. |
customer_id | string | The unique identifier of the customer associated with the license key. |
expires_at | object | The timestamp indicating when the license key expires, in UTC. |
id | string | The unique identifier of the license key. |
instances_count | integer | The current number of instances activated for this license key. |
key | string | The license key string. |
payment_id | string | The unique identifier of the payment associated with the license key. |
product_id | string | The unique identifier of the product associated with the license key. |
status | LicenseKeyStatus | The current status of the license key (e.g., active, inactive, expired). |
subscription_id | object | The unique identifier of the subscription associated with the license key, if any. |
License key updated successfully
400 Status
Cannot set expiry for subscription-based license
404 Status
License key not found
422 Status
New activation limit is less than current instances count
500 Status
Something went wrong :(
Update License Key Instance
Update a specific license key instance by its ID.
Request
use dodopayments_rust::{ models::PatchLicenseKeyInstanceRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let license_key_id = "lic_xxxxxxxxxx"; let instance_id = "lki_xxxxxxxxxx"; let resp = client .licenses() .license_keys() .id(license_key_id) .license_key_instances() .id(instance_id) .update() .body(PatchLicenseKeyInstanceRequest { name: "Updated Device Name".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | License key instance ID |
Body
| Field | Type | Description |
|---|---|---|
name | string |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
business_id | string | |
created_at | string | |
id | string | |
license_key_id | string | |
name | string |
License key instance updated
404 Status
License key instance not found
500 Status
Something went wrong :(
Validate License
Validate a license for the user.
Request
use dodopayments_rust::{ models::ValidateLicenseKeyRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .licenses() .validate() .body(ValidateLicenseKeyRequest { license_key: "lic_xxxxxxxxxx".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
license_key | string | |
license_key_instance_id | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
valid | boolean |
License key validation result
422 Status
Invalid request format
500 Status
Something went wrong :(
Meters
Archive Meter
Archive a meter by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let meter_id = "meter_xxxxxxxxxx"; let resp = client.meters().id(meter_id).archive().send().await?; println!("Meter archived successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Meter ID |
Responses
204 Status
Meter deleted successfully
404 Status
Meter not found
500 Status
Something went wrong :(
Create Meter
Create a new meter.
Request
use dodopayments_rust::{models::CreateMeterRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .meters() .create() .body(CreateMeterRequest { name: "API Calls".to_string(), event_name: "api_call".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
aggregation | MeterAggregation | Aggregation configuration for the meter |
description | object | Optional description of the meter |
event_name | string | Event name to track |
filter | object | |
measurement_unit | string | measurement unit |
name | string | Name of the meter |
Responses
201 Status
Meter created successfully
| Field | Type | Description |
|---|---|---|
aggregation | object | - |
business_id | string | - |
created_at | string | - |
description | object | - |
event_name | string | - |
filter | object | - |
id | string | - |
measurement_unit | string | - |
name | string | - |
updated_at | string | - |
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Meter Details
Retrieve a meter by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let meter_id = "meter_xxxxxxxxxx"; let resp = client.meters().id(meter_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Meter ID |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
aggregation | MeterAggregation | |
business_id | string | |
created_at | string | |
description | object | |
event_name | string | |
filter | object | |
id | string | |
measurement_unit | string | |
name | string | |
updated_at | string |
Meter details
404 Status
Meter not found
500 Status
Something went wrong :(
Get Meters
Get a list of all meters.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.meters().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<MeterResponse> |
Meters List
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Unarchive Meter
Unarchive a meter by its ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let meter_id = "meter_xxxxxxxxxx"; let resp = client.meters().id(meter_id).unarchive().send().await?; println!("Meter unarchived successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Meter ID |
Responses
200 Status
Meter Unarchived Successfully
500 Status
Something went wrong :(
Misc
Get Supported Countries
Retrieve a list of countries supported by Dodo Payments for checkout.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.misc().list_supported_countries().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
Currently Supported Countries
No specific fields defined.
500 Status
Something went wrong :(
Payments
Create Payment
Create a one-time payment for a customer.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; println!("Note: create payment API is deprecated. Use checkout sessions instead."); println!("See create_checkout.rs example"); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
allowed_payment_method_types | object | List of payment methods allowed during checkout. Customers will never see payment methods that are not in this list. However, adding a method here does not guarantee customers will see it. Availability still depends on other factors (e.g., customer location, merchant settings). |
billing | BillingAddress | Billing address details for the payment |
billing_currency | object | |
customer | CustomerRequest | Customer information for the payment |
discount_code | object | Discount Code to apply to the transaction |
force_3ds | object | Override merchant default 3DS behaviour for this payment |
metadata | Metadata | Additional metadata associated with the payment. Defaults to empty if not provided. |
payment_link | object | Whether to generate a payment link. Defaults to false if not specified. |
payment_method_id | object | Optional payment method ID to use for this payment. If provided, customer_id must also be provided. The payment method will be validated for eligibility with the payment's currency. |
product_cart | array<OneTimeProductCartItemReq> | List of products in the cart. Must contain at least 1 and at most 100 items. |
redirect_immediately | boolean | If true, redirects the customer immediately after payment completion False by default |
return_url | object | Optional URL to redirect the customer after payment. Must be a valid URL if provided. |
short_link | object | If true, returns a shortened payment link. Defaults to false if not specified. |
show_saved_payment_methods | boolean | Display saved payment methods of a returning customer False by default |
tax_id | object | Tax ID in case the payment is B2B. If tax id validation fails the payment creation will fail |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
client_secret | string | Client secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon |
customer | CustomerLimitedDetailsResponse | Limited details about the customer making the payment |
discount_id | object | The discount id if discount is applied |
expires_on | object | Expiry timestamp of the payment link |
metadata | Metadata | Additional metadata associated with the payment |
payment_id | string | Unique identifier for the payment |
payment_link | object | Optional URL to a hosted payment page |
product_cart | object | Optional list of products included in the payment |
total_amount | integer | Total amount of the payment in smallest currency unit (e.g. cents) |
One Time payment successfully initiated
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Payment Detail
Get detailed information about a specific payment.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let payment_id = "pay_xxxxxxxxxx"; let resp = client.payments().id(payment_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
payment_id | string | Payment Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
billing | BillingAddress | Billing address details for payments |
brand_id | string | brand id this payment belongs to |
business_id | string | Identifier of the business associated with the payment |
card_holder_name | object | Cardholder name |
card_issuing_country | object | |
card_last_four | object | The last four digits of the card |
card_network | object | Card network like VISA, MASTERCARD etc. |
card_type | object | The type of card DEBIT or CREDIT |
checkout_session_id | object | If payment is made using a checkout session, this field is set to the id of the session. |
created_at | string | Timestamp when the payment was created |
currency | Currency | Currency used for the payment |
custom_field_responses | object | Customer's responses to custom fields collected during checkout |
customer | CustomerLimitedDetailsResponse | Details about the customer who made the payment |
digital_products_delivered | boolean | brand id this payment belongs to |
discount_id | object | The discount id if discount is applied |
disputes | array<DisputeResponse> | List of disputes associated with this payment |
error_code | object | An error code if the payment failed |
error_message | object | An error message if the payment failed |
invoice_id | object | Invoice ID for this payment. Uses India-specific invoice ID if available. |
invoice_url | object | URL to download the invoice PDF for this payment. |
metadata | Metadata | Additional custom data associated with the payment |
payment_id | string | Unique identifier for the payment |
payment_link | object | Checkout URL |
payment_method | object | Payment method used by customer (e.g. "card", "bank_transfer") |
payment_method_type | object | Specific type of payment method (e.g. "visa", "mastercard") |
product_cart | object | List of products purchased in a one-time payment |
refund_status | object | |
refunds | array<RefundListItem> | List of refunds issued for this payment |
settlement_amount | integer | The amount that will be credited to your Dodo balance after currency conversion and processing. Especially relevant for adaptive pricing where the customer's payment currency differs from your settlement currency. |
settlement_currency | Currency | The currency in which the settlement_amount will be credited to your Dodo balance. This may differ from the customer's payment currency in adaptive pricing scenarios. |
settlement_tax | object | This represents the portion of settlement_amount that corresponds to taxes collected. Especially relevant for adaptive pricing where the tax component must be tracked separately in your Dodo balance. |
status | object | |
subscription_id | object | Identifier of the subscription if payment is part of a subscription |
tax | object | Amount of tax collected in smallest currency unit (e.g. cents) |
total_amount | integer | Total amount charged to the customer including tax, in smallest currency unit (e.g. cents) |
updated_at | object | Timestamp when the payment was last updated |
Especially relevant for adaptive pricing where the tax component must be tracked separately
Especially relevant for adaptive pricing where the tax component must be tracked separately
Especially relevant for adaptive pricing where the tax component must be tracked separately
Especially relevant for adaptive pricing where the tax component must be tracked separately
500 Status
Something went wrong :(
Get Payment Invoice
Get an invoice by Payment ID.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let payment_id = "pay_xxxxxxxxxx"; let invoice = client .payments() .id(payment_id) .retrieve_invoice() .send() .await?; std::fs::write("invoice.pdf", &invoice.0)?; println!("Invoice saved to invoice.pdf"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
payment_id | string | `` |
Responses
200 Status
PDF document
429 Status
Too Many Requests have been sent
500 Status
Something went wrong :(
Get Payment Line Items
Retrieve line items for a specific payment.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let payment_id = "pay_xxxxxxxxxx"; let resp = client.payments().id(payment_id).line_items().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
payment_id | string | Payment Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
currency | Currency | |
items | array<PaymentLineItem> |
Get Payments
Get a list of all payments associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.payments().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<GetPaymentsListResponseItem> |
500 Status
Something went wrong :(
Payouts
Get Payouts
Get a list of all payouts associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.payouts().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<PayoutsResponse> |
Payouts List
500 Status
Something went wrong :(
Products
Create Product
Create a new product.
Request
use dodopayments_rust::{models::CreateProductRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .products() .create() .body(CreateProductRequest { name: "Premium Plan".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
addons | object | Addons available for subscription product |
brand_id | object | Brand id for the product, if not provided will default to primary brand |
credit_entitlements | object | Optional credit entitlements to attach (max 3) |
description | object | Optional description of the product |
digital_product_delivery | object | |
license_key_activation_message | object | Optional message displayed during license key activation |
license_key_activations_limit | object | The number of times the license key can be activated. Must be 0 or greater |
license_key_duration | object | |
license_key_enabled | object | When true, generates and sends a license key to your customer. Defaults to false |
metadata | Metadata | Additional metadata for the product |
name | string | Name of the product |
price | Price | Price configuration for the product |
tax_category | TaxCategory | Tax category applied to this product |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
addons | object | Available Addons for subscription products |
brand_id | string | |
business_id | string | Unique identifier for the business to which the product belongs. |
created_at | string | Timestamp when the product was created. |
credit_entitlements | array<CreditEntitlementMappingResponse> | Attached credit entitlements with settings |
description | object | Description of the product, optional. |
digital_product_delivery | object | |
image | object | URL of the product image, optional. |
is_recurring | boolean | Indicates if the product is recurring (e.g., subscriptions). |
license_key_activation_message | object | Message sent upon license key activation, if applicable. |
license_key_activations_limit | object | Limit on the number of activations for the license key, if enabled. |
license_key_duration | object | |
license_key_enabled | boolean | Indicates whether the product requires a license key. |
metadata | Metadata | Additional custom data associated with the product |
name | object | Name of the product, optional. |
price | Price | Pricing information for the product. |
product_collection_id | object | The product collection ID this product belongs to, if any |
product_id | string | Unique identifier for the product. |
tax_category | TaxCategory | Tax category associated with the product. |
updated_at | string | Timestamp when the product was last updated. |
Product Created Successfully
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Create Product Short Link
Create a short checkout URL with a custom slug for a product.
Request
use dodopayments_rust::{ models::CreateShortLinkRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client .products() .id(product_id) .create_short_link() .body(CreateShortLinkRequest { slug: "my-product-link".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Product Id |
Body
| Field | Type | Description |
|---|---|---|
slug | string | Slug for the short link. |
static_checkout_params | object | Static Checkout URL parameters to apply to the resulting short URL. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
full_url | string | Full URL. |
short_url | string | Short URL. |
Short URL
404 Status
Product not found
409 Status
Slug is already taken
500 Status
Something went wrong :(
Delete Product
Archive a product associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client.products().id(product_id).archive().send().await?; println!("Product archived successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | `` |
Responses
200 Status
Product Delected Successfully
410 Status
Product is deleted
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Product Detail
Get detailed information about a specific product.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client.products().id(product_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Product Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
addons | object | Available Addons for subscription products |
brand_id | string | |
business_id | string | Unique identifier for the business to which the product belongs. |
created_at | string | Timestamp when the product was created. |
credit_entitlements | array<CreditEntitlementMappingResponse> | Attached credit entitlements with settings |
description | object | Description of the product, optional. |
digital_product_delivery | object | |
image | object | URL of the product image, optional. |
is_recurring | boolean | Indicates if the product is recurring (e.g., subscriptions). |
license_key_activation_message | object | Message sent upon license key activation, if applicable. |
license_key_activations_limit | object | Limit on the number of activations for the license key, if enabled. |
license_key_duration | object | |
license_key_enabled | boolean | Indicates whether the product requires a license key. |
metadata | Metadata | Additional custom data associated with the product |
name | object | Name of the product, optional. |
price | Price | Pricing information for the product. |
product_collection_id | object | The product collection ID this product belongs to, if any |
product_id | string | Unique identifier for the product. |
tax_category | TaxCategory | Tax category associated with the product. |
updated_at | string | Timestamp when the product was last updated. |
Product Details
500 Status
Something went wrong :(
Get Product Short Links
List all short checkout links created by the business.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.products().list_short_links().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<ShortLinkItem> |
Short URLs for the Business
500 Status
Something went wrong :(
Get Products
Get a list of all products associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.products().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<GetProductsListResponseItem> |
Products List
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Unarchive Product
Unarchive a previously archived product.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client.products().id(product_id).unarchive().send().await?; println!("Product unarchived successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | `` |
Responses
200 Status
Product Delected Successfully
500 Status
Something went wrong :(
Update Product
Update a product's details.
Request
use dodopayments_rust::{models::PatchProductRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client .products() .id(product_id) .update() .body(PatchProductRequest { name: Some("Updated Product".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | `` |
Body
| Field | Type | Description |
|---|---|---|
addons | object | Available Addons for subscription products |
brand_id | object | |
credit_entitlements | object | Credit entitlements to update (replaces all existing when present) Send empty array to remove all, omit field to leave unchanged |
description | object | Description of the product, optional and must be at most 1000 characters. |
digital_product_delivery | object | |
image_id | object | Product image id after its uploaded to S3 |
license_key_activation_message | object | Message sent to the customer upon license key activation. Only applicable if license_key_enabled is true. This message contains instructions for activating the license key. |
license_key_activations_limit | object | Limit for the number of activations for the license key. Only applicable if license_key_enabled is true. Represents the maximum number of times the license key can be activated. |
license_key_duration | object | |
license_key_enabled | object | Whether the product requires a license key. If true, additional fields related to license key (duration, activations limit, activation message) become applicable. |
metadata | object | |
name | object | Name of the product, optional and must be at most 100 characters. |
price | object | |
tax_category | object |
Responses
200 Status
Product Updated Successfully
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Update Product File
Update the files associated with a product.
Request
use dodopayments_rust::{models::UploadProductFile, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client .products() .id(product_id) .update_files() .body(UploadProductFile { file_name: "product_file.pdf".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Product Id |
Body
| Field | Type | Description |
|---|---|---|
file_name | string |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
file_id | string | |
url | string |
Aws s3 presigned URL. Upload image to this URL within 60s
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Update Product Image
Update images for a product.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let product_id = "prod_xxxxxxxxxx"; let resp = client .products() .id(product_id) .update_image() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
id | string | Product Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
image_id | object | |
url | string |
Aws s3 presigned URL. Upload image to this URL within 60s
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Refunds
Create Refund
Create a refund for a payment.
Request
use dodopayments_rust::{models::CreateRefundRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .refunds() .create() .body(CreateRefundRequest { payment_id: "pay_xxxxxxxxxx".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
items | object | Partially Refund an Individual Item |
metadata | Metadata | Additional metadata associated with the refund. |
payment_id | string | The unique identifier of the payment to be refunded. |
reason | object | The reason for the refund, if any. Maximum length is 3000 characters. Optional. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | object | The refunded amount. |
business_id | string | The unique identifier of the business issuing the refund. |
created_at | string | The timestamp of when the refund was created in UTC. |
currency | object | |
customer | CustomerLimitedDetailsResponse | Details about the customer for this refund (from the associated payment) |
is_partial | boolean | If true the refund is a partial refund |
metadata | Metadata | Additional metadata stored with the refund. |
payment_id | string | The unique identifier of the payment associated with the refund. |
reason | object | The reason provided for the refund, if any. Optional. |
refund_id | string | The unique identifier of the refund. |
status | RefundStatus | The current status of the refund. |
Refund successfully initiated
400 Status
Invalid Request Parameters
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Refund Detail
Get detailed information about a specific refund.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let refund_id = "ref_xxxxxxxxxx"; let resp = client.refunds().id(refund_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
refund_id | string | Refund Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
amount | object | The refunded amount. |
business_id | string | The unique identifier of the business issuing the refund. |
created_at | string | The timestamp of when the refund was created in UTC. |
currency | object | |
customer | CustomerLimitedDetailsResponse | Details about the customer for this refund (from the associated payment) |
is_partial | boolean | If true the refund is a partial refund |
metadata | Metadata | Additional metadata stored with the refund. |
payment_id | string | The unique identifier of the payment associated with the refund. |
reason | object | The reason provided for the refund, if any. Optional. |
refund_id | string | The unique identifier of the refund. |
status | RefundStatus | The current status of the refund. |
500 Status
Something went wrong :(
Get Refunds
Get a list of all refunds associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.refunds().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<RefundListItem> |
500 Status
Something went wrong :(
Subscriptions
Change Subscription Plan
Preview the effects of a subscription plan change before committing to it.
Request
use dodopayments_rust::{ models::UpdateSubscriptionPlanReq, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let subscription_id = "sub_xxxxxxxxxx"; let resp = client .subscriptions() .id(subscription_id) .change_plan() .body(UpdateSubscriptionPlanReq { product_id: "prod_xxxxxxxxxx".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
subscription_id | string | Subscription Id |
Body
| Field | Type | Description |
|---|---|---|
addons | object | Addons for the new plan. Note : Leaving this empty would remove any existing addons |
discount_code | object | Optional discount code to apply to the new plan. If provided, validates and applies the discount to the plan change. If not provided and the subscription has an existing discount with preserve_on_plan_change=true, the existing discount will be preserved (if applicable to the new product). |
effective_at | EffectiveAt | When to apply the plan change. - immediately (default): Apply the plan change right away - next_billing_date: Schedule the change for the next billing date |
metadata | object | |
on_payment_failure | object | |
product_id | string | Unique identifier of the product to subscribe to |
proration_billing_mode | ProrationBillingMode | Proration Billing Mode |
quantity | integer | Number of units to subscribe for. Must be at least 1. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
immediate_charge | ImmediateCharge | |
new_plan | SubscriptionResponse |
Preview of subscription plan change
500 Status
Something went wrong :(
Create Subscription
Create a subscription for a customer.
Request
use dodopayments_rust::{ models::CreateSubscriptionRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .subscriptions() .create() .body(CreateSubscriptionRequest { product_id: "prod_xxxxxxxxxx".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
addons | object | Attach addons to this subscription |
allowed_payment_method_types | object | List of payment methods allowed during checkout. Customers will never see payment methods that are not in this list. However, adding a method here does not guarantee customers will see it. Availability still depends on other factors (e.g., customer location, merchant settings). |
billing | BillingAddress | Billing address information for the subscription |
billing_currency | object | |
customer | CustomerRequest | Customer details for the subscription |
discount_code | object | Discount Code to apply to the subscription |
force_3ds | object | Override merchant default 3DS behaviour for this subscription |
metadata | Metadata | Additional metadata for the subscription Defaults to empty if not specified |
on_demand | object | |
one_time_product_cart | object | List of one time products that will be bundled with the first payment for this subscription |
payment_link | object | If true, generates a payment link. Defaults to false if not specified. |
payment_method_id | object | Optional payment method ID to use for this subscription. If provided, customer_id must also be provided (via AttachExistingCustomer). The payment method will be validated for eligibility with the subscription's currency. |
product_id | string | Unique identifier of the product to subscribe to |
quantity | integer | Number of units to subscribe for. Must be at least 1. |
redirect_immediately | boolean | If true, redirects the customer immediately after payment completion False by default |
return_url | object | Optional URL to redirect after successful subscription creation |
short_link | object | If true, returns a shortened payment link. Defaults to false if not specified. |
show_saved_payment_methods | boolean | Display saved payment methods of a returning customer False by default |
tax_id | object | Tax ID in case the payment is B2B. If tax id validation fails the payment creation will fail |
trial_period_days | object | Optional trial period in days If specified, this value overrides the trial period set in the product's price Must be between 0 and 10000 days |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
addons | array<AddonCartResponseItem> | Addons associated with this subscription |
client_secret | object | Client secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon |
customer | CustomerLimitedDetailsResponse | Customer details associated with this subscription |
discount_id | object | The discount id if discount is applied |
expires_on | object | Expiry timestamp of the payment link |
metadata | Metadata | Additional metadata associated with the subscription |
one_time_product_cart | object | One time products associated with the purchase of subscription |
payment_id | string | First payment id for the subscription |
payment_link | object | URL to checkout page |
recurring_pre_tax_amount | integer | Tax will be added to the amount and charged to the customer on each billing cycle |
subscription_id | string | Unique identifier for the subscription |
Subscription successfully initiated
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Create Subscription Charge
Create an on-demand charge for a subscription.
Request
use dodopayments_rust::{ models::CreateSubscriptionChargeRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let subscription_id = "sub_xxxxxxxxxx"; let resp = client .subscriptions() .id(subscription_id) .charge() .body(CreateSubscriptionChargeRequest { ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
subscription_id | string | Subscription Id |
Body
| Field | Type | Description |
|---|---|---|
adaptive_currency_fees_inclusive | object | Whether adaptive currency fees should be included in the product_price (true) or added on top (false). This field is ignored if adaptive pricing is not enabled for the business. |
customer_balance_config | object | |
metadata | object | |
product_currency | object | |
product_description | object | Optional product description override for billing and line items. If not specified, the stored description of the product will be used. |
product_price | integer | The product price. Represented in the lowest denomination of the currency (e.g., cents for USD). For example, to charge $1.00, pass 100. |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
payment_id | string |
Subscription Charge successfully created
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Get Subscription Detail
Get detailed information about a specific subscription.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let subscription_id = "sub_xxxxxxxxxx"; let resp = client .subscriptions() .id(subscription_id) .retrieve() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
subscription_id | string | Subscription Id |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
addons | array<AddonCartResponseItem> | Addons associated with this subscription |
billing | BillingAddress | Billing address details for payments |
cancel_at_next_billing_date | boolean | Indicates if the subscription will cancel at the next billing date |
cancelled_at | object | Cancelled timestamp if the subscription is cancelled |
created_at | string | Timestamp when the subscription was created |
credit_entitlement_cart | array<CreditEntitlementCartResponse> | Credit entitlement cart settings for this subscription |
currency | Currency | Currency used for the subscription payments |
custom_field_responses | object | Customer's responses to custom fields collected during checkout |
customer | CustomerLimitedDetailsResponse | Customer details associated with the subscription |
discount_cycles_remaining | object | Number of remaining discount cycles if discount is applied |
discount_id | object | The discount id if discount is applied |
expires_at | object | Timestamp when the subscription will expire |
metadata | Metadata | Additional custom data associated with the subscription |
meter_credit_entitlement_cart | array<MeterCreditEntitlementCartResponse> | Meter credit entitlement cart settings for this subscription |
meters | array<MeterCartResponseItem> | Meters associated with this subscription (for usage-based billing) |
next_billing_date | string | Timestamp of the next scheduled billing. Indicates the end of current billing period |
on_demand | boolean | Wether the subscription is on-demand or not |
payment_frequency_count | integer | Number of payment frequency intervals |
payment_frequency_interval | TimeInterval | Time interval for payment frequency (e.g. month, year) |
payment_method_id | object | Saved payment method id used for recurring charges |
previous_billing_date | string | Timestamp of the last payment. Indicates the start of current billing period |
product_id | string | Identifier of the product associated with this subscription |
quantity | integer | Number of units/items included in the subscription |
recurring_pre_tax_amount | integer | Amount charged before tax for each recurring payment in smallest currency unit (e.g. cents) |
scheduled_change | object | |
status | SubscriptionStatus | Current status of the subscription |
subscription_id | string | Unique identifier for the subscription |
subscription_period_count | integer | Number of subscription period intervals |
subscription_period_interval | TimeInterval | Time interval for the subscription period (e.g. month, year) |
tax_id | object | Tax identifier provided for this subscription (if applicable) |
tax_inclusive | boolean | Indicates if the recurring_pre_tax_amount is tax inclusive |
trial_period_days | integer | Number of days in the trial period (0 if no trial) |
500 Status
Something went wrong :(
Get Subscription Usage History
Retrieve the complete usage history for a subscription with usage-based billing.
This provides insights into customer usage patterns and billing calculations over time.
What You'll Get:
- Billing periods: Each item represents a billing cycle with start and end dates
- Meter usage: Detailed breakdown of usage for each meter configured on the subscription
- Usage calculations: Total units consumed, free threshold units, and chargeable units
- Historical tracking: Complete audit trail of usage-based charges
Use Cases:
- Customer support: Investigate billing questions and usage discrepancies
- Usage analytics: Analyze customer consumption patterns over time
- Billing transparency: Provide customers with detailed usage breakdowns
- Revenue optimization: Identify usage trends to optimize pricing strategies
Filtering Options:
- Date range filtering: Get usage history for specific time periods
- Meter-specific filtering: Focus on usage for a particular meter
- Pagination: Navigate through large usage histories efficiently
Important Notes:
- Only returns data for subscriptions with usage-based (metered) components
- Usage history is organized by billing periods (subscription cycles)
- Free threshold units are calculated and displayed separately from chargeable units
- Historical data is preserved even if meter configurations change
Example Query Patterns:
- Get last 3 months:
?start_date=2024-01-01T00:00:00Z&end_date=2024-03-31T23:59:59Z - Filter by meter:
?meter_id=mtr_api_requests - Paginate results:
?page_size=20&page_number=1 - Recent usage:
?start_date=2024-03-01T00:00:00Z(from March 1st to now)
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let subscription_id = "sub_xxxxxxxxxx"; let resp = client .subscriptions() .id(subscription_id) .usage_history() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
subscription_id | string | Unique subscription identifier |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<UsageHistoryItem> | List of usage history items |
Usage history retrieved successfully
400 Status
Invalid request - malformed parameters or validation errors
401 Status
Unauthorized - invalid or missing API key
404 Status
Subscription not found - no subscription exists with the specified ID
422 Status
Unprocessable entity - invalid query parameter values or date ranges
500 Status
Internal server error - please contact support if this persists
Get Subscriptions
Get a list of all subscriptions associated with your account.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.subscriptions().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
items | array<SubscriptionListResponseItem> |
500 Status
Something went wrong :(
Update Subscription
Update a subscription's details.
Request
use dodopayments_rust::{ models::PatchSubscriptionRequest, to_pretty_json, DodoPaymentsClientBuilder, }; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let subscription_id = "sub_xxxxxxxxxx"; let resp = client .subscriptions() .id(subscription_id) .update() .body(PatchSubscriptionRequest { ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
subscription_id | string | Subscription Id |
Body
| Field | Type | Description |
|---|---|---|
billing | object | |
cancel_at_next_billing_date | object | When set, the subscription will remain active until the end of billing period |
credit_entitlement_cart | object | Update credit entitlement cart settings |
customer_name | object | |
disable_on_demand | object | |
metadata | object | |
next_billing_date | object | |
status | object | |
tax_id | object |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
addons | array<AddonCartResponseItem> | Addons associated with this subscription |
billing | BillingAddress | Billing address details for payments |
cancel_at_next_billing_date | boolean | Indicates if the subscription will cancel at the next billing date |
cancelled_at | object | Cancelled timestamp if the subscription is cancelled |
created_at | string | Timestamp when the subscription was created |
credit_entitlement_cart | array<CreditEntitlementCartResponse> | Credit entitlement cart settings for this subscription |
currency | Currency | Currency used for the subscription payments |
custom_field_responses | object | Customer's responses to custom fields collected during checkout |
customer | CustomerLimitedDetailsResponse | Customer details associated with the subscription |
discount_cycles_remaining | object | Number of remaining discount cycles if discount is applied |
discount_id | object | The discount id if discount is applied |
expires_at | object | Timestamp when the subscription will expire |
metadata | Metadata | Additional custom data associated with the subscription |
meter_credit_entitlement_cart | array<MeterCreditEntitlementCartResponse> | Meter credit entitlement cart settings for this subscription |
meters | array<MeterCartResponseItem> | Meters associated with this subscription (for usage-based billing) |
next_billing_date | string | Timestamp of the next scheduled billing. Indicates the end of current billing period |
on_demand | boolean | Wether the subscription is on-demand or not |
payment_frequency_count | integer | Number of payment frequency intervals |
payment_frequency_interval | TimeInterval | Time interval for payment frequency (e.g. month, year) |
payment_method_id | object | Saved payment method id used for recurring charges |
previous_billing_date | string | Timestamp of the last payment. Indicates the start of current billing period |
product_id | string | Identifier of the product associated with this subscription |
quantity | integer | Number of units/items included in the subscription |
recurring_pre_tax_amount | integer | Amount charged before tax for each recurring payment in smallest currency unit (e.g. cents) |
scheduled_change | object | |
status | SubscriptionStatus | Current status of the subscription |
subscription_id | string | Unique identifier for the subscription |
subscription_period_count | integer | Number of subscription period intervals |
subscription_period_interval | TimeInterval | Time interval for the subscription period (e.g. month, year) |
tax_id | object | Tax identifier provided for this subscription (if applicable) |
tax_inclusive | boolean | Indicates if the recurring_pre_tax_amount is tax inclusive |
trial_period_days | integer | Number of days in the trial period (0 if no trial) |
Subscription successfully updated
422 Status
Invalid Request Object or Parameters
500 Status
Something went wrong :(
Webhooks
Create Webhook
Create a new webhook for a business.
Request
use dodopayments_rust::{models::CreateWebhookRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client .webhooks() .create() .body(CreateWebhookRequest { url: "https://example.com/webhook".to_string(), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Body
| Field | Type | Description |
|---|---|---|
description | object | |
disabled | object | Create the webhook in a disabled state. Default is false |
filter_types | array<EventType> | Filter events to the webhook. Webhook event will only be sent for events in the list. |
headers | object | Custom headers to be passed |
idempotency_key | object | The request's idempotency key |
metadata | object | Metadata to be passed to the webhook Defaut is {} |
rate_limit | object | |
url | string | Url of the webhook |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
created_at | string | Created at timestamp |
description | string | An example webhook name. |
disabled | object | Status of the webhook. If true, events are not sent |
filter_types | object | Filter events to the webhook. Webhook event will only be sent for events in the list. |
id | string | The webhook's ID. |
metadata | object | Metadata of the webhook |
rate_limit | object | Configured rate limit |
updated_at | string | Updated at timestamp |
url | string | Url endpoint of the webhook |
created Successfully
Delete Webhook
Delete a specific webhook.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client.webhooks().id(webhook_id).delete().send().await?; println!("Webhook deleted successfully"); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Responses
200 Status
Webhook has been deleted
404 Status
Not Found
500 Status
Something went wrong.
Get Webhook Detail
Get detailed information about a specific webhook.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client.webhooks().id(webhook_id).retrieve().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
created_at | string | Created at timestamp |
description | string | An example webhook name. |
disabled | object | Status of the webhook. If true, events are not sent |
filter_types | object | Filter events to the webhook. Webhook event will only be sent for events in the list. |
id | string | The webhook's ID. |
metadata | object | Metadata of the webhook |
rate_limit | object | Configured rate limit |
updated_at | string | Updated at timestamp |
url | string | Url endpoint of the webhook |
Webhook details retrived.
404 Status
Not Found
500 Status
Something went wrong.
Get Webhook Headers
Get the custom headers for a specific webhook.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client .webhooks() .id(webhook_id) .retrieve_webhook_headers() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
headers | object | List of headers configured |
sensitive | array<string> | Sensitive headers without the value |
Webhook headers details retrived.
404 Status
Not Found
500 Status
Something went wrong.
Get Webhook Signing Secret
Get the signing key for a specific webhook.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client .webhooks() .id(webhook_id) .signing_key() .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
secret | string |
Webhook secret retrived.
404 Status
Not Found
500 Status
Something went wrong.
Get Webhooks
List all webhooks for a business.
Request
use dodopayments_rust::{to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let resp = client.webhooks().list().send().await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Responses
200 Status
| Field | Type | Description |
|---|---|---|
data | array<WebhookDetails> | List of webhoooks |
done | boolean | true if no more values are to be fetched. |
iterator | object | Cursor pointing to the next paginated object |
prev_iterator | object | Cursor pointing to the previous paginated object |
List of s
Update Webhook
Update a specific webhook.
Request
use dodopayments_rust::{models::PatchWebhookRequest, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client .webhooks() .id(webhook_id) .update() .body(PatchWebhookRequest { url: Some("https://example.com/new-webhook".to_string()), ..Default::default() }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Body
| Field | Type | Description |
|---|---|---|
description | object | Description of the webhook |
disabled | object | To Disable the endpoint, set it to true. |
filter_types | object | Filter events to the endpoint. Webhook event will only be sent for events in the list. |
metadata | object | Metadata |
rate_limit | object | Rate limit |
url | object | Url endpoint |
Responses
200 Status
| Field | Type | Description |
|---|---|---|
created_at | string | Created at timestamp |
description | string | An example webhook name. |
disabled | object | Status of the webhook. If true, events are not sent |
filter_types | object | Filter events to the webhook. Webhook event will only be sent for events in the list. |
id | string | The webhook's ID. |
metadata | object | Metadata of the webhook |
rate_limit | object | Configured rate limit |
updated_at | string | Updated at timestamp |
url | string | Url endpoint of the webhook |
Webhook patched successfully
404 Status
Webhook Not Found
500 Status
Something went wrong.
Update Webhook Headers
Update the custom headers for a specific webhook.
Request
use dodopayments_rust::{models::WebhookHeadersReq, to_pretty_json, DodoPaymentsClientBuilder}; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let api_key = std::env::var("DODO_API_KEY")?; let client = DodoPaymentsClientBuilder::new() .bearer_token(&api_key) .enviroment("test_mode") .build()?; let webhook_id = "wh_xxxxxxxxxx"; let resp = client .webhooks() .id(webhook_id) .update_webhook_headers() .body(WebhookHeadersReq { headers: std::collections::HashMap::new(), }) .send() .await?; println!("{}", to_pretty_json(&resp)?); Ok(()) }
Path Parameters
| Parameter | Type | Description |
|---|---|---|
webhook_id | string | `` |
Body
| Field | Type | Description |
|---|---|---|
headers | object | Object of header-value pair to update or add |
Responses
200 Status
Webhook headers patched successfully
404 Status
Webhook Not Found
500 Status
Something went wrong.