API Documentation & SDKs
- Introduction
- Code Integration Tutorial
- SDKs - Node, Python, PHP, Go, Ruby, Java & Kotlin
- Payments Integration Guide
- Subscription Integration Guide
- Mobile Integration Guide
- On Demand Subscriptions
- Webhooks Details
- Managing Products Via API
- Overlay Checkout (Beta)
- Metadata Guide
- Configuring Allowed Payment Methods
- MCP Server
- Technical - FAQs
- Error Codes
Payments
Subscriptions
Discounts
Licenses
Customers
Products
Payouts
Miscellaneous
Subscriptions
Create Subscription
Create a subscription for a customer.
POST
/
subscriptions
import DodoPayments from 'dodopayments';
const client = new DodoPayments({
bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscriptions.create({
billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
customer: { customer_id: 'customer_id' },
product_id: 'product_id',
quantity: 0,
});
console.log(subscription.payment_id);
}
main();
{
"addons": [
{
"addon_id": "<string>",
"quantity": 123
}
],
"client_secret": "<string>",
"customer": {
"customer_id": "<string>",
"email": "<string>",
"name": "<string>"
},
"discount_id": "<string>",
"metadata": {},
"payment_id": "<string>",
"payment_link": "<string>",
"recurring_pre_tax_amount": 1,
"subscription_id": "<string>"
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
Request payload for creating a new subscription
This struct represents the data required to create a new subscription in the system. It includes details about the product, quantity, customer information, and billing details.
Response
200 - application/json
Subscription successfully initiated
The response is of type object
.
import DodoPayments from 'dodopayments';
const client = new DodoPayments({
bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
});
async function main() {
const subscription = await client.subscriptions.create({
billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
customer: { customer_id: 'customer_id' },
product_id: 'product_id',
quantity: 0,
});
console.log(subscription.payment_id);
}
main();
{
"addons": [
{
"addon_id": "<string>",
"quantity": 123
}
],
"client_secret": "<string>",
"customer": {
"customer_id": "<string>",
"email": "<string>",
"name": "<string>"
},
"discount_id": "<string>",
"metadata": {},
"payment_id": "<string>",
"payment_link": "<string>",
"recurring_pre_tax_amount": 1,
"subscription_id": "<string>"
}
Assistant
Responses are generated using AI and may contain mistakes.