> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-881012b3.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a Plan

> Create a plan with basic details such as amount and currency

<div style={{display:"flex",flexWrap:"wrap",alignItems:"center",gap:"0.35rem 0.9rem",border:"1px solid rgba(128,128,128,0.28)",borderRadius:"0.5rem",padding:"0.45rem 0.75rem",margin:"0 0 1.25rem",fontSize:"0.875rem"}}>
  <span style={{fontWeight:600}}>Available in</span>
  <span>🇮🇳 India</span>
  <span>🇸🇬 Singapore</span>
  <span>🇺🇸 United States</span>
</div>

Use this endpoint to create a plan.

<RequestExample>
  ```bash Curl theme={null}
  curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
  -X POST https://api.razorpay.com/v1/plans \
  -H "Content-Type: application/json" \
  -d '{
    "period": "weekly",
    "interval": 1,
    "item": {
      "name": "Test plan - Weekly",
      "amount": 69900,
      "currency": "SGD",
      "description": "Description for the test plan"
    },
    "notes": {
      "notes_key_1": "Tea, Earl Grey, Hot",
      "notes_key_2": "Tea, Earl Grey… decaf."
    }
  }'
  ```

  ```java Java theme={null}
  RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  JSONObject planRequest = new JSONObject();
  planRequest.put("period","weekly");
  planRequest.put("interval",1);
  JSONObject item = new JSONObject();
  item.put("name","Test plan - Weekly");
  item.put("amount",69900);
  item.put("currency","SGD");
  item.put("description","Description for the test plan");
  planRequest.put("item",item);
  JSONObject notes = new JSONObject();
  notes.put("notes_key_1","Tea, Earl Grey, Hot");
  notes.put("notes_key_2","Tea, Earl Grey… decaf.");
  planRequest.put("notes",notes);

  Plan plan = razorpay.plans.create(planRequest);
  ```

  ```php PHP theme={null}
  $api = new Api($key_id, $secret);

  $api->plan->create(array('period' => 'weekly', 'interval' => 1, 'item' => array('name' => 'Test Weekly 1 plan', 'description' => 'Description for the weekly 1 plan', 'amount' => 600, 'currency' => 'SGD'),'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
  ```

  ```javascript Node.js theme={null}
  var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })

  instance.plans.create({
    period: "weekly",
    interval: 1,
    item: {
      name: "Test plan - Weekly",
      amount: 69900,
      currency: "SGD",
      description: "Description for the test plan"
    },
    notes: {
      notes_key_1: "Tea, Earl Grey, Hot",
      notes_key_2: "Tea, Earl Grey… decaf."
    }
  })
  ```

  ```python Python theme={null}
  client = razorpay.Client(auth=("YOUR_ID", "YOUR_SECRET"))

  client.plan.create({
      'period': 'weekly',
      'interval': 1,
      'item': {
          'name': 'Test plan - Weekly',
          'amount': 69900,
          'currency': 'SGD',
          'description': 'Description for the test plan',
          },
      'notes': {'notes_key_1': 'Tea, Earl Grey, Hot',
                'notes_key_2': 'Tea, Earl Grey... decaf.'}
      })
  ```

  ```ruby Ruby theme={null}
  require "razorpay"
  Razorpay.setup('YOUR_KEY_ID', 'YOUR_SECRET')

  para_attr = {
    "period": "weekly",
    "interval": 1,
    "item": {
      "name": "Test plan - Weekly",
      "amount": 69900,
      "currency": "SGD",
      "description": "Description for the test plan"
    },
    "notes": {
      "notes_key_1": "Tea, Earl Grey, Hot",
      "notes_key_2": "Tea, Earl Grey… decaf."
    }
  }

  Razorpay::Plan.create(para_attr)
  ```

  ```go Go theme={null}
  import ( razorpay "github.com/razorpay/razorpay-go" )
  client := razorpay.NewClient("YOUR_KEY_ID", "YOUR_SECRET")

  data:= map[string]interface{}{
    "period": "weekly",
    "interval": 1,
    "item": map[string]interface{}{
      "name": "Test plan - Weekly",
      "amount": 69900,
      "currency": "SGD",
      "description": "Description for the test plan",
    },
    "notes": map[string]interface{}{
      "notes_key_1": "Tea, Earl Grey, Hot",
      "notes_key_2": "Tea, Earl Grey… decaf.",
    },
  }
  body, err := client.Plan.Create(data, nil)
  ```

  ```csharp .NET theme={null}
  RazorpayClient client = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  Dictionary<string, object> planRequest = new Dictionary<string, object>();
  planRequest.Add("period", "weekly");
  planRequest.Add("interval", 1);
  Dictionary<string, object> item = new Dictionary<string, object>();
  item.Add("name", "Test plan - Weekly");
  item.Add("amount", 69900);
  item.Add("currency", "SGD");
  item.Add("description", "Description for the test plan");
  planRequest.Add("item", item);
  Dictionary<string, object> notes = new Dictionary<string, object>();
  notes.Add("notes_key_1", "Tea, Earl Grey, Hot");
  notes.Add("notes_key_2", "Tea, Earl Grey… decaf.");
  planRequest.Add("notes", notes);

  Plan plan = client.Plan.Create(planRequest);
  ```

  ```bash CLI theme={null}
  razorpay subscriptions plans create \
    --period monthly \
    --interval 1 \
    --item-name "Monthly Plan" \
    --item-amount 50000 \
    --item-currency INR \
    --item-description "Basic monthly subscription" \
    --note key1="Monthly gym membership"
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "id":"plan_00000000000001",
    "entity":"plan",
    "interval":1,
    "period":"weekly",
    "item":{
      "id":"item_00000000000001",
      "active":true,
      "name":"Test plan - Weekly",
      "description":"Description for the test plan - Weekly",
      "amount":69900,
      "unit_amount":69900,
      "currency":"SGD",
      "type":"plan",
      "unit":null,
      "tax_inclusive":false,
      "hsn_code":null,
      "sac_code":null,
      "tax_rate":null,
      "tax_id":null,
      "tax_group_id":null,
      "created_at":1580219935,
      "updated_at":1580219935
    },
    "notes":{
      "notes_key_1":"Tea, Earl Grey, Hot",
      "notes_key_2":"Tea, Earl Grey… decaf."
    },
    "created_at":1580219935
  }
  ```

  ```json Failure theme={null}
  {
    "error": {
      "code": "BAD_REQUEST_ERROR",
      "description": "offer_id is/are not required and should not be sent"
    }
  }
  ```
