# POST /plan/create — Create Plan

> Product: **Pabbly Subscription Billing** (v1)
> Base URL: `https://payments.pabbly.com/api/v1`
> Auth: Basic via `Authorization` header
> Canonical: `/subscription-billing/plans/create-plan`

This is a POST request API used to create the selling plan for a product. In response you will get the plan Id, Created date and other important details.

**Body parameters:**

| Name | Type | Required | Description |
|------|------|----------|-------------|
| product_id | string | Yes | Unique product Id in which you are creating this plan. |
| plan_name | string | Yes | Name of the plan. |
| plan_code | string | Yes | Plan Code can be same as plan name. This will be displayed at the end of the checkout page link. |
| billing_cycle | string | No |  |
| setup_fee | integer | No | One time payment deducted at the time of purchase only. |
| billing_cycle_num | string | Yes | Used only when the billing_cycle is ‘Specific’ |
| price | integer | Yes | Add the plan amount. This is required or flat_fee/per_unit/ donation/variable |
| billing_period | string | Yes | It can be Monthy Billing - 'm' Yearly Billing - 'y' Weekly Billing - 'w' |
| billing_period_num | string | Yes | It can be the number of month/weeks for the billing frequency. |
| plan_active | string | Yes | It is active by default. You can deactivate it also. |
| plan_description | string | No | Description of the plan. |
| trial_period | integer | No | Assign trial days to your customers. |
| redirect_url | string | No | Customer will be redirected to this link after successful payment. |
| currency_code | string | Yes | In what currency do you want to sell |
| meta_data | object | No | Pass additional information in plan and track it in subscription details of a customer. |
|   ↳ value1 | string | No |  |
|   ↳ value2 | string | No |  |
|   ↳ value3 | string | No |  |
| billing_cycle lifetime-Is used for Recurring plan until cancel specific-Is used for Specified number of billing cycle | string | Yes | It can be `specific/lifetime/onetime' |
| setup_fee_type flat_fee - 'If you want to add the FIXED setup fee' per_unit - 'If you want to add the Quantity-wise Setup fee' | string | Yes | If setup fee amount is set flat_fee/per_unit |
| plan_type | string | Yes | flat_fee/per_unit/volume /tiered/stairstep/donation/variable |
| tiers starting_unit - Used to add the starting unit of this plan ending_unit- Used to add the end unit of this plan price - Add the amount of this unit range | string | Yes | If plan type is tiered/volume/stairtstep |
| trial_amount | string | No | Enter the amount for for paid trial. |
| trial_type | string | Yes | If trial period is set day/month |
| variable_increase_price | string | Yes | If plan type is variable. |
| variable_max_price_amount | string | Yes | If plan type is variable. |
| variable_type | string | Yes | If plan type is variable sale/hour. |
| variable_start_time | string | Yes | If variable_type is hour. |
| payment_gateway | string | No | Use selected/all for All or Selected Gateways |
| gateways_array | string | No | Add the gateways in arrays, If If the payment gateway is Selected type. |
| failed_payment_gateway | string | No | Use selected/all for All or Selected Gateways |
| failed_payment_gateway_array | string | No | Add the gateways in arrays, If If the payment gateway is Selected type. |
| payment_term | string | No | net0/net15/net30/net45/net60/month/nextmonth. |
| specific_keep_live | string | No | live/expire |
| min_quantity | string | No | Minimum quantity to make the purchase. |
| max_quantity | string | No | The maximum quantity allowed in one purchase. The customer can't exceed the maximum quantity limit. |

**Example request body:**

```json
{
    "product_id": "5ea2d55617f6bf3123f0f95f",
    "plan_name": "plan1",
    "plan_code": "plan1",
    "billing_cycle": "lifetime",
    "setup_fee": 2,
    "billing_cycle_num": "2",
    "price": 10,
    "billing_period": "m",
    "billing_period_num": "1",
    "plan_active": "true",
    "plan_description": "",
    "trial_period": 2,
    "redirect_url": "https://www.pabbly.com/",
    "currency_code": "USD",
    "meta_data": 
    {
    "value1":"{value_details}", 
    "value2":"{value_details}", 
    "value3":"{value_details}"
}
}
```

**Response (200)** — Create Plan:

```json
{
    "status": "success",
    "message": "Plan Created",
    "data": {
        "plan_type": "per_unit",
        "plan_active": "true",
        "redirect_url": "https://www.pabbly.com/",
        "currency_code": "INR",
        "currency_symbol": "₹",
        "payment_gateway": "selected",
        "gateways_array": [
            "615c365d2688ae545d670709"
        ],
        "tiers": [
            {
                "starting_unit": "1",
                "ending_unit": "10",
                "price": "100"
            },
            {
                "starting_unit": "11",
                "price": "500"
            }
        ],
        "setup_fee_type": "per_unit",
        "trial_type": "day",
        "trial_amount": 10,
        "createdAt": "2021-10-06T10:46:40.960Z",
        "updatedAt": "2021-10-06T10:46:40.960Z",
        "id": "615d7e9086d80a30fcf9b6fb",
        "product_id": "615c5494aa7246671999768d",
        "plan_name": "Per Unit Plan",
        "plan_code": "perunitplan",
        "price": 10,
        "billing_period": "m",
        "billing_period_num": "1",
        "billing_cycle": "lifetime",
        "billing_cycle_num": "2",
        "trial_period": 2,
        "setup_fee": 2,
        "plan_description": "",
        "checkout_page": "http://localhost:1337/subscribe/615d7e9086d80a30fcf9b6fb/perunitplan"
    }
}
```

**Code examples:**

_cURL_

```curl
curl -X POST https://payments.pabbly.com/api/v1/plan/create \
  -u {{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}} \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": "5ea2d55617f6bf3123f0f95f",
    "plan_name": "plan1",
    "plan_code": "plan1",
    "billing_cycle": "lifetime",
    "setup_fee": 2,
    "billing_cycle_num": "2",
    "price": 10,
    "billing_period": "m",
    "billing_period_num": "1",
    "plan_active": "true",
    "plan_description": "",
    "trial_period": 2,
    "redirect_url": "https://www.pabbly.com/",
    "currency_code": "USD",
    "meta_data": {
      "value1": "{value_details}",
      "value2": "{value_details}",
      "value3": "{value_details}"
    }
  }'
