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

  1. Install via CLI
#![allow(unused)]
fn main() {
cargo add dodopayments_rust
}
  1. 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

FieldTypeDescription
currencyCurrencyThe currency of the Addon
descriptionobjectOptional description of the Addon
namestringName of the Addon
priceintegerAmount of the addon
tax_categoryTaxCategoryTax category applied to this Addon

Responses

200 Status

FieldTypeDescription
business_idstringUnique identifier for the business to which the addon belongs.
created_atstringCreated time
currencyCurrencyCurrency of the Addon
descriptionobjectOptional description of the Addon
idstringid of the Addon
imageobjectImage of the Addon
namestringName of the Addon
priceintegerAmount of the addon
tax_categoryTaxCategoryTax category applied to this Addon
updated_atstringUpdated 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

ParameterTypeDescription
idstringAddon Id

Responses

200 Status

FieldTypeDescription
business_idstringUnique identifier for the business to which the addon belongs.
created_atstringCreated time
currencyCurrencyCurrency of the Addon
descriptionobjectOptional description of the Addon
idstringid of the Addon
imageobjectImage of the Addon
namestringName of the Addon
priceintegerAmount of the addon
tax_categoryTaxCategoryTax category applied to this Addon
updated_atstringUpdated 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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
idstringAddon Id

Body

FieldTypeDescription
currencyobject
descriptionobjectDescription of the Addon, optional and must be at most 1000 characters.
image_idobjectAddon image id after its uploaded to S3
nameobjectName of the Addon, optional and must be at most 100 characters.
priceobjectAmount of the addon
tax_categoryobject

Responses

200 Status

FieldTypeDescription
business_idstringUnique identifier for the business to which the addon belongs.
created_atstringCreated time
currencyCurrencyCurrency of the Addon
descriptionobjectOptional description of the Addon
idstringid of the Addon
imageobjectImage of the Addon
namestringName of the Addon
priceintegerAmount of the addon
tax_categoryTaxCategoryTax category applied to this Addon
updated_atstringUpdated 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

ParameterTypeDescription
idstringAddon Id

Responses

200 Status

FieldTypeDescription
image_idstring
urlstring

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

ParameterTypeDescription
credit_entitlement_idstringCredit Entitlement ID

Responses

200 Status

FieldTypeDescription
itemsarray<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

FieldTypeDescription
descriptionobject
nameobject
statement_descriptorobject
support_emailobject
urlobject

Responses

200 Status

FieldTypeDescription
brand_idstring
business_idstring
descriptionobject
enabledboolean
imageobject
nameobject
reason_for_holdobjectIncase the brand verification fails or is put on hold
statement_descriptorstring
support_emailobject
urlobject
verification_enabledboolean
verification_statusBrandVerificationStatus

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

ParameterTypeDescription
idstringBrand Id

Responses

200 Status

FieldTypeDescription
brand_idstring
business_idstring
descriptionobject
enabledboolean
imageobject
nameobject
reason_for_holdobjectIncase the brand verification fails or is put on hold
statement_descriptorstring
support_emailobject
urlobject
verification_enabledboolean
verification_statusBrandVerificationStatus

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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
idstringBrand Id

Body

FieldTypeDescription
descriptionobject
image_idobjectThe UUID you got back from the presigned‐upload call
nameobject
statement_descriptorobject
support_emailobject
urlobject

Responses

200 Status

FieldTypeDescription
brand_idstring
business_idstring
descriptionobject
enabledboolean
imageobject
nameobject
reason_for_holdobjectIncase the brand verification fails or is put on hold
statement_descriptorstring
support_emailobject
urlobject
verification_enabledboolean
verification_statusBrandVerificationStatus

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

ParameterTypeDescription
idstringBrand Id

Responses

200 Status

FieldTypeDescription
image_idstringUUID that will be used as the image identifier/key suffix
urlstringPresigned 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

FieldTypeDescription
currencyobject
descriptionobjectOptional description of the credit entitlement
expires_after_daysobjectNumber of days after which credits expire (optional)
max_rollover_countobjectMaximum number of times credits can be rolled over
namestringName of the credit entitlement
overage_behaviorobject
overage_enabledbooleanWhether overage charges are enabled when credits run out
overage_limitobjectMaximum overage units allowed (optional)
precisionintegerPrecision for credit amounts (0-10 decimal places)
price_per_unitobjectPrice per credit unit
rollover_enabledbooleanWhether rollover is enabled for unused credits
rollover_percentageobjectPercentage of unused credits that can rollover (0-100)
rollover_timeframe_countobjectCount of timeframe periods for rollover limit
rollover_timeframe_intervalobject
unitstringUnit of measurement for the credit (e.g., "API Calls", "Tokens", "Credits")

Responses

201 Status

Credit entitlement created successfully