</ResponseExample>

## Request Parameters

<ParamField body="period" type="string" required>
  This, combined with `interval`, defines the frequency of the plan. Possible values:

  * `daily`
  * `weekly`
  * `monthly`
  * `quarterly`
  * `yearly`
</ParamField>

<Info>
  **Handy Tips**

  You can create custom frequencies while creating a plan. For example, once in 3 weeks.

  * 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` while registering the mandate with banks.
  * For Emandate, all defined and undefined frequencies are considered `as-presented` while registering the mandate with banks.
</Info>

<ParamField body="interval" type="integer" required>
  This, combined with `period`, defines the frequency of the plan. If the billing cycle is 2 months, the value should be `2`. For daily plans, the minimum value should be `7`.
</ParamField>

<ParamField body="item" type="object">
  Details of the plan.
</ParamField>

<ParamField body="name" type="string" required>
  Name of the plan. For example, `Test Plan`.
</ParamField>

<ParamField body="amount" type="integer" required>
  Amount for the plan that is to be charged to the subscription in the next billing cycle. For example, `69900` translates to ₹699.
</ParamField>

<ParamField body="currency" type="string" required>
  Currency for the payment. For example, `INR`. You can accept payment in any of the [supported currencies](/docs/sg/payments/international-payments#supported-currencies).
</ParamField>

<ParamField body="description" type="string">
  Description for the plan. For example, `Description for the test plan`.
</ParamField>

<ParamField body="notes" type="object">
  Notes you can enter of the contact for future reference. This is a key-value pair. You can enter a maximum of 15 key-value pairs. For example, `"note_key": "Monthly gym membership"`.
</ParamField>

## Response Parameters

<ResponseField name="id" type="string">
  The unique identifier linked to a plan. For example, `plan_00000000000001`. This ID is used when creating a subscription for a customer.
</ResponseField>

<ResponseField name="entity" type="string">
  The entity being created. Here, it is `plan`.
</ResponseField>

<ResponseField name="interval" type="integer">
  Used together with `period` to define how often the customer should be charged.
</ResponseField>

<ResponseField name="period" type="string">
  Used together with `interval` to define how often the customer should be charged. Possible values:

  * `daily`
  * `weekly`
  * `monthly`
  * `yearly`
</ResponseField>

<ResponseField name="item" type="array">
  Details of the plan.
</ResponseField>

<ResponseField name="id" type="string">
  The unique identifier linked to an item. For example, `item_00000000000001`.
</ResponseField>

<ResponseField name="name" type="string">
  Name of the plan. For example, `Test Plan`.
</ResponseField>

<ResponseField name="amount" type="integer">
  Amount for the plan. When you use this plan to create a subscription, the customer will be charged this amount periodically.
</ResponseField>

<ResponseField name="currency" type="string">
  Currency for the payment. You can accept payment in any of the  [supported currencies](/docs/sg/payments/international-payments#supported-currencies).
</ResponseField>

<ResponseField name="description" type="string">
  Description for the plan. For example, `Description for the test plan`.
</ResponseField>

<ResponseField name="notes" type="object">
  Notes you can enter of the contact for future reference. This is a key-value pair. You can enter a maximum of 15 key-value pairs. For example, `"note_key": "Monthly Gym"`.
</ResponseField>

<ResponseField name="created_at" type="integer">
  The Unix timestamp at which the plan was created.
</ResponseField>

## Errors

<AccordionGroup>
  <Accordion title="Authentication failed">
    **Code:** `401`

    This error occurs when you use incorrect or invalid API Keys.

    **Solution:** Use the right set of API keys.
  </Accordion>

  <Accordion title="`offer_id` is/are not required and should not be sent">
    **Code:** `400`

    This error occurs when you are passing `offer_id` parameter in the request body.

    **Solution:** `offer_id` should not be passed in the request body.
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="The amount must be at least INR 1.00.">
    **Code:** `400`

    The amount specified is less than the minimum amount. Currency subunits, such as paise (in the case of INR), should always be greater than 100.

    **Solution:** Enter an amount equal to or greater than the minimum amount, that is 100.
  </Accordion>
</AccordionGroup>

<AccordionGroup>
  <Accordion title="The period field is required.">
    **Code:** `400`

    The `period` field was not included in the request body.

    **Solution:** Pass `period` as one of the supported values (for example `daily`, `weekly`, `monthly`, `yearly`).
  </Accordion>

  <Accordion title="Invalid argument for period passed.">
    **Code:** `400`

    The value passed for `period` is not one of the supported values.

    **Solution:** Use one of the supported `period` values: `daily`, `weekly`, `monthly`, `yearly`.
  </Accordion>

  <Accordion title="The interval field is required.">
    **Code:** `400`

    The `interval` field was not included in the request body.

    **Solution:** Pass `interval` as a positive integer specifying how many `period` units between each billing cycle.
  </Accordion>

  <Accordion title="The interval must be at least 1.">
    **Code:** `400`

    The `interval` value is `0` or negative.

    **Solution:** Pass `interval` as an integer greater than or equal to 1.
  </Accordion>

  <Accordion title="The interval must be an integer.">
    **Code:** `400`

    A non-integer value was passed for `interval`.

    **Solution:** Pass `interval` as an integer.
  </Accordion>

  <Accordion title="The item id field is required when item is not present.">
    **Code:** `400`

    Neither the `item` object nor an `item_id` was included in the request body.

    **Solution:** Pass either an inline `item` object (with `name`, `amount`, `currency`) or an existing `item_id`.
  </Accordion>

  <Accordion title="The name field is required.">
    **Code:** `400`

    The `item.name` field was not included in the inline `item` object.

    **Solution:** Always include `item.name` when passing an inline item.
  </Accordion>

  <Accordion title="The amount field is required when unit amount is not present.">
    **Code:** `400`

    Neither `item.amount` nor `item.unit_amount` was included in the request body.

    **Solution:** Pass `item.amount` (in currency subunits) or `item.unit_amount`.
  </Accordion>

  <Accordion title="The amount must be valid integer between 0 and 4294967295.">
    **Code:** `400`

    A negative or out-of-range value was passed for `item.amount`.

    **Solution:** Pass `item.amount` as a non-negative integer below `4294967295`.
  </Accordion>

  <Accordion title="Currency provided is not supported.">
    **Code:** `400`

    The `item.currency` value is not one of the supported ISO currency codes.

    **Solution:** Use a supported 3-letter ISO currency code (for example, `INR`).
  </Accordion>

  <Accordion title="{any extra field} is/are not required and should not be sent.">
    **Code:** `400`

    The request body contains fields that are not part of the Plans API schema.

    **Solution:** Only include documented fields in the request body.
  </Accordion>
</AccordionGroup>
