Plan API's

The Razorpay Plan API allows you to create and manage subscription plans for recurring billing scenarios. A plan defines the pricing, billing frequency, and interval for a subscription, making it a reusable template that can be linked to multiple customers.

These APIs are essential when building subscription-based products or services, as they help standardize the structure of recurring payments. You can use the Plan API to create new plans, retrieve a list of existing plans, or fetch details of a specific plan using its ID.

End Points

Method Endpoint
POST /plan/create
GET /plan/get
GET /plan/get?id=

Create a Plan

The Create Plan endpoint (POST /plan/create) is used to define a new subscription plan in Razorpay. A plan includes key billing parameters such as the amount to be charged, billing interval (weekly, monthly, yearly, etc.), and currency. This API is essential for setting up standardized billing models that can be reused across multiple subscriptions. Once created, the plan can be linked to customers to generate recurring payments automatically as per the specified interval and pricing structure.

Arguments
period string (Required)

This parameter, combined with the interval, defines the frequency of the plan. Possible values include daily, weekly, monthly, quarterly, and yearly. You can also create custom frequencies like once in 3 weeks.

Handy Tips:
For UPI: All undefined frequencies except daily, weekly, monthly, quarterly, and yearly are considered as-presented.
For Domestic Cards: All undefined frequencies except weekly, monthly, and yearly are considered as-presented during mandate registration.
For Emandates: All defined and undefined frequencies are considered as-presented during mandate registration.

interval integer (Required)

This value, along with period, defines the plan's billing cycle frequency. For example, if the billing cycle is every 2 months, pass 2 here. For daily plans, the minimum interval value should be 7.

item object (Optional)

This object contains the plan details such as name, description, and amount configuration. You can expand this section to include child parameters like name, amount, currency, and description for the plan item.

notes object (Optional)

A key-value pair object for storing additional information about the plan for future reference. You can pass up to 15 custom keys. Example: "note_key": "Monthly gym membership".

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.plan.create(data);

curl --request POST \
  --url https://www.cloudlesspayment.com/api/plan/create \
  --header 'x-api-key: Your-API-key' \
  --header 'Content-Type: application/json' \
  --data '{
    "period": "monthly",
    "interval": 2,
    "item": {
      "name": "Premium Membership",
      "description": "Access to all premium features and content",
      "amount": 49900,
      "currency": "INR"
    },
    "notes": {
      "user_type": "premium",
      "plan_source": "website_signup"
    }
  }'
Body Parameters

{
  "period": "monthly",
  "interval": 2,
  "item": {
    "name": "Premium Membership",
    "description": "Access to all premium features and content",
    "amount": 49900,
    "currency": "INR"
  },
  "notes": {
    "user_type": "premium",
    "plan_source": "website_signup"
  }
}
                                        
Response Example