FieldTypeDescription
business_idstring-
created_atstring-
currencyobject-
descriptionobject-
expires_after_daysobject-
idstring-
max_rollover_countobject-
namestring-
overage_behaviorobjectControls how overage is handled at billing cycle end.
overage_enabledboolean-
overage_limitobject-
precisioninteger-
price_per_unitobjectPrice per credit unit
rollover_enabledboolean-
rollover_percentageobject-
rollover_timeframe_countobject-
rollover_timeframe_intervalobject-
unitstring-
updated_atstring-

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

ParameterTypeDescription
idstringCredit 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

ParameterTypeDescription
idstringCredit Entitlement ID

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
currencyobject
descriptionobject
expires_after_daysobject
idstring
max_rollover_countobject
namestring
overage_behaviorCbbOverageBehaviorControls how overage is handled at billing cycle end.
overage_enabledboolean
overage_limitobject
precisioninteger
price_per_unitobjectPrice per credit unit
rollover_enabledboolean
rollover_percentageobject
rollover_timeframe_countobject
rollover_timeframe_intervalobject
unitstring
updated_atstring

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 deleted parameter 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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
credit_entitlement_idstringCredit Entitlement ID
customer_idstringCustomer ID

Responses

200 Status

FieldTypeDescription
balancestring
created_atstring
credit_entitlement_idstring
customer_idstring
idstring
last_transaction_atobject
overagestring
updated_atstring

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

ParameterTypeDescription
credit_entitlement_idstringCredit Entitlement ID
customer_idstringCustomer ID

Responses

200 Status

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
credit_entitlement_idstringCredit Entitlement ID
customer_idstringCustomer ID

Responses

200 Status

FieldTypeDescription
itemsarray<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_at timestamp 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

ParameterTypeDescription
idstringCredit 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 null explicitly will clear the database value (using double option pattern)
  • The updated_at timestamp 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

ParameterTypeDescription
idstringCredit Entitlement ID

Body

FieldTypeDescription
currencyobject
descriptionobjectOptional description of the credit entitlement
expires_after_daysobjectNumber of days after which credits expire
max_rollover_countobjectMaximum number of times credits can be rolled over
nameobjectName of the credit entitlement
overage_behaviorobject
overage_enabledobjectWhether overage charges are enabled when credits run out
overage_limitobjectMaximum overage units allowed
price_per_unitobjectPrice per credit unit
rollover_enabledobjectWhether rollover is enabled for unused credits
rollover_percentageobjectPercentage of unused credits that can rollover (0-100)
rollover_timeframe_countobjectCount of timeframe periods for rollover limit
rollover_timeframe_intervalobject
unitobjectUnit 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

FieldTypeDescription
emailstring
metadataMetadataAdditional metadata for the customer
namestring
phone_numberobject

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
customer_idstring
emailstring
metadataMetadataAdditional metadata for the customer
namestring
phone_numberobject

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

ParameterTypeDescription
customer_idstringCustomer ID

Body

FieldTypeDescription
amountinteger
currencyCurrencyCurrency of the wallet to adjust
entry_typeCustomerLedgerEntryTypeType of ledger entry - credit or debit
idempotency_keyobjectOptional idempotency key to prevent duplicate entries
reasonobject

Responses

200 Status

FieldTypeDescription
balanceinteger
created_atstring
currencyCurrency
customer_idstring
updated_atstring

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

ParameterTypeDescription
customer_idstringCustomer Id

Responses

200 Status

FieldTypeDescription
linkstring

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

ParameterTypeDescription
customer_idstringCustomer Id

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
customer_idstring
emailstring
metadataMetadataAdditional metadata for the customer
namestring
phone_numberobject

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

ParameterTypeDescription
customer_idstringCustomer ID

Responses

200 Status

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
customer_idstringCustomer ID

Responses

200 Status

FieldTypeDescription
itemsarray<CustomerWalletResponse>
total_balance_usdintegerSum 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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
customer_idstringCustomer Id

Body

FieldTypeDescription
emailobject
metadataobject
nameobject
phone_numberobject

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
customer_idstring
emailstring
metadataMetadataAdditional metadata for the customer
namestring
phone_numberobject

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

FieldTypeDescription
amountintegerThe 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.
codeobjectOptionally supply a code (will be uppercased). - Must be at least 3 characters if provided. - If omitted, a random 16-character code is generated.
expires_atobjectWhen the discount expires, if ever.
nameobject
preserve_on_plan_changebooleanWhether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
restricted_toobjectList of product IDs to restrict usage (if any).
subscription_cyclesobjectNumber 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.
typeDiscountTypeThe discount type (e.g. percentage, flat, or flat_per_unit).
usage_limitobjectHow many times this discount can be used (if any). Must be >= 1 if provided.

Responses

200 Status

