API Test Keys
Create a Subscription
POST/v1/subscriptionsClick to copy
Use this endpoint to create a Subscription.
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":6,7"quantity":1,8"customer_notify": true,9"start_at":1773461489,10"expire_by":1773547889,11"addons":[12{13"item":{14"name":"Delivery charges",15"amount":3000,16"currency":""17}18}19],20"notes":{21"notes_key_1":"Tea, Earl Grey, Hot",22"notes_key_2":"Tea, Earl Grey… decaf."23}24}'
Success
Failure
1{2"id": "sub_00000000000001",3"entity": "subscription",4"plan_id": "plan_00000000000001",5"customer_email": null,6"status": "created",7"current_start": null,8"current_end": null,9"ended_at": null,10"quantity": 1,11"notes": {12"notes_key_1": "Tea, Earl Grey, Hot",13"notes_key_2": "Tea, Earl Grey… decaf."14},15"charge_at": 1773461489,16"start_at": 1773461489,17"end_at": 1776450600,18"auth_attempts": 0,19"total_count": 6,20"paid_count": 0,21"customer_notify": true,22"created_at": 1773394958,23"expire_by": 1773547889,24"short_url": "https://rzp.io/rzp/Dqdqx3h",25"has_scheduled_changes": false,26"change_scheduled_at": null,27"source": "api",28"remaining_count": 629}
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 $100 /month/license. The customer wants 5 licenses. You should pass 5 as the quantity. The customer is charged $500 (5 x $100) 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 booleanIndicates whether the communication to the customer would be handled by businesses or Razorpay. Possible values:
true(default): Communication handled by Razorpay.false: Communication handled by businesses.
addonsobjectArray 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”.
Response Parameters
idstring The unique identifier of the subscription created. For example, sub_00000000000001.
entitystring The entity being created. Here, it will be subscription.
plan_idstring The unique identifier for a plan that is linked to the created subscription. For example, plan_00000000000001.
customer_idstring The unique identifier of the customer linked to the subscription. This is populated automatically once the customer completes the authorisation transaction. For example, cust_00000000000001.
statusstringStatus of the subscription. Refer to the
for more details. Possible values:createdauthenticatedactivependinghaltedcancelledcompletedexpired
current_startinteger Unix timestamp. The start time of the current billing cycle of the subscription. For example, 1581013800.
current_endinteger Unix timestamp. The end time of the current billing cycle of the subscription. For example, 1581013800.
ended_atinteger The timestamp, in Unix format, when the subscription was completed or was cancelled. For example, 1581013800.
quantityintegerThe number of times the plan should be linked to the subscription. For example, if the plan is $100/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged $500 (5 x $100) monthly. By default, this value is set to 1.
notesobject 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_atinteger Unix timestamp. This indicates when the next charge on the subscription should be made. For example, 1581013800.
offer_idstring The unique identifier of the offer that should be linked to the subscription. For example, offer_JHD834hjbxzhd38d.
start_atinteger The timestamp, in Unix format, when the subscription should start. If not passed, the subscription starts immediately after the authorisation payment. For example, 1581013800.
end_atinteger The timestamp, in Unix format, when the subscription should end. For example, 1581013800.
auth_attemptsinteger The number of times that the charge for the current billing cycle has been attempted on the card. For example, 2.
total_countinteger 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_countinteger This indicates the number of billing cycles for which the customer has already been charged. For example, 2.
customer_notifybooleanIndicates whether the communication to the customer would be handled by businesses or Razorpay.
true: Communication handled by Razorpay. Defaults totrue.false: Communication handled by businesses.
created_atinteger The timestamp, in Unix format, when the subscription was created. For example, 1581013800.
expire_byinteger The timestamp, in Unix format, till when the customer can make the authorisation payment. For example, 1581013800.
short_urlstring URL that can be used to make the authorisation payment. For example, https://rzp.io/i/PWtAiEo.
has_scheduled_changesbooleanIndicates if the subscription has any scheduled changes. Possible values:
true: Subscription has scheduled changes.false: Subscription does not have scheduled changes.
schedule_change_atstringRepresents when the subscription should be updated. Possible values:
now(default): Updates the subscription immediately.cycle_end: Updates the subscription at the end of the current billing cycle.
remaining_countinteger This indicates the number of billing cycles remaining on the subscription. For example, 2.
Errors
The requested URL was not found on the server.
Error Status: 400
This error occurs when the Subscriptions feature is not enabled.
Solution
The id provided does not exist
Error Status: 400
This error occurs when passing an incorrect plan_id.
Solution
Offer Not Found
Error Status: 400
This error occurs when you are linking an invalid/expired offer to a Subscription.
Solution
Offer not applicable for this Subscription
Error Status: 400
This error occurs when you are linking/passing an offer_id to a Subscription on which the offer doesn't apply.
Solution
The plan id field is required.
Error Status: 400
The plan_id was not included in the request body.
Solution
The plan id must be 19 characters.
Error Status: 400
The value passed for plan_id is not 19 characters long (the expected plan_<14 alphanumeric chars> format).
Solution
The plan id must be at least 14 characters.
Error Status: 400
The value passed for plan_id is shorter than the minimum-id payload length. Returned for short or malformed plan ids.
Solution
The total count field is required when end at is not present.
Error Status: 400
Neither total_count nor end_at was included in the request body. At least one is required to bound the subscription.
Solution
The total count must be at least 1.
Error Status: 400
total_count was passed as 0 or a negative value.
Solution
The total count must be an integer.
Error Status: 400
A non-integer value was passed for total_count.
Solution
The quantity must be at least 1.
Error Status: 400
quantity was passed as 0 or a negative value.
Solution
start_at cannot be lesser than the current time.
Error Status: 400
start_at is set to a past UNIX timestamp.
Solution
The customer notify field must be true or false.
Error Status: 400
A non-boolean value (for example a string like "maybe") was passed for customer_notify.
Solution
{any extra field} is/are not required and should not be sent.
Error Status: 400
The request body contains fields that are not part of the Subscriptions API schema.
Solution
Create a Subscription
POST/v1/subscriptionsClick to copy
Use this endpoint to create a Subscription.
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 $100 /month/license. The customer wants 5 licenses. You should pass 5 as the quantity. The customer is charged $500 (5 x $100) 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 booleanIndicates whether the communication to the customer would be handled by businesses or Razorpay. Possible values:
true(default): Communication handled by Razorpay.false: Communication handled by businesses.
addonsobjectArray 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”.
Response Parameters
idstring The unique identifier of the subscription created. For example, sub_00000000000001.
entitystring The entity being created. Here, it will be subscription.
plan_idstring The unique identifier for a plan that is linked to the created subscription. For example, plan_00000000000001.
customer_idstring The unique identifier of the customer linked to the subscription. This is populated automatically once the customer completes the authorisation transaction. For example, cust_00000000000001.
statusstringStatus of the subscription. Refer to the
for more details. Possible values:createdauthenticatedactivependinghaltedcancelledcompletedexpired
current_startinteger Unix timestamp. The start time of the current billing cycle of the subscription. For example, 1581013800.
current_endinteger Unix timestamp. The end time of the current billing cycle of the subscription. For example, 1581013800.
ended_atinteger The timestamp, in Unix format, when the subscription was completed or was cancelled. For example, 1581013800.
quantityintegerThe number of times the plan should be linked to the subscription. For example, if the plan is $100/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged $500 (5 x $100) monthly. By default, this value is set to 1.
notesobject 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_atinteger Unix timestamp. This indicates when the next charge on the subscription should be made. For example, 1581013800.
offer_idstring The unique identifier of the offer that should be linked to the subscription. For example, offer_JHD834hjbxzhd38d.
start_atinteger The timestamp, in Unix format, when the subscription should start. If not passed, the subscription starts immediately after the authorisation payment. For example, 1581013800.
end_atinteger The timestamp, in Unix format, when the subscription should end. For example, 1581013800.
auth_attemptsinteger The number of times that the charge for the current billing cycle has been attempted on the card. For example, 2.
total_countinteger 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_countinteger This indicates the number of billing cycles for which the customer has already been charged. For example, 2.
customer_notifybooleanIndicates whether the communication to the customer would be handled by businesses or Razorpay.
true: Communication handled by Razorpay. Defaults totrue.false: Communication handled by businesses.
created_atinteger The timestamp, in Unix format, when the subscription was created. For example, 1581013800.
expire_byinteger The timestamp, in Unix format, till when the customer can make the authorisation payment. For example, 1581013800.
short_urlstring URL that can be used to make the authorisation payment. For example, https://rzp.io/i/PWtAiEo.
has_scheduled_changesbooleanIndicates if the subscription has any scheduled changes. Possible values:
true: Subscription has scheduled changes.false: Subscription does not have scheduled changes.
schedule_change_atstringRepresents when the subscription should be updated. Possible values:
now(default): Updates the subscription immediately.cycle_end: Updates the subscription at the end of the current billing cycle.
remaining_countinteger This indicates the number of billing cycles remaining on the subscription. For example, 2.
Errors
The requested URL was not found on the server.
Error Status: 400
This error occurs when the Subscriptions feature is not enabled.
Solution
The id provided does not exist
Error Status: 400
This error occurs when passing an incorrect plan_id.
Solution
Offer Not Found
Error Status: 400
This error occurs when you are linking an invalid/expired offer to a Subscription.
Solution
Offer not applicable for this Subscription
Error Status: 400
This error occurs when you are linking/passing an offer_id to a Subscription on which the offer doesn't apply.
Solution
The plan id field is required.
Error Status: 400
The plan_id was not included in the request body.
Solution
The plan id must be 19 characters.
Error Status: 400
The value passed for plan_id is not 19 characters long (the expected plan_<14 alphanumeric chars> format).
Solution
The plan id must be at least 14 characters.
Error Status: 400
The value passed for plan_id is shorter than the minimum-id payload length. Returned for short or malformed plan ids.
Solution
The total count field is required when end at is not present.
Error Status: 400
Neither total_count nor end_at was included in the request body. At least one is required to bound the subscription.
Solution
The total count must be at least 1.
Error Status: 400
total_count was passed as 0 or a negative value.
Solution
The total count must be an integer.
Error Status: 400
A non-integer value was passed for total_count.
Solution
The quantity must be at least 1.
Error Status: 400
quantity was passed as 0 or a negative value.
Solution
start_at cannot be lesser than the current time.
Error Status: 400
start_at is set to a past UNIX timestamp.
Solution
The customer notify field must be true or false.
Error Status: 400
A non-boolean value (for example a string like "maybe") was passed for customer_notify.
Solution
{any extra field} is/are not required and should not be sent.
Error Status: 400
The request body contains fields that are not part of the Subscriptions API schema.
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":6,7"quantity":1,8"customer_notify": true,9"start_at":1773461489,10"expire_by":1773547889,11"addons":[12{13"item":{14"name":"Delivery charges",15"amount":3000,16"currency":""17}18}19],20"notes":{21"notes_key_1":"Tea, Earl Grey, Hot",22"notes_key_2":"Tea, Earl Grey… decaf."23}24}'
Success
Failure
1{2"id": "sub_00000000000001",3"entity": "subscription",4"plan_id": "plan_00000000000001",5"customer_email": null,6"status": "created",7"current_start": null,8"current_end": null,9"ended_at": null,10"quantity": 1,11"notes": {12"notes_key_1": "Tea, Earl Grey, Hot",13"notes_key_2": "Tea, Earl Grey… decaf."14},15"charge_at": 1773461489,16"start_at": 1773461489,17"end_at": 1776450600,18"auth_attempts": 0,19"total_count": 6,20"paid_count": 0,21"customer_notify": true,22"created_at": 1773394958,23"expire_by": 1773547889,24"short_url": "https://rzp.io/rzp/Dqdqx3h",25"has_scheduled_changes": false,26"change_scheduled_at": null,27"source": "api",28"remaining_count": 629}