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.
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. Each page of records is written to your database in a single batch.
Database Support
Dodo Sync supports MongoDB, PostgreSQL, MySQL 8.0.20 or later, 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.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:27017ormongodb+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:Manual Sync
Trigger sync operations on-demand, such as from a cron job, an API endpoint, or a serverless function:Running on Serverless
On Vercel, AWS Lambda, or similar platforms:- Call
.disconnect()in afinallyblock, as in the example above, so connections don’t stay open between invocations. - Use the Node.js runtime. Edge runtimes can’t open database connections.
- Raise the function timeout. A large sync can take longer than the default limit. On Vercel, set
export const maxDuration = 60;. - Sync fewer scopes per invocation, such as
scopes: ['payments'], to keep each run short.
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:27017ormongodb+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 keyenvironment:"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
Upgrading from 0.x
Version 1.0 changes how MongoDB data is stored and raises the MySQL requirement. Before upgrading:- MongoDB: Drop your existing
licencescollection. License documents are now stored by licenseidinstead ofsubscription_id, and the next sync repopulates the collection. - MongoDB: Check your connection URI. Data is now written to the database the URI names, not always
dodopayments_sync. To keep using your existing data, putdodopayments_syncin the URI or leave the database out. - MySQL: Upgrade to MySQL 8.0.20 or later.
Additional Resources
GitHub Repository
View source code, report issues, or contribute improvements
npm Package
View package details and installation instructions