FieldTypeDescription
amountintegerThe 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_idstringThe business this discount belongs to.
codestringThe discount code (up to 16 chars).
created_atstringTimestamp when the discount is created
discount_idstringThe unique discount ID
expires_atobjectOptional date/time after which discount is expired.
nameobjectName for the Discount
preserve_on_plan_changebooleanWhether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
restricted_toarray<string>List of product IDs to which this discount is restricted.
subscription_cyclesobjectNumber 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_usedintegerHow many times this discount has been used.
typeDiscountTypeThe type of discount, e.g. percentage, flat, or flat_per_unit.
usage_limitobjectUsage limit for this discount, if any.
  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

Created discount

  • If discount_type is percentage, 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

ParameterTypeDescription
discount_idstringDiscount 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

ParameterTypeDescription
codestringThe discount code (e.g., 'SAVE20')

Responses

200 Status

FieldTypeDescription
amountintegerThe 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_idstringThe business this discount belongs to.
codestringThe discount code (up to 16 chars).
created_atstringTimestamp when the discount is created
discount_idstringThe unique discount ID
expires_atobjectOptional date/time after which discount is expired.
nameobjectName for the Discount
preserve_on_plan_changebooleanWhether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
restricted_toarray<string>List of product IDs to which this discount is restricted.
subscription_cyclesobjectNumber 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_usedintegerHow many times this discount has been used.
typeDiscountTypeThe type of discount, e.g. percentage, flat, or flat_per_unit.
usage_limitobjectUsage limit for this discount, if any.
  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, 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_type is percentage, 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

ParameterTypeDescription
discount_idstringDiscount Id

Responses

200 Status

FieldTypeDescription
amountintegerThe 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_idstringThe business this discount belongs to.
codestringThe discount code (up to 16 chars).
created_atstringTimestamp when the discount is created
discount_idstringThe unique discount ID
expires_atobjectOptional date/time after which discount is expired.
nameobjectName for the Discount
preserve_on_plan_changebooleanWhether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
restricted_toarray<string>List of product IDs to which this discount is restricted.
subscription_cyclesobjectNumber 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_usedintegerHow many times this discount has been used.
typeDiscountTypeThe type of discount, e.g. percentage, flat, or flat_per_unit.
usage_limitobjectUsage limit for this discount, if any.
  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, 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_type is percentage, 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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
discount_idstringDiscount Id

Body

FieldTypeDescription
amountobjectIf 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.
codeobjectIf present, update the discount code (uppercase).
expires_atobject
nameobject
preserve_on_plan_changeobjectWhether this discount should be preserved when a subscription changes plans. If not provided, the existing value is kept.
restricted_toobjectIf present, replaces all restricted product IDs with this new set. To remove all restrictions, send empty array
subscription_cyclesobjectNumber 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.
typeobject
usage_limitobject

Responses

200 Status

FieldTypeDescription
amountintegerThe 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_idstringThe business this discount belongs to.
codestringThe discount code (up to 16 chars).
created_atstringTimestamp when the discount is created
discount_idstringThe unique discount ID
expires_atobjectOptional date/time after which discount is expired.
nameobjectName for the Discount
preserve_on_plan_changebooleanWhether this discount should be preserved when a subscription changes plans. Default: false (discount is removed on plan change)
restricted_toarray<string>List of product IDs to which this discount is restricted.
subscription_cyclesobjectNumber 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_usedintegerHow many times this discount has been used.
typeDiscountTypeThe type of discount, e.g. percentage, flat, or flat_per_unit.
usage_limitobjectUsage limit for this discount, if any.
  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

  • If discount_type is percentage, this is in basis points (e.g., 540 => 5.4%). If not provided, the discount will be applied indefinitely to

Updated discount

  • If discount_type is percentage, 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

ParameterTypeDescription
dispute_idstringDispute Id

Responses

200 Status

FieldTypeDescription
amountstringThe amount involved in the dispute, represented as a string to accommodate precision.
business_idstringThe unique identifier of the business involved in the dispute.
created_atstringThe timestamp of when the dispute was created, in UTC.
currencystringThe currency of the disputed amount, represented as an ISO 4217 currency code.
customerCustomerLimitedDetailsResponseThe customer who filed the dispute
dispute_idstringThe unique identifier of the dispute.
dispute_stageDisputeStageThe current stage of the dispute process.
dispute_statusDisputeStatusThe current status of the dispute.
is_resolved_by_rdrobjectWhether the dispute was resolved by Rapid Dispute Resolution
payment_idstringThe unique identifier of the payment associated with the dispute.
reasonobjectReason for the dispute
remarksobjectRemarks

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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
event_idstringUnique event identifier (case-sensitive, must match the ID used during ingestion)

Responses

200 Status

FieldTypeDescription
business_idstring
customer_idstring
event_idstring
event_namestring
metadataobject
timestampstring

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_name filter
  • 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

FieldTypeDescription
itemsarray<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_id values within the same request are rejected (entire request fails)
    • Subsequent requests with existing event_id values are ignored (idempotent behavior)
  • 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

FieldTypeDescription
eventsarray<EventInput>List of events to be pushed

