Skip to main content
Sync your Dodo Payments data to your own database for analytics, reporting, and integrations. The sync engine automatically replicates payments, customers, subscriptions, and licenses to MongoDB, PostgreSQL, MySQL, or ClickHouse.
Package: dodo-sync on npm | Source: GitHub

What Can You Sync?

Choose any combination of these entities:

Payments

All payment transactions, including one-time payments, refunds, and status updates.

Customers

Customer profiles, contact information, and metadata.

Subscriptions

Subscription data, billing cycles, and status changes.

Licenses

License keys, activations, and status updates.
Specify which entities to sync using the scopes parameter. Each run fetches every record in the selected scopes and writes it by ID, so existing rows are updated in place instead of duplicated. In MongoDB, license keys are stored by subscription ID, so a subscription with several license keys keeps only one of them.

Database Support

Dodo Sync supports MongoDB, PostgreSQL, MySQL, and ClickHouse. Support for Snowflake and other databases, ETL pipelines, and realtime sync is in development. To contribute a new database integration, submit a pull request to the GitHub repository.

Getting Started

Use Dodo Sync via the CLI for quick setup or programmatically in your code for integration into your application. Both methods provide the same functionality.

Using the CLI

Install the CLI globally to run it from anywhere:

Running the CLI

The CLI supports two modes: interactive for guided setup, and manual for direct configuration. Interactive mode: Run without arguments to start the setup wizard.
Manual mode: Pass arguments directly to skip the wizard.
Examples:

CLI Arguments

number
required
Sync interval in seconds. The CLI runs continuously at this interval. For a one-time sync, use .run() in your code.
string
required
Database type: "mongodb", "postgres", "mysql", or "clickhouse".
string
required
Connection URI for your database:
  • MongoDB: mongodb://localhost:27017 or mongodb+srv://user:pass@cluster.mongodb.net/
  • PostgreSQL: postgresql://user:password@localhost:5432/mydb
  • MySQL: mysql://user:password@localhost:3306/mydb
  • ClickHouse: http://localhost:8123
string
required
Comma-separated list of entities to sync: licences, payments, customers, subscriptions. Example: "payments,customers".
string
required
Your Dodo Payments API key from Developer → API Keys. Use a key from the same mode as --env.
string
required
Environment: "live_mode" or "test_mode".
number
Rate limit in requests per second. Controls how fast the sync engine makes API requests. Defaults to 10; values of 100 or more turn off throttling.

Using in Your Code

Integrate the sync feature directly into your application. Install it as a dependency:

Automatic Sync (Interval-based)

Run the sync continuously at regular intervals:
The interval option is required when using .start(). The sync runs continuously at the specified interval until the process stops.

Manual Sync

Trigger sync operations on-demand, such as from a cron job or API endpoint:
The interval option is not required for manual sync. Call .run() whenever you need to sync.

PostgreSQL Example

MySQL Example

ClickHouse Example

Constructor Options

string
required
Database type: "mongodb", "postgres", "mysql", or "clickhouse".
string
required
Connection string for your database:
  • MongoDB: mongodb://localhost:27017 or mongodb+srv://...
  • PostgreSQL: postgresql://user:password@localhost:5432/mydb
  • MySQL: mysql://user:password@localhost:3306/mydb
  • ClickHouse: http://localhost:8123
string[]
required
Array of entities to sync: "licences", "payments", "customers", "subscriptions". Include any combination.
object
required
Dodo Payments API configuration. See the TypeScript SDK types for complete options.Required properties:
  • bearerToken: Your Dodo Payments API key
  • environment: "test_mode" or "live_mode"
number
Time in seconds between automatic syncs. Required for .start(), optional for .run().
number
Rate limit in requests per second. Defaults to 10; values of 100 or more turn off throttling.

Important Information

MongoDB: A database named dodopayments_sync is automatically created on your server. This database name is fixed and cannot be changed.PostgreSQL: Tables (Subscriptions, Payments, Licenses, Customers) are created in the database specified in your connection URI. Data is stored as JSONB.MySQL: Tables (Subscriptions, Payments, Licenses, Customers) are created in the database specified in your connection URI. Data is stored as JSON.ClickHouse: Tables (Subscriptions, Payments, Licenses, Customers) are created using the ReplacingMergeTree engine. When querying, use the FINAL keyword to ensure deduplicated results.

Additional Resources

GitHub Repository

View source code, report issues, or contribute improvements

npm Package

View package details and installation instructions
Last modified on September 25, 2026