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.subscription_id);
}

main();
{
  "addons": [
    {
      "addon_id": "<string>",
      "quantity": 123
    }
  ],
  "client_secret": "<string>",
  "customer": {
    "customer_id": "<string>",
    "email": "<string>",
    "name": "<string>"
  },
  "discount_id": "<string>",
  "metadata": {},
  "payment_link": "<string>",
  "recurring_pre_tax_amount": 1,
  "subscription_id": "<string>"
}

Authorizations

Authorization
string
header
required

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.