```

_Ruby_

```ruby
require 'net/http'
require 'json'

uri = URI('https://payments.pabbly.com/api/v1/plan/create')
request = Net::HTTP::Post.new(uri)
request.basic_auth '{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'
request['Content-Type'] = 'application/json'
request.body = "{\"product_id\":\"5ea2d55617f6bf3123f0f95f\",\"plan_name\":\"plan1\",\"plan_code\":\"plan1\",\"billing_cycle\":\"lifetime\",\"setup_fee\":2,\"billing_cycle_num\":\"2\",\"price\":10,\"billing_period\":\"m\",\"billing_period_num\":\"1\",\"plan_active\":\"true\",\"plan_description\":\"\",\"trial_period\":2,\"redirect_url\":\"https://www.pabbly.com/\",\"currency_code\":\"USD\",\"meta_data\":{\"value1\":\"{value_details}\",\"value2\":\"{value_details}\",\"value3\":\"{value_details}\"}}"

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == 'https') do |http|
  http.request(request)
end

data = JSON.parse(response.body)
```

_Python_

```python
import requests
from requests.auth import HTTPBasicAuth

response = requests.post(
    'https://payments.pabbly.com/api/v1/plan/create',
    auth=HTTPBasicAuth('{{YOUR_API_KEY}}', '{{YOUR_SECRET_KEY}}'),
    json={
    'product_id': '5ea2d55617f6bf3123f0f95f',
    'plan_name': 'plan1',
    'plan_code': 'plan1',
    'billing_cycle': 'lifetime',
    'setup_fee': 2,
    'billing_cycle_num': '2',
    'price': 10,
    'billing_period': 'm',
    'billing_period_num': '1',
    'plan_active': 'true',
    'plan_description': '',
    'trial_period': 2,
    'redirect_url': 'https://www.pabbly.com/',
    'currency_code': 'USD',
    'meta_data': {
        'value1': '{value_details}',
        'value2': '{value_details}',
        'value3': '{value_details}'
    }
},
)

data = response.json()
```

_PHP_

```php
<?php
$ch = curl_init('https://payments.pabbly.com/api/v1/plan/create');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_USERPWD, '{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}');
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_POSTFIELDS, '{"product_id":"5ea2d55617f6bf3123f0f95f","plan_name":"plan1","plan_code":"plan1","billing_cycle":"lifetime","setup_fee":2,"billing_cycle_num":"2","price":10,"billing_period":"m","billing_period_num":"1","plan_active":"true","plan_description":"","trial_period":2,"redirect_url":"https://www.pabbly.com/","currency_code":"USD","meta_data":{"value1":"{value_details}","value2":"{value_details}","value3":"{value_details}"}}');

$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
```

_Java_

```java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Base64;

String credentials = Base64.getEncoder().encodeToString("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}".getBytes());

