API Test Keys
Cancel a Subscription
POST/v1/subscriptions/:id/cancelClick to copy
Use this endpoint to cancel a Subscription. You can either cancel the Subscription immediately or at the end of the current billing cycle. Once cancelled, you cannot renew or reactivate it.
- When you cancel a Subscription, the status changes to
cancelled. - If you choose to cancel a Subscription at the end of a billing cycle, its status changes to
cancelledonly at the end of the current billing cycle.
Is this page helpful?
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \2-X POST https://api.razorpay.com/v1/subscriptions/sub_00000000000001/cancel \3-H "Content-Type: application/json" \4-d '{5"cancel_at_cycle_end": false6}'
Success
Failure
1{2"id": "sub_00000000000001",3"entity": "subscription",4"plan_id": "plan_00000000000001",5"customer_id": "cust_D00000000000001",6"status": "cancelled",7"current_start": 1580453311,8"current_end": 1581013800,9"ended_at": 1580288092,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": 1580453311,16"start_at": 1577385991,17"end_at": 1603737000,18"auth_attempts": 0,19"total_count": 6,20"paid_count": 1,21"customer_notify": true,22"created_at": 1580283117,23"expire_by": 1581013800,24"short_url": "https://rzp.io/i/z3b1R61A9",25"has_scheduled_changes": false,26"change_scheduled_at": null,27"source": "api",28"offer_id":"offer_JHD834hjbxzhd38d",29"remaining_count": 530}
Path Parameters
id *
string The unique identifier linked to a Subscription. For example, sub_00000000000001.
Request Parameters
cancel_at_cycle_endbooleanUse this parameter to cancel a Subscription at the end of a billing cycle. Possible values:
true: Cancel the subscription at the end of the current billing cycle.false(default): Cancel the subscription immediately.
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 authorization 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 RM 100.00/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged RM 500.00 (5 x RM 100.00) 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 authorization 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 Curlec.
true: Communication handled by Razorpay Curlec. 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 authorization payment. For example, 1581013800.
short_urlstring URL that can be used to make the authorization 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
Subscription is not cancellable in expired status.
Error Status: 400
This error occurs when you are trying to cancel a Subscription which is in the expired state.
Solution
Cancel a Subscription
POST/v1/subscriptions/:id/cancelClick to copy
Use this endpoint to cancel a Subscription. You can either cancel the Subscription immediately or at the end of the current billing cycle. Once cancelled, you cannot renew or reactivate it.
- When you cancel a Subscription, the status changes to
cancelled. - If you choose to cancel a Subscription at the end of a billing cycle, its status changes to
cancelledonly at the end of the current billing cycle.
Is this page helpful?
Path Parameters
id *
string The unique identifier linked to a Subscription. For example, sub_00000000000001.
Request Parameters
cancel_at_cycle_endbooleanUse this parameter to cancel a Subscription at the end of a billing cycle. Possible values:
true: Cancel the subscription at the end of the current billing cycle.false(default): Cancel the subscription immediately.
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 authorization 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 RM 100.00/user/month and the customer has 5 users, you should pass 5 as the quantity to have the customer charged RM 500.00 (5 x RM 100.00) 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 authorization 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 Curlec.
true: Communication handled by Razorpay Curlec. 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 authorization payment. For example, 1581013800.
short_urlstring URL that can be used to make the authorization 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
Subscription is not cancellable in expired status.
Error Status: 400
This error occurs when you are trying to cancel a Subscription which is in the expired state.
Solution
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \2-X POST https://api.razorpay.com/v1/subscriptions/sub_00000000000001/cancel \3-H "Content-Type: application/json" \4-d '{5"cancel_at_cycle_end": false6}'
Success
Failure
1{2"id": "sub_00000000000001",3"entity": "subscription",4"plan_id": "plan_00000000000001",5"customer_id": "cust_D00000000000001",6"status": "cancelled",7"current_start": 1580453311,8"current_end": 1581013800,9"ended_at": 1580288092,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": 1580453311,16"start_at": 1577385991,17"end_at": 1603737000,18"auth_attempts": 0,19"total_count": 6,20"paid_count": 1,21"customer_notify": true,22"created_at": 1580283117,23"expire_by": 1581013800,24"short_url": "https://rzp.io/i/z3b1R61A9",25"has_scheduled_changes": false,26"change_scheduled_at": null,27"source": "api",28"offer_id":"offer_JHD834hjbxzhd38d",29"remaining_count": 530}