Responses

200 Status

FieldTypeDescription
ingested_countinteger

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

FieldTypeDescription
license_keystring
namestring

Responses

201 Status

License key instance created

FieldTypeDescription
business_idstringBusiness ID
created_atstringCreation timestamp
customerobjectLimited customer details associated with the license key.
idstringLicense key instance ID
license_key_idstringAssociated license key ID
namestringInstance name
productobjectRelated 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

FieldTypeDescription
license_keystring
license_key_instance_idstring

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

ParameterTypeDescription
idstringLicense key ID

Responses

200 Status

FieldTypeDescription
activations_limitobjectThe maximum number of activations allowed for this license key.
business_idstringThe unique identifier of the business associated with the license key.
created_atstringThe timestamp indicating when the license key was created, in UTC.
customer_idstringThe unique identifier of the customer associated with the license key.
expires_atobjectThe timestamp indicating when the license key expires, in UTC.
idstringThe unique identifier of the license key.
instances_countintegerThe current number of instances activated for this license key.
keystringThe license key string.
payment_idstringThe unique identifier of the payment associated with the license key.
product_idstringThe unique identifier of the product associated with the license key.
statusLicenseKeyStatusThe current status of the license key (e.g., active, inactive, expired).
subscription_idobjectThe 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

ParameterTypeDescription
idstringLicense key instance ID

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
idstring
license_key_idstring
namestring

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

FieldTypeDescription
itemsarray<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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
idstringLicense key ID

Body

FieldTypeDescription
activations_limitobjectThe updated activation limit for the license key. Use null to remove the limit, or omit this field to leave it unchanged.
disabledobjectIndicates 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_atobjectThe 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

FieldTypeDescription
activations_limitobjectThe maximum number of activations allowed for this license key.
business_idstringThe unique identifier of the business associated with the license key.
created_atstringThe timestamp indicating when the license key was created, in UTC.
customer_idstringThe unique identifier of the customer associated with the license key.
expires_atobjectThe timestamp indicating when the license key expires, in UTC.
idstringThe unique identifier of the license key.
instances_countintegerThe current number of instances activated for this license key.
keystringThe license key string.
payment_idstringThe unique identifier of the payment associated with the license key.
product_idstringThe unique identifier of the product associated with the license key.
statusLicenseKeyStatusThe current status of the license key (e.g., active, inactive, expired).
subscription_idobjectThe 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

ParameterTypeDescription
idstringLicense key instance ID

Body

FieldTypeDescription
namestring

Responses

200 Status

FieldTypeDescription
business_idstring
created_atstring
idstring
license_key_idstring
namestring

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

FieldTypeDescription
license_keystring
license_key_instance_idobject

Responses

200 Status

FieldTypeDescription
validboolean

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

ParameterTypeDescription
idstringMeter 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

FieldTypeDescription
aggregationMeterAggregationAggregation configuration for the meter
descriptionobjectOptional description of the meter
event_namestringEvent name to track
filterobject
measurement_unitstringmeasurement unit
namestringName of the meter

Responses

201 Status

Meter created successfully

FieldTypeDescription
aggregationobject-
business_idstring-
created_atstring-
descriptionobject-
event_namestring-
filterobject-
idstring-
measurement_unitstring-
namestring-
updated_atstring-

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

ParameterTypeDescription
idstringMeter ID

Responses

200 Status

FieldTypeDescription
aggregationMeterAggregation
business_idstring
created_atstring
descriptionobject
event_namestring
filterobject
idstring
measurement_unitstring
namestring
updated_atstring

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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
idstringMeter 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

FieldTypeDescription
allowed_payment_method_typesobjectList 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).
billingBillingAddressBilling address details for the payment
billing_currencyobject
customerCustomerRequestCustomer information for the payment
discount_codeobjectDiscount Code to apply to the transaction
force_3dsobjectOverride merchant default 3DS behaviour for this payment
metadataMetadataAdditional metadata associated with the payment. Defaults to empty if not provided.
payment_linkobjectWhether to generate a payment link. Defaults to false if not specified.
payment_method_idobjectOptional 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_cartarray<OneTimeProductCartItemReq>List of products in the cart. Must contain at least 1 and at most 100 items.
redirect_immediatelybooleanIf true, redirects the customer immediately after payment completion False by default
return_urlobjectOptional URL to redirect the customer after payment. Must be a valid URL if provided.
short_linkobjectIf true, returns a shortened payment link. Defaults to false if not specified.
show_saved_payment_methodsbooleanDisplay saved payment methods of a returning customer False by default
tax_idobjectTax ID in case the payment is B2B. If tax id validation fails the payment creation will fail

Responses

200 Status

