API Test Keys
Create a Subscription Link
POST
/v1/subscriptions
Click to copy
Use this endpoint to create a Subscription link.
Is this page helpful?
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \2-X POST https://api.razorpay.com/v1/subscriptions \3-H "Content-Type: application/json" \4-d '{5"plan_id": "plan_00000000000001",6"total_count": 12,7"quantity": 1,8"start_at": 1561852800,9"expire_by": 1561939199,10"customer_notify": 1,11"addons": [12{13"item": {14"name": "Delivery charges",15"amount": 30000,16"currency": "MYR"17}18}19],20"offer_id":"offer_JHD834hjbxzhd38d",21"notes": {22"notes_key_1":"Tea, Earl Grey, Hot",23"notes_key_2":"Tea, Earl Grey… decaf."24},25"notify_info":{26"notify_phone": "+601234567890",27"notify_email": "nur.aisyah@example.com"28}29}'
Success
Failure
1{2"id":"sub_00000000000002",3"entity":"subscription",4"plan_id":"plan_00000000000001",5"status":"created",6"current_start":null,7"current_end":null,8"ended_at":null,9"quantity":1,10"notes":{11"notes_key_1":"Tea, Earl Grey, Hot",12"notes_key_2":"Tea, Earl Grey… decaf."13},14"charge_at":1580453311,15"start_at":1580453311,16"end_at":1587061800,17"auth_attempts":0,18"total_count":12,19"paid_count":0,20"customer_notify":true,21"created_at":1580283117,22"expire_by":1581013800,23"short_url":"https://rzp.io/i/m0y0f",24"has_scheduled_changes":false,25"change_scheduled_at":null,26"source": "api",27"offer_id":"offer_JHD834hjbxzhd38d",28"remaining_count":1229}
Request Parameters
plan_id
*
string
The unique identifier of a plan that should be linked to the Subscription. For example, plan_00000000000001
.
total_count
*
integer
The number of billing cycles for which the customer should be charged. For example, if a customer is buying a 1-year subscription billed on a bi-monthly basis, this value should be 6
.
quantity
integer
The number of times the customer should be charged the plan amount per invoice. For example, a customer subscribes to use software. The charges are MYR 100.00 /month/license. The customer wants 5 licenses. You should pass 5
as the quantity. The customer is charged MYR 500.00 (5 x MYR 100.00) monthly. By default, this value is set to 1
.
start_at
integer
Unix timestamp that indicates from when the Subscription should start. If not passed, the Subscription starts immediately after the authorisation payment. For example, 1581013800
. For Subscriptions with a future start_date, frequency is considered as_presented
.
expire_by
integer
Unix timestamp that indicates till when the customer can make the authorisation payment. For example, 1581013800
. The default value is 30 years. Do not pass any value if you do not want to set an expiry date.
customer_notify
boolean
Indicates whether the communication to the customer would be handled by businesses or Curlec. Possible values:
0
: communication handled by businesses.1
(default): communication handled by Curlec.
addons
object
Array that contains details of any upfront amount you want to collect as part of the authorisation transaction.
Show child parameters (1)
offer_id
string
The unique identifier of the offer that is linked to the Subscription. You can obtain this from the Dashboard. For example, offer_JHD834hjbxzhd38d
.
notes
object
Notes you can enter for 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": "Beam me up Scotty”
.
notify_info
object
The customer's email and phone number to which notifications are to be sent. Use this array only if you have set the customer_notify
parameter to 1
. That is, Curlec sends notifications to the customer. The customer details entered in the API request are only to notify the customer about the Subscription. The same will not be prefilled in the checkout as per the government guidelines.
Show child parameters (2)
Response Parameters
id
string
The unique identifier of the subscription created. For example, sub_00000000000001
.
entity
string
The entity being created. Here, it will be subscription
.
plan_id
string
The unique identifier for a plan that is linked to the created subscription. For example, plan_00000000000001
.
customer_id
string
The unique identifier of the customer linked to the subscription. This is populated automatically once the customer completes the authorization transaction. For example, cust_00000000000001
.
status
string
Status of the subscription. Refer to the
for more details. Possible values:created
authenticated
active
pending
halted
cancelled
completed
expired
current_start
integer
Unix timestamp. The start time of the current billing cycle of the subscription. For example, 1581013800
.
current_end
integer
Unix timestamp. The end time of the current billing cycle of the subscription. For example, 1581013800
.
ended_at
integer
The timestamp, in Unix format, when the subscription was completed or was cancelled. For example, 1581013800
.
quantity
integer
The number of times the plan should be linked to the subscription. For example, if the plan is MYR 100.00/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged MYR 500.00 (5 x MYR 100.00) monthly. By default, this value is set to 1.
notes
object
Notes you can enter for 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": "Beam me up Scotty”
.
charge_at
integer
Unix timestamp. This indicates when the next charge on the subscription should be made. For example, 1581013800
.
offer_id
string
The unique identifier of the offer that should be linked to the subscription. For example, offer_JHD834hjbxzhd38d
.
start_at
integer
The timestamp, in Unix format, when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. For example, 1581013800
.
end_at
integer
The timestamp, in Unix format, when the subscription should end. For example, 1581013800
.
auth_attempts
integer
The number of times that the charge for the current billing cycle has been attempted on the card. For example, 2
.
total_count
integer
The number of billing cycles for which the customer should be charged. For example, 2
. We support subscriptions for a maximum duration of 100 years. The number of billing cycles depends if the subscription is daily, weekly, monthly or yearly.
paid_count
integer
This indicates the number of billing cycles for which the customer has already been charged. For example, 2
.
customer_notify
boolean
Indicates whether the communication to the customer would be handled by businesses or Curlec.
false
: communication handled by businesses.true
: communication handled by Curlec. Defaults totrue
.
created_at
integer
The timestamp, in Unix format, when the subscription was created. For example, 1581013800
.
expire_by
integer
The timestamp, in Unix format, till when the customer can make the authorization payment. For example, 1581013800
.
short_url
string
URL that can be used to make the authorization payment. For example, https://rzp.io/i/PWtAiEo
.
has_scheduled_changes
boolean
Indicates if the subscription has any scheduled changes. Possible values:
true
false
schedule_change_at
string
Represents when the subscription should be updated. Possible values:
now
(default value): Updates the subscription immediately.cycle_end
: Updates the subscription at the end of the current billing cycle.
remaining_count
integer
This indicates the number of billing cycles remaining on the subscription. For example, 2
.
Errors
Link expire by cannot be lesser than the current time.
Error Status: 400
This error occurs when the time mentioned in the expire_by
parameter has already passed. For example, if today's date is 12 December 2022, but the expiry date is mentioned as 10 December 2022.
Solution
Create a Subscription Link
POST
/v1/subscriptions
Click to copy
Use this endpoint to create a Subscription link.
Is this page helpful?
Request Parameters
plan_id
*
string
The unique identifier of a plan that should be linked to the Subscription. For example, plan_00000000000001
.
total_count
*
integer
The number of billing cycles for which the customer should be charged. For example, if a customer is buying a 1-year subscription billed on a bi-monthly basis, this value should be 6
.
quantity
integer
The number of times the customer should be charged the plan amount per invoice. For example, a customer subscribes to use software. The charges are MYR 100.00 /month/license. The customer wants 5 licenses. You should pass 5
as the quantity. The customer is charged MYR 500.00 (5 x MYR 100.00) monthly. By default, this value is set to 1
.
start_at
integer
Unix timestamp that indicates from when the Subscription should start. If not passed, the Subscription starts immediately after the authorisation payment. For example, 1581013800
. For Subscriptions with a future start_date, frequency is considered as_presented
.
expire_by
integer
Unix timestamp that indicates till when the customer can make the authorisation payment. For example, 1581013800
. The default value is 30 years. Do not pass any value if you do not want to set an expiry date.
customer_notify
boolean
Indicates whether the communication to the customer would be handled by businesses or Curlec. Possible values:
0
: communication handled by businesses.1
(default): communication handled by Curlec.
addons
object
Array that contains details of any upfront amount you want to collect as part of the authorisation transaction.
Show child parameters (1)
offer_id
string
The unique identifier of the offer that is linked to the Subscription. You can obtain this from the Dashboard. For example, offer_JHD834hjbxzhd38d
.
notes
object
Notes you can enter for 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": "Beam me up Scotty”
.
notify_info
object
The customer's email and phone number to which notifications are to be sent. Use this array only if you have set the customer_notify
parameter to 1
. That is, Curlec sends notifications to the customer. The customer details entered in the API request are only to notify the customer about the Subscription. The same will not be prefilled in the checkout as per the government guidelines.
Show child parameters (2)
Response Parameters
id
string
The unique identifier of the subscription created. For example, sub_00000000000001
.
entity
string
The entity being created. Here, it will be subscription
.
plan_id
string
The unique identifier for a plan that is linked to the created subscription. For example, plan_00000000000001
.
customer_id
string
The unique identifier of the customer linked to the subscription. This is populated automatically once the customer completes the authorization transaction. For example, cust_00000000000001
.
status
string
Status of the subscription. Refer to the
for more details. Possible values:created
authenticated
active
pending
halted
cancelled
completed
expired
current_start
integer
Unix timestamp. The start time of the current billing cycle of the subscription. For example, 1581013800
.
current_end
integer
Unix timestamp. The end time of the current billing cycle of the subscription. For example, 1581013800
.
ended_at
integer
The timestamp, in Unix format, when the subscription was completed or was cancelled. For example, 1581013800
.
quantity
integer
The number of times the plan should be linked to the subscription. For example, if the plan is MYR 100.00/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged MYR 500.00 (5 x MYR 100.00) monthly. By default, this value is set to 1.
notes
object
Notes you can enter for 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": "Beam me up Scotty”
.
charge_at
integer
Unix timestamp. This indicates when the next charge on the subscription should be made. For example, 1581013800
.
offer_id
string
The unique identifier of the offer that should be linked to the subscription. For example, offer_JHD834hjbxzhd38d
.
start_at
integer
The timestamp, in Unix format, when the subscription should start. If not passed, the subscription starts immediately after the authorization payment. For example, 1581013800
.
end_at
integer
The timestamp, in Unix format, when the subscription should end. For example, 1581013800
.
auth_attempts
integer
The number of times that the charge for the current billing cycle has been attempted on the card. For example, 2
.
total_count
integer
The number of billing cycles for which the customer should be charged. For example, 2
. We support subscriptions for a maximum duration of 100 years. The number of billing cycles depends if the subscription is daily, weekly, monthly or yearly.
paid_count
integer
This indicates the number of billing cycles for which the customer has already been charged. For example, 2
.
customer_notify
boolean
Indicates whether the communication to the customer would be handled by businesses or Curlec.
false
: communication handled by businesses.true
: communication handled by Curlec. Defaults totrue
.
created_at
integer
The timestamp, in Unix format, when the subscription was created. For example, 1581013800
.
expire_by
integer
The timestamp, in Unix format, till when the customer can make the authorization payment. For example, 1581013800
.
short_url
string
URL that can be used to make the authorization payment. For example, https://rzp.io/i/PWtAiEo
.
has_scheduled_changes
boolean
Indicates if the subscription has any scheduled changes. Possible values:
true
false
schedule_change_at
string
Represents when the subscription should be updated. Possible values:
now
(default value): Updates the subscription immediately.cycle_end
: Updates the subscription at the end of the current billing cycle.
remaining_count
integer
This indicates the number of billing cycles remaining on the subscription. For example, 2
.
Errors
Link expire by cannot be lesser than the current time.
Error Status: 400
This error occurs when the time mentioned in the expire_by
parameter has already passed. For example, if today's date is 12 December 2022, but the expiry date is mentioned as 10 December 2022.
Solution
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \2-X POST https://api.razorpay.com/v1/subscriptions \3-H "Content-Type: application/json" \4-d '{5"plan_id": "plan_00000000000001",6"total_count": 12,7"quantity": 1,8"start_at": 1561852800,9"expire_by": 1561939199,10"customer_notify": 1,11"addons": [12{13"item": {14"name": "Delivery charges",15"amount": 30000,16"currency": "MYR"17}18}19],20"offer_id":"offer_JHD834hjbxzhd38d",21"notes": {22"notes_key_1":"Tea, Earl Grey, Hot",23"notes_key_2":"Tea, Earl Grey… decaf."24},25"notify_info":{26"notify_phone": "+601234567890",27"notify_email": "nur.aisyah@example.com"28}29}'
Success
Failure
1{2"id":"sub_00000000000002",3"entity":"subscription",4"plan_id":"plan_00000000000001",5"status":"created",6"current_start":null,7"current_end":null,8"ended_at":null,9"quantity":1,10"notes":{11"notes_key_1":"Tea, Earl Grey, Hot",12"notes_key_2":"Tea, Earl Grey… decaf."13},14"charge_at":1580453311,15"start_at":1580453311,16"end_at":1587061800,17"auth_attempts":0,18"total_count":12,19"paid_count":0,20"customer_notify":true,21"created_at":1580283117,22"expire_by":1581013800,23"short_url":"https://rzp.io/i/m0y0f",24"has_scheduled_changes":false,25"change_scheduled_at":null,26"source": "api",27"offer_id":"offer_JHD834hjbxzhd38d",28"remaining_count":1229}