{
    "data": {
        "message": "Razorpay logic executed successfully",
        "result": {
            "action": "create",
            "data": {
                "created_at": 1753157556,
                "entity": "plan",
                "id": "plan_Qvyd9QRE8HHLq8",
                "interval": 2,
                "item": {
                    "active": true,
                    "amount": 49900,
                    "created_at": 1753157556,
                    "currency": "INR",
                    "description": "Access to all premium features and content",
                    "hsn_code": null,
                    "id": "item_Qvyd9PsjQeXcv3",
                    "name": "Premium Membership",
                    "sac_code": null,
                    "tax_group_id": null,
                    "tax_id": null,
                    "tax_inclusive": false,
                    "tax_rate": null,
                    "type": "plan",
                    "unit": null,
                    "unit_amount": 49900,
                    "updated_at": 1753157556
                },
                "notes": {
                    "plan_source": "website_signup",
                    "user_type": "premium"
                },
                "period": "monthly"
            },
            "vendor": "plan"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}
                                        

Get All Plan(s)

The Get All Plans endpoint (GET /plan/get) is used to retrieve a list of all subscription plans that have been created in the system. This API helps in displaying available plans to users, managing plan configurations, or performing analytics on pricing structures. Each plan typically includes details such as plan ID, name, amount, interval, and currency. Pagination and filtering options can be applied to fetch specific sets of plans based on frequency (e.g., monthly, yearly), amount range, or other metadata.

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.plan.fetchAll();

curl --request GET \
  --url https://www.cloudlesspayment.com/api/plan/get \
  --header 'x-api-key: Your-API-key'
Response Example

                                            {
    "data": {
        "message": "Razorpay GET logic executed successfully",
        "result": {
            "action": "fetch",
            "data": {
                "count": 10,
                "entity": "collection",
                "items": [
                    {
                        "created_at": 1753157556,
                        "entity": "plan",
                        "id": "plan_Qvyd9QRE8HHLq8",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1753157556,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_Qvyd9PsjQeXcv3",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1753157556
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752649776,
                        "entity": "plan",
                        "id": "plan_QteROg5Bm4upKn",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752649776,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QteROfcLXcxNrS",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752649776
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752649630,
                        "entity": "plan",
                        "id": "plan_QteOopYOI2ziLo",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752649630,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QteOooouZJn8mT",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752649630
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752649004,
                        "entity": "plan",
                        "id": "plan_QteDnqESldVjHt",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752649004,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QteDnpLktKysz1",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752649004
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752648795,
                        "entity": "plan",
                        "id": "plan_QteA7QTpQcVAJU",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752648795,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QteA7PpGBBd1cc",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752648795
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752641349,
                        "entity": "plan",
                        "id": "plan_Qtc31VtH9vUm72",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752641349,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_Qtc31VLFxPsxIR",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752641349
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1752582576,
                        "entity": "plan",
                        "id": "plan_QtLMIkE1j5YSmh",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1752582576,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QtLMIjhwHefLxz",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1752582576
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1751258166,
                        "entity": "plan",
                        "id": "plan_QnHHJy2SIgpmGg",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1751258166,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QnHHJxAMsEo6VS",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1751258166
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1751020651,
                        "entity": "plan",
                        "id": "plan_QmBpjekI6xeots",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1751020651,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QmBpjdrI0I7lTd",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1751020651
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    },
                    {
                        "created_at": 1751020605,
                        "entity": "plan",
                        "id": "plan_QmBovHzPXkA61I",
                        "interval": 2,
                        "item": {
                            "active": true,
                            "amount": 49900,
                            "created_at": 1751020605,
                            "currency": "INR",
                            "description": "Access to all premium features and content",
                            "hsn_code": null,
                            "id": "item_QmBovH5mfkEOOt",
                            "name": "Premium Membership",
                            "sac_code": null,
                            "tax_group_id": null,
                            "tax_id": null,
                            "tax_inclusive": false,
                            "tax_rate": null,
                            "type": "plan",
                            "unit": null,
                            "unit_amount": 49900,
                            "updated_at": 1751020605
                        },
                        "notes": {
                            "plan_source": "website_signup",
                            "user_type": "premium"
                        },
                        "period": "monthly"
                    }
                ]
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}
                                        

Get Specific Plan

The Get Plan by ID endpoint (GET /plan/get/<id>) is used to retrieve detailed information about a specific subscription plan using its unique identifier. This is helpful when you need to display plan details to a user, validate a selected plan before subscription, or fetch configuration details such as billing amount, interval, frequency, and associated metadata. It ensures accurate access to the most current plan data for business logic or frontend rendering.

Arguments
id string (Required)

Unique identifier of the plan to retrieve. Must match an existing plan created earlier.

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.plan.fetchById(planId);

curl --request GET \
  --url https://www.cloudlesspayment.com/api/plan/get?id=planId \
  --header 'x-api-key: Your-API-key'
Response Example

{
    "data": {
        "message": "Razorpay GET logic executed successfully",
        "result": {
            "action": "fetch",
            "data": {
                "created_at": 1741085787,
                "entity": "plan",
                "id": "plan_Q2gisxugbN079e",
                "interval": 1,
                "item": {
                    "active": true,
                    "amount": 30000,
                    "created_at": 1741085787,
                    "currency": "INR",
                    "description": null,
                    "hsn_code": null,
                    "id": "item_Q2gisxLAG71p0E",
                    "name": "Free",
                    "sac_code": null,
                    "tax_group_id": null,
                    "tax_id": null,
                    "tax_inclusive": false,
                    "tax_rate": null,
                    "type": "plan",
                    "unit": null,
                    "unit_amount": 30000,
                    "updated_at": 1741085787
                },
                "notes": [],
                "period": "monthly"
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}