FieldTypeDescription
client_secretstringClient secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon
customerCustomerLimitedDetailsResponseLimited details about the customer making the payment
discount_idobjectThe discount id if discount is applied
expires_onobjectExpiry timestamp of the payment link
metadataMetadataAdditional metadata associated with the payment
payment_idstringUnique identifier for the payment
payment_linkobjectOptional URL to a hosted payment page
product_cartobjectOptional list of products included in the payment
total_amountintegerTotal 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

ParameterTypeDescription
payment_idstringPayment Id

Responses

200 Status

FieldTypeDescription
billingBillingAddressBilling address details for payments
brand_idstringbrand id this payment belongs to
business_idstringIdentifier of the business associated with the payment
card_holder_nameobjectCardholder name
card_issuing_countryobject
card_last_fourobjectThe last four digits of the card
card_networkobjectCard network like VISA, MASTERCARD etc.
card_typeobjectThe type of card DEBIT or CREDIT
checkout_session_idobjectIf payment is made using a checkout session, this field is set to the id of the session.
created_atstringTimestamp when the payment was created
currencyCurrencyCurrency used for the payment
custom_field_responsesobjectCustomer's responses to custom fields collected during checkout
customerCustomerLimitedDetailsResponseDetails about the customer who made the payment
digital_products_deliveredbooleanbrand id this payment belongs to
discount_idobjectThe discount id if discount is applied
disputesarray<DisputeResponse>List of disputes associated with this payment
error_codeobjectAn error code if the payment failed
error_messageobjectAn error message if the payment failed
invoice_idobjectInvoice ID for this payment. Uses India-specific invoice ID if available.
invoice_urlobjectURL to download the invoice PDF for this payment.
metadataMetadataAdditional custom data associated with the payment
payment_idstringUnique identifier for the payment
payment_linkobjectCheckout URL
payment_methodobjectPayment method used by customer (e.g. "card", "bank_transfer")
payment_method_typeobjectSpecific type of payment method (e.g. "visa", "mastercard")
product_cartobjectList of products purchased in a one-time payment
refund_statusobject
refundsarray<RefundListItem>List of refunds issued for this payment
settlement_amountintegerThe 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_currencyCurrencyThe 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_taxobjectThis 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.
statusobject
subscription_idobjectIdentifier of the subscription if payment is part of a subscription
taxobjectAmount of tax collected in smallest currency unit (e.g. cents)
total_amountintegerTotal amount charged to the customer including tax, in smallest currency unit (e.g. cents)
updated_atobjectTimestamp 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

ParameterTypeDescription
payment_idstring``

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

ParameterTypeDescription
payment_idstringPayment Id

Responses

200 Status

FieldTypeDescription
currencyCurrency
itemsarray<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

FieldTypeDescription
itemsarray<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

FieldTypeDescription
itemsarray<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

FieldTypeDescription
addonsobjectAddons available for subscription product
brand_idobjectBrand id for the product, if not provided will default to primary brand
credit_entitlementsobjectOptional credit entitlements to attach (max 3)
descriptionobjectOptional description of the product
digital_product_deliveryobject
license_key_activation_messageobjectOptional message displayed during license key activation
license_key_activations_limitobjectThe number of times the license key can be activated. Must be 0 or greater
license_key_durationobject
license_key_enabledobjectWhen true, generates and sends a license key to your customer. Defaults to false
metadataMetadataAdditional metadata for the product
namestringName of the product
pricePricePrice configuration for the product
tax_categoryTaxCategoryTax category applied to this product

Responses

200 Status

FieldTypeDescription
addonsobjectAvailable Addons for subscription products
brand_idstring
business_idstringUnique identifier for the business to which the product belongs.
created_atstringTimestamp when the product was created.
credit_entitlementsarray<CreditEntitlementMappingResponse>Attached credit entitlements with settings
descriptionobjectDescription of the product, optional.
digital_product_deliveryobject
imageobjectURL of the product image, optional.
is_recurringbooleanIndicates if the product is recurring (e.g., subscriptions).
license_key_activation_messageobjectMessage sent upon license key activation, if applicable.
license_key_activations_limitobjectLimit on the number of activations for the license key, if enabled.
license_key_durationobject
license_key_enabledbooleanIndicates whether the product requires a license key.
metadataMetadataAdditional custom data associated with the product
nameobjectName of the product, optional.
pricePricePricing information for the product.
product_collection_idobjectThe product collection ID this product belongs to, if any
product_idstringUnique identifier for the product.
tax_categoryTaxCategoryTax category associated with the product.
updated_atstringTimestamp 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

ParameterTypeDescription
idstringProduct Id

Body

FieldTypeDescription
slugstringSlug for the short link.
static_checkout_paramsobjectStatic Checkout URL parameters to apply to the resulting short URL.

Responses

200 Status

FieldTypeDescription
full_urlstringFull URL.
short_urlstringShort 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

ParameterTypeDescription
idstring``

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

ParameterTypeDescription
idstringProduct Id

Responses

200 Status