HttpClient client = HttpClient.newHttpClient();
HttpRequest.Builder builder = HttpRequest.newBuilder()
    .uri(URI.create("https://payments.pabbly.com/api/v1/plan/create"))
    .header("Authorization", "Basic " + credentials)
    .header("Content-Type", "application/json")
    .method("POST", HttpRequest.BodyPublishers.ofString("{\"product_id\":\"5ea2d55617f6bf3123f0f95f\",\"plan_name\":\"plan1\",\"plan_code\":\"plan1\",\"billing_cycle\":\"lifetime\",\"setup_fee\":2,\"billing_cycle_num\":\"2\",\"price\":10,\"billing_period\":\"m\",\"billing_period_num\":\"1\",\"plan_active\":\"true\",\"plan_description\":\"\",\"trial_period\":2,\"redirect_url\":\"https://www.pabbly.com/\",\"currency_code\":\"USD\",\"meta_data\":{\"value1\":\"{value_details}\",\"value2\":\"{value_details}\",\"value3\":\"{value_details}\"}}"));

HttpRequest request = builder.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
```

_Node.js_

```node
const credentials = Buffer.from('{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}').toString('base64');

const response = await fetch('https://payments.pabbly.com/api/v1/plan/create', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${credentials}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    "product_id": "5ea2d55617f6bf3123f0f95f",
    "plan_name": "plan1",
    "plan_code": "plan1",
    "billing_cycle": "lifetime",
    "setup_fee": 2,
    "billing_cycle_num": "2",
    "price": 10,
    "billing_period": "m",
    "billing_period_num": "1",
    "plan_active": "true",
    "plan_description": "",
    "trial_period": 2,
    "redirect_url": "https://www.pabbly.com/",
    "currency_code": "USD",
    "meta_data": {
      "value1": "{value_details}",
      "value2": "{value_details}",
      "value3": "{value_details}"
    }
  }),
});

const data = await response.json();
```

_Go_

```go
package main

import (
    "fmt"
    "io"
    "net/http"
    "strings"
)

func main() {
    payload := strings.NewReader("{\"product_id\":\"5ea2d55617f6bf3123f0f95f\",\"plan_name\":\"plan1\",\"plan_code\":\"plan1\",\"billing_cycle\":\"lifetime\",\"setup_fee\":2,\"billing_cycle_num\":\"2\",\"price\":10,\"billing_period\":\"m\",\"billing_period_num\":\"1\",\"plan_active\":\"true\",\"plan_description\":\"\",\"trial_period\":2,\"redirect_url\":\"https://www.pabbly.com/\",\"currency_code\":\"USD\",\"meta_data\":{\"value1\":\"{value_details}\",\"value2\":\"{value_details}\",\"value3\":\"{value_details}\"}}")
    req, _ := http.NewRequest("POST", "https://payments.pabbly.com/api/v1/plan/create", payload)
    req.Header.Set("Content-Type", "application/json")
    req.SetBasicAuth("{{YOUR_API_KEY}}", "{{YOUR_SECRET_KEY}}")

    res, _ := http.DefaultClient.Do(req)
    defer res.Body.Close()
    body, _ := io.ReadAll(res.Body)
    fmt.Println(string(body))
}
```

_.NET_

```dotnet
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Threading.Tasks;

var credentials = Convert.ToBase64String(Encoding.ASCII.GetBytes("{{YOUR_API_KEY}}:{{YOUR_SECRET_KEY}}"));

var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://payments.pabbly.com/api/v1/plan/create");
request.Headers.TryAddWithoutValidation("Authorization", $"Basic {credentials}");
request.Content = new StringContent("{\"product_id\":\"5ea2d55617f6bf3123f0f95f\",\"plan_name\":\"plan1\",\"plan_code\":\"plan1\",\"billing_cycle\":\"lifetime\",\"setup_fee\":2,\"billing_cycle_num\":\"2\",\"price\":10,\"billing_period\":\"m\",\"billing_period_num\":\"1\",\"plan_active\":\"true\",\"plan_description\":\"\",\"trial_period\":2,\"redirect_url\":\"https://www.pabbly.com/\",\"currency_code\":\"USD\",\"meta_data\":{\"value1\":\"{value_details}\",\"value2\":\"{value_details}\",\"value3\":\"{value_details}\"}}");
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");

var response = await client.SendAsync(request);
var data = await response.Content.ReadAsStringAsync();
Console.WriteLine(data);
```

---

**Other endpoints in Plans:**

- [GET /plans — List All Plans](/subscription-billing/plans/list-all-plans)
- [GET /plan/{{plan_id}} — Get single Plan by Plan ID](/subscription-billing/plans/get-single-plan-by-plan-id)
- [GET /plans/{{product_id}} — List All Plans By Product ID](/subscription-billing/plans/list-all-plans-by-product-id)
- [PUT /plan/update/{{plan_id}} — Update Plan](/subscription-billing/plans/update-plan)
- [DELETE /plans/{{plan_id}} — Delete Plan](/subscription-billing/plans/delete-plan)

