Skip to main content
POST
/
api
/
v2
/
subscription-plans
Create a Subscription Plan
curl --request POST \
  --url https://sandbox.cashfree.com/api/v2/subscription-plans \
  --header 'Content-Type: application/json' \
  --header 'X-Client-Id: <x-client-id>' \
  --header 'X-Client-Secret: <x-client-secret>' \
  --data '
{
  "planId": "1682406696",
  "planName": "Plan 1682406656",
  "type": "PERIODIC",
  "recurringAmount": 10,
  "maxAmount": 100,
  "intervals": 1,
  "intervalType": "month"
}
'
import requests

url = "https://sandbox.cashfree.com/api/v2/subscription-plans"

payload = {
"planId": "1682406696",
"planName": "Plan 1682406656",
"type": "PERIODIC",
"recurringAmount": 10,
"maxAmount": 100,
"intervals": 1,
"intervalType": "month"
}
headers = {
"X-Client-Id": "<x-client-id>",
"X-Client-Secret": "<x-client-secret>",
"Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {
'X-Client-Id': '<x-client-id>',
'X-Client-Secret': '<x-client-secret>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
planId: '1682406696',
planName: 'Plan 1682406656',
type: 'PERIODIC',
recurringAmount: 10,
maxAmount: 100,
intervals: 1,
intervalType: 'month'
})
};

fetch('https://sandbox.cashfree.com/api/v2/subscription-plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://sandbox.cashfree.com/api/v2/subscription-plans",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'planId' => '1682406696',
'planName' => 'Plan 1682406656',
'type' => 'PERIODIC',
'recurringAmount' => 10,
'maxAmount' => 100,
'intervals' => 1,
'intervalType' => 'month'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-Client-Id: <x-client-id>",
"X-Client-Secret: <x-client-secret>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://sandbox.cashfree.com/api/v2/subscription-plans"

payload := strings.NewReader("{\n \"planId\": \"1682406696\",\n \"planName\": \"Plan 1682406656\",\n \"type\": \"PERIODIC\",\n \"recurringAmount\": 10,\n \"maxAmount\": 100,\n \"intervals\": 1,\n \"intervalType\": \"month\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("X-Client-Id", "<x-client-id>")
req.Header.Add("X-Client-Secret", "<x-client-secret>")
req.Header.Add("Content-Type", "application/json")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://sandbox.cashfree.com/api/v2/subscription-plans")
.header("X-Client-Id", "<x-client-id>")
.header("X-Client-Secret", "<x-client-secret>")
.header("Content-Type", "application/json")
.body("{\n \"planId\": \"1682406696\",\n \"planName\": \"Plan 1682406656\",\n \"type\": \"PERIODIC\",\n \"recurringAmount\": 10,\n \"maxAmount\": 100,\n \"intervals\": 1,\n \"intervalType\": \"month\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://sandbox.cashfree.com/api/v2/subscription-plans")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Client-Id"] = '<x-client-id>'
request["X-Client-Secret"] = '<x-client-secret>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"planId\": \"1682406696\",\n \"planName\": \"Plan 1682406656\",\n \"type\": \"PERIODIC\",\n \"recurringAmount\": 10,\n \"maxAmount\": 100,\n \"intervals\": 1,\n \"intervalType\": \"month\"\n}"

response = http.request(request)
puts response.read_body
{
  "message": "Plan created successfully",
  "status": "OK",
  "data": {
    "planId": "1682406696",
    "planName": "Plan 1682406656",
    "type": "PERIODIC",
    "currency": "INR",
    "amount": 10,
    "maxAmount": 100,
    "intervals": 1,
    "intervalType": "month",
    "isActive": true,
    "addedOn": "2023-04-25 13:50:17"
  }
}

Headers

X-Client-Id
string
required

Client ID provided by Cashfree.

Example:

"asdf1234"

X-Client-Secret
string
required

Client Secret provided by Cashfree.

Example:

"qwer9876"

Body

application/json
planId
string

Unique ID for the subscription plan.

Example:

"1682406696"

planName
string

Name of the subscription plan.

Example:

"Plan 1682406656"

type
enum<string>

The type of the subscription plan.

Available options:
PERIODIC,
ON_DEMAND
Example:

"PERIODIC"

recurringAmount
number

Recurring amount for the plan.

Example:

10

maxAmount
number

Maximum amount for the plan.

Example:

100

intervals
integer

Number of intervals for the periodic plan.

Example:

1

intervalType
enum<string>

Interval type for the periodic plan.

Available options:
day,
week,
month,
year
Example:

"month"

Response

Subscription plan created successfully.