FieldTypeDescription
addonsobjectAvailable Addons for subscription products
brand_idstring
business_idstringUnique identifier for the business to which the product belongs.
created_atstringTimestamp when the product was created.
credit_entitlementsarray<CreditEntitlementMappingResponse>Attached credit entitlements with settings
descriptionobjectDescription of the product, optional.
digital_product_deliveryobject
imageobjectURL of the product image, optional.
is_recurringbooleanIndicates if the product is recurring (e.g., subscriptions).
license_key_activation_messageobjectMessage sent upon license key activation, if applicable.
license_key_activations_limitobjectLimit on the number of activations for the license key, if enabled.
license_key_durationobject
license_key_enabledbooleanIndicates whether the product requires a license key.
metadataMetadataAdditional custom data associated with the product
nameobjectName of the product, optional.
pricePricePricing information for the product.
product_collection_idobjectThe product collection ID this product belongs to, if any
product_idstringUnique identifier for the product.
tax_categoryTaxCategoryTax category associated with the product.
updated_atstringTimestamp 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

FieldTypeDescription
itemsarray<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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
idstring``

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

ParameterTypeDescription
idstring``

Body

FieldTypeDescription
addonsobjectAvailable Addons for subscription products
brand_idobject
credit_entitlementsobjectCredit entitlements to update (replaces all existing when present) Send empty array to remove all, omit field to leave unchanged
descriptionobjectDescription of the product, optional and must be at most 1000 characters.
digital_product_deliveryobject
image_idobjectProduct image id after its uploaded to S3
license_key_activation_messageobjectMessage 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_limitobjectLimit 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_durationobject
license_key_enabledobjectWhether the product requires a license key. If true, additional fields related to license key (duration, activations limit, activation message) become applicable.
metadataobject
nameobjectName of the product, optional and must be at most 100 characters.
priceobject
tax_categoryobject

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

ParameterTypeDescription
idstringProduct Id

Body

FieldTypeDescription
file_namestring

Responses

200 Status

FieldTypeDescription
file_idstring
urlstring

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

ParameterTypeDescription
idstringProduct Id

Responses

200 Status

FieldTypeDescription
image_idobject
urlstring

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

FieldTypeDescription
itemsobjectPartially Refund an Individual Item
metadataMetadataAdditional metadata associated with the refund.
payment_idstringThe unique identifier of the payment to be refunded.
reasonobjectThe reason for the refund, if any. Maximum length is 3000 characters. Optional.

Responses

200 Status

FieldTypeDescription
amountobjectThe refunded amount.
business_idstringThe unique identifier of the business issuing the refund.
created_atstringThe timestamp of when the refund was created in UTC.
currencyobject
customerCustomerLimitedDetailsResponseDetails about the customer for this refund (from the associated payment)
is_partialbooleanIf true the refund is a partial refund
metadataMetadataAdditional metadata stored with the refund.
payment_idstringThe unique identifier of the payment associated with the refund.
reasonobjectThe reason provided for the refund, if any. Optional.
refund_idstringThe unique identifier of the refund.
statusRefundStatusThe 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

ParameterTypeDescription
refund_idstringRefund Id

Responses

200 Status

FieldTypeDescription
amountobjectThe refunded amount.
business_idstringThe unique identifier of the business issuing the refund.
created_atstringThe timestamp of when the refund was created in UTC.
currencyobject
customerCustomerLimitedDetailsResponseDetails about the customer for this refund (from the associated payment)
is_partialbooleanIf true the refund is a partial refund
metadataMetadataAdditional metadata stored with the refund.
payment_idstringThe unique identifier of the payment associated with the refund.
reasonobjectThe reason provided for the refund, if any. Optional.
refund_idstringThe unique identifier of the refund.
statusRefundStatusThe 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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
subscription_idstringSubscription Id

Body

FieldTypeDescription
addonsobjectAddons for the new plan. Note : Leaving this empty would remove any existing addons
discount_codeobjectOptional 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_atEffectiveAtWhen to apply the plan change. - immediately (default): Apply the plan change right away - next_billing_date: Schedule the change for the next billing date
metadataobject
on_payment_failureobject
product_idstringUnique identifier of the product to subscribe to
proration_billing_modeProrationBillingModeProration Billing Mode
quantityintegerNumber of units to subscribe for. Must be at least 1.

Responses

200 Status

FieldTypeDescription
immediate_chargeImmediateCharge
new_planSubscriptionResponse

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

