Skip to main content
The TypeScript SDK provides convenient server-side access to the Dodo Payments REST API for TypeScript and JavaScript applications. It features comprehensive type definitions, error handling, retries, timeouts, and auto-pagination for seamless payment processing.

Installation

Install the SDK using your package manager of choice:

Quick Start

Initialize the client with your API key and start processing payments:
Always store your API keys securely using environment variables. Never commit them to version control or expose them in client-side code.

Core Features

TypeScript First

Full TypeScript support with comprehensive type definitions for all API endpoints

Auto-Pagination

Automatic pagination for list responses makes working with large datasets effortless

Error Handling

Built-in error types with detailed messages for different failure scenarios

Smart Retries

Configurable automatic retries with exponential backoff for transient errors

Configuration

Environment Variables

Set environment variables for secure configuration:
.env

Timeout Configuration

Configure request timeouts globally or per-request:

Retry Configuration

Configure automatic retry behavior:
The SDK automatically retries requests that fail due to network errors or server issues (5xx responses) with exponential backoff.

Common Operations

Create a Checkout Session

Generate a checkout session for collecting payment information:

Manage Customers

Create and retrieve customer information:

Handle Subscriptions

Create and manage recurring subscriptions:
billing requires at minimum the two-letter ISO country code. customer is a union of { customer_id } (to attach an existing customer) or { email, name? } (to create a new one). product_price is expressed in the lowest currency denomination.

Usage-Based Billing

Ingest Usage Events

Track custom events for usage-based billing:
Events must have unique event_id values for idempotency. Duplicate IDs within the same request are rejected, and subsequent requests with existing IDs are ignored.

Retrieve Usage Events

Fetch detailed information about usage events:

Proxy Configuration

Configure proxy settings for different runtimes:

Node.js (using undici)

Bun

Deno

Logging

Control log verbosity using environment variables or client options:
Available log levels:
  • 'debug' - Show debug messages, info, warnings, and errors
  • 'info' - Show info messages, warnings, and errors
  • 'warn' - Show warnings and errors (default)
  • 'error' - Show only errors
  • 'off' - Disable all logging
At the debug level, all HTTP requests and responses are logged, including headers and bodies. Some authentication headers are redacted, but sensitive data in bodies may still be visible.

Migration from Node.js SDK

If you’re upgrading from the legacy Node.js SDK, the TypeScript SDK offers improved type safety and features:

View Migration Guide

Learn how to migrate from the Node.js SDK to the TypeScript SDK

Auto-Pagination

List methods in the DodoPayments API are paginated. You can use the for await … of syntax to iterate through items across all pages:
Alternatively, you can request a single page at a time:

Requirements

The following runtimes are supported:
  • Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more)
  • Node.js 20 LTS or later (non-EOL) versions
  • Deno v1.28.0 or higher
  • Bun 1.0 or later
  • Cloudflare Workers
  • Vercel Edge Runtime
  • Jest 28 or greater with the "node" environment
  • Nitro v2.6 or greater
TypeScript >= 4.9 is supported.

Resources

GitHub Repository

View source code and contribute

API Reference

Complete API documentation

Discord Community

Get help and connect with developers

Report Issues

Report bugs or request features

Support

Need help with the TypeScript SDK?

Contributing

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