Create a plan
Creates a new subscription plan that defines the billing period and amount.
curl --request POST \
--url https://api.razorpay.com/v1/plans \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"period": "weekly",
"interval": 1,
"item": {
"name": "Test Weekly 1",
"amount": 500,
"currency": "INR",
"description": "Description for the weekly plan"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
period: 'weekly',
interval: 1,
item: {
name: 'Test Weekly 1',
amount: 500,
currency: 'INR',
description: 'Description for the weekly plan'
}
})
};
fetch('https://api.razorpay.com/v1/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.razorpay.com/v1/plans"
payload = {
"period": "weekly",
"interval": 1,
"item": {
"name": "Test Weekly 1",
"amount": 500,
"currency": "INR",
"description": "Description for the weekly plan"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.razorpay.com/v1/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([
'period' => 'weekly',
'interval' => 1,
'item' => [
'name' => 'Test Weekly 1',
'amount' => 500,
'currency' => 'INR',
'description' => 'Description for the weekly plan'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.razorpay.com/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.razorpay.com/v1/plans"
payload := strings.NewReader("{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.razorpay.com/v1/plans")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}")
.asString();{
"id": "plan_00000000000001",
"entity": "plan",
"interval": 1,
"period": "weekly",
"item": {
"id": "item_00000000000001",
"active": true,
"amount": 500,
"unit_amount": 500,
"currency": "INR",
"name": "Test Weekly 1",
"description": "Description for the weekly plan"
},
"created_at": 1580453311
}{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "The amount must be greater than 0.",
"field": "amount"
}
}{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "The amount must be greater than 0.",
"field": "amount"
}
}Authorizations
Use your Razorpay Key ID as the username and Key Secret as the password.
Body
Billing frequency of the plan.
daily, weekly, monthly, yearly "weekly"
Number of billing period intervals between charges. For example, 2 with period=monthly bills every 2 months.
1
Item details for the plan.
Show child attributes
Show child attributes
Response
Plan created successfully.
A Razorpay Plan object used to define recurring billing.
Unique identifier of the plan.
"plan_00000000000001"
Entity type. Always plan.
"plan"
Number of billing periods between charges. For example, 2 with period=weekly means every 2 weeks.
1
Billing frequency.
daily, weekly, monthly, yearly "weekly"
Details of the item associated with the plan.
Show child attributes
Show child attributes
Unix timestamp at which the plan was created.
1580453311
Was this page helpful?
curl --request POST \
--url https://api.razorpay.com/v1/plans \
--header 'Authorization: Basic <encoded-value>' \
--header 'Content-Type: application/json' \
--data '
{
"period": "weekly",
"interval": 1,
"item": {
"name": "Test Weekly 1",
"amount": 500,
"currency": "INR",
"description": "Description for the weekly plan"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Basic <encoded-value>', 'Content-Type': 'application/json'},
body: JSON.stringify({
period: 'weekly',
interval: 1,
item: {
name: 'Test Weekly 1',
amount: 500,
currency: 'INR',
description: 'Description for the weekly plan'
}
})
};
fetch('https://api.razorpay.com/v1/plans', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.razorpay.com/v1/plans"
payload = {
"period": "weekly",
"interval": 1,
"item": {
"name": "Test Weekly 1",
"amount": 500,
"currency": "INR",
"description": "Description for the weekly plan"
}
}
headers = {
"Authorization": "Basic <encoded-value>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.razorpay.com/v1/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([
'period' => 'weekly',
'interval' => 1,
'item' => [
'name' => 'Test Weekly 1',
'amount' => 500,
'currency' => 'INR',
'description' => 'Description for the weekly plan'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Basic <encoded-value>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}require 'uri'
require 'net/http'
url = URI("https://api.razorpay.com/v1/plans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Basic <encoded-value>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}"
response = http.request(request)
puts response.read_bodypackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.razorpay.com/v1/plans"
payload := strings.NewReader("{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Basic <encoded-value>")
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://api.razorpay.com/v1/plans")
.header("Authorization", "Basic <encoded-value>")
.header("Content-Type", "application/json")
.body("{\n \"period\": \"weekly\",\n \"interval\": 1,\n \"item\": {\n \"name\": \"Test Weekly 1\",\n \"amount\": 500,\n \"currency\": \"INR\",\n \"description\": \"Description for the weekly plan\"\n }\n}")
.asString();{
"id": "plan_00000000000001",
"entity": "plan",
"interval": 1,
"period": "weekly",
"item": {
"id": "item_00000000000001",
"active": true,
"amount": 500,
"unit_amount": 500,
"currency": "INR",
"name": "Test Weekly 1",
"description": "Description for the weekly plan"
},
"created_at": 1580453311
}{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "The amount must be greater than 0.",
"field": "amount"
}
}{
"error": {
"code": "BAD_REQUEST_ERROR",
"description": "The amount must be greater than 0.",
"field": "amount"
}
}