FieldTypeDescription
addonsobjectAttach addons to this subscription
allowed_payment_method_typesobjectList 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).
billingBillingAddressBilling address information for the subscription
billing_currencyobject
customerCustomerRequestCustomer details for the subscription
discount_codeobjectDiscount Code to apply to the subscription
force_3dsobjectOverride merchant default 3DS behaviour for this subscription
metadataMetadataAdditional metadata for the subscription Defaults to empty if not specified
on_demandobject
one_time_product_cartobjectList of one time products that will be bundled with the first payment for this subscription
payment_linkobjectIf true, generates a payment link. Defaults to false if not specified.
payment_method_idobjectOptional 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_idstringUnique identifier of the product to subscribe to
quantityintegerNumber of units to subscribe for. Must be at least 1.
redirect_immediatelybooleanIf true, redirects the customer immediately after payment completion False by default
return_urlobjectOptional URL to redirect after successful subscription creation
short_linkobjectIf true, returns a shortened payment link. Defaults to false if not specified.
show_saved_payment_methodsbooleanDisplay saved payment methods of a returning customer False by default
tax_idobjectTax ID in case the payment is B2B. If tax id validation fails the payment creation will fail
trial_period_daysobjectOptional 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

FieldTypeDescription
addonsarray<AddonCartResponseItem>Addons associated with this subscription
client_secretobjectClient secret used to load Dodo checkout SDK NOTE : Dodo checkout SDK will be coming soon
customerCustomerLimitedDetailsResponseCustomer details associated with this subscription
discount_idobjectThe discount id if discount is applied
expires_onobjectExpiry timestamp of the payment link
metadataMetadataAdditional metadata associated with the subscription
one_time_product_cartobjectOne time products associated with the purchase of subscription
payment_idstringFirst payment id for the subscription
payment_linkobjectURL to checkout page
recurring_pre_tax_amountintegerTax will be added to the amount and charged to the customer on each billing cycle
subscription_idstringUnique 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

ParameterTypeDescription
subscription_idstringSubscription Id

Body

FieldTypeDescription
adaptive_currency_fees_inclusiveobjectWhether 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_configobject
metadataobject
product_currencyobject
product_descriptionobjectOptional product description override for billing and line items. If not specified, the stored description of the product will be used.
product_priceintegerThe 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

FieldTypeDescription
payment_idstring

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

ParameterTypeDescription
subscription_idstringSubscription Id

Responses

200 Status

FieldTypeDescription
addonsarray<AddonCartResponseItem>Addons associated with this subscription
billingBillingAddressBilling address details for payments
cancel_at_next_billing_datebooleanIndicates if the subscription will cancel at the next billing date
cancelled_atobjectCancelled timestamp if the subscription is cancelled
created_atstringTimestamp when the subscription was created
credit_entitlement_cartarray<CreditEntitlementCartResponse>Credit entitlement cart settings for this subscription
currencyCurrencyCurrency used for the subscription payments
custom_field_responsesobjectCustomer's responses to custom fields collected during checkout
customerCustomerLimitedDetailsResponseCustomer details associated with the subscription
discount_cycles_remainingobjectNumber of remaining discount cycles if discount is applied
discount_idobjectThe discount id if discount is applied
expires_atobjectTimestamp when the subscription will expire
metadataMetadataAdditional custom data associated with the subscription
meter_credit_entitlement_cartarray<MeterCreditEntitlementCartResponse>Meter credit entitlement cart settings for this subscription
metersarray<MeterCartResponseItem>Meters associated with this subscription (for usage-based billing)
next_billing_datestringTimestamp of the next scheduled billing. Indicates the end of current billing period
on_demandbooleanWether the subscription is on-demand or not
payment_frequency_countintegerNumber of payment frequency intervals
payment_frequency_intervalTimeIntervalTime interval for payment frequency (e.g. month, year)
payment_method_idobjectSaved payment method id used for recurring charges
previous_billing_datestringTimestamp of the last payment. Indicates the start of current billing period
product_idstringIdentifier of the product associated with this subscription
quantityintegerNumber of units/items included in the subscription
recurring_pre_tax_amountintegerAmount charged before tax for each recurring payment in smallest currency unit (e.g. cents)
scheduled_changeobject
statusSubscriptionStatusCurrent status of the subscription
subscription_idstringUnique identifier for the subscription
subscription_period_countintegerNumber of subscription period intervals
subscription_period_intervalTimeIntervalTime interval for the subscription period (e.g. month, year)
tax_idobjectTax identifier provided for this subscription (if applicable)
tax_inclusivebooleanIndicates if the recurring_pre_tax_amount is tax inclusive
trial_period_daysintegerNumber 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

ParameterTypeDescription
subscription_idstringUnique subscription identifier

Responses

200 Status

FieldTypeDescription
itemsarray<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

FieldTypeDescription
itemsarray<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

ParameterTypeDescription
subscription_idstringSubscription Id

Body

FieldTypeDescription
billingobject
cancel_at_next_billing_dateobjectWhen set, the subscription will remain active until the end of billing period
credit_entitlement_cartobjectUpdate credit entitlement cart settings
customer_nameobject
disable_on_demandobject
metadataobject
next_billing_dateobject
statusobject
tax_idobject

Responses

200 Status

FieldTypeDescription
addonsarray<AddonCartResponseItem>Addons associated with this subscription
billingBillingAddressBilling address details for payments
cancel_at_next_billing_datebooleanIndicates if the subscription will cancel at the next billing date
cancelled_atobjectCancelled timestamp if the subscription is cancelled
created_atstringTimestamp when the subscription was created
credit_entitlement_cartarray<CreditEntitlementCartResponse>Credit entitlement cart settings for this subscription
currencyCurrencyCurrency used for the subscription payments
custom_field_responsesobjectCustomer's responses to custom fields collected during checkout
customerCustomerLimitedDetailsResponseCustomer details associated with the subscription
discount_cycles_remainingobjectNumber of remaining discount cycles if discount is applied
discount_idobjectThe discount id if discount is applied
expires_atobjectTimestamp when the subscription will expire
metadataMetadataAdditional custom data associated with the subscription
meter_credit_entitlement_cartarray<MeterCreditEntitlementCartResponse>Meter credit entitlement cart settings for this subscription
metersarray<MeterCartResponseItem>Meters associated with this subscription (for usage-based billing)
next_billing_datestringTimestamp of the next scheduled billing. Indicates the end of current billing period
on_demandbooleanWether the subscription is on-demand or not
payment_frequency_countintegerNumber of payment frequency intervals
payment_frequency_intervalTimeIntervalTime interval for payment frequency (e.g. month, year)
payment_method_idobjectSaved payment method id used for recurring charges
previous_billing_datestringTimestamp of the last payment. Indicates the start of current billing period
product_idstringIdentifier of the product associated with this subscription
quantityintegerNumber of units/items included in the subscription
recurring_pre_tax_amountintegerAmount charged before tax for each recurring payment in smallest currency unit (e.g. cents)
scheduled_changeobject
statusSubscriptionStatusCurrent status of the subscription
subscription_idstringUnique identifier for the subscription
subscription_period_countintegerNumber of subscription period intervals
subscription_period_intervalTimeIntervalTime interval for the subscription period (e.g. month, year)
tax_idobjectTax identifier provided for this subscription (if applicable)
tax_inclusivebooleanIndicates if the recurring_pre_tax_amount is tax inclusive
trial_period_daysintegerNumber 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

FieldTypeDescription
descriptionobject
disabledobjectCreate the webhook in a disabled state. Default is false
filter_typesarray<EventType>Filter events to the webhook. Webhook event will only be sent for events in the list.
headersobjectCustom headers to be passed
idempotency_keyobjectThe request's idempotency key
metadataobjectMetadata to be passed to the webhook Defaut is {}
rate_limitobject
urlstringUrl of the webhook

Responses

200 Status

FieldTypeDescription
created_atstringCreated at timestamp
descriptionstringAn example webhook name.
disabledobjectStatus of the webhook. If true, events are not sent
filter_typesobjectFilter events to the webhook. Webhook event will only be sent for events in the list.
idstringThe webhook's ID.
metadataobjectMetadata of the webhook
rate_limitobjectConfigured rate limit
updated_atstringUpdated at timestamp
urlstringUrl 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

ParameterTypeDescription
webhook_idstring``

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

ParameterTypeDescription
webhook_idstring``

Responses

200 Status

FieldTypeDescription
created_atstringCreated at timestamp
descriptionstringAn example webhook name.
disabledobjectStatus of the webhook. If true, events are not sent
filter_typesobjectFilter events to the webhook. Webhook event will only be sent for events in the list.
idstringThe webhook's ID.
metadataobjectMetadata of the webhook
rate_limitobjectConfigured rate limit
updated_atstringUpdated at timestamp
urlstringUrl 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

ParameterTypeDescription
webhook_idstring``

Responses

200 Status

FieldTypeDescription
headersobjectList of headers configured
sensitivearray<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

ParameterTypeDescription
webhook_idstring``

Responses

200 Status

FieldTypeDescription
secretstring

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

FieldTypeDescription
dataarray<WebhookDetails>List of webhoooks
donebooleantrue if no more values are to be fetched.
iteratorobjectCursor pointing to the next paginated object
prev_iteratorobjectCursor 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

ParameterTypeDescription
webhook_idstring``

Body

FieldTypeDescription
descriptionobjectDescription of the webhook
disabledobjectTo Disable the endpoint, set it to true.
filter_typesobjectFilter events to the endpoint. Webhook event will only be sent for events in the list.
metadataobjectMetadata
rate_limitobjectRate limit
urlobjectUrl endpoint

Responses

200 Status

FieldTypeDescription
created_atstringCreated at timestamp
descriptionstringAn example webhook name.
disabledobjectStatus of the webhook. If true, events are not sent
filter_typesobjectFilter events to the webhook. Webhook event will only be sent for events in the list.
idstringThe webhook's ID.
metadataobjectMetadata of the webhook
rate_limitobjectConfigured rate limit
updated_atstringUpdated at timestamp
urlstringUrl 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

ParameterTypeDescription
webhook_idstring``

Body

FieldTypeDescription
headersobjectObject 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.