Cancel an Invoice
POST
/v1/invoices/:id/cancel
Click to copy
Use this endpoint to cancel an invoice. Invoices in the paid
state cannot be cancelled.
Is this page helpful?
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]23-X POST https://api.razorpay.com/v1/invoices/inv_JqVZyyKWjCs9cY/cancel \
Success
Failure
1{2"amount": 20000,3"amount_due": null,4"amount_paid": null,5"billing_end": null,6"billing_start": null,7"cancelled_at": 1657203958,8"comment": "Fresh sea weed mowed this morning",9"created_at": 1657203943,10"currency": "INR",11"currency_symbol": "₹",12"customer_details": {13"billing_address": null,14"contact": "9876543210",15"customer_contact": "9876543210",16"customer_email": "gaurav.kumar@example.com",17"customer_name": "Gaurav Kumar",18"email": "gaurav.kumar@example.com",19"gstin": null,20"id": "cust_DtHaBuooGHTuyZ",21"name": "Gaurav Kumar",22"shipping_address": null23},24"customer_id": "cust_DtHaBuooGHTuyZ",25"date": 1588076279,26"description": "Domestic invoice for Gaurav Kumar.",27"email_status": "pending",28"entity": "invoice",29"expire_by": 1924991999,30"expired_at": null,31"first_payment_min_amount": null,32"gross_amount": 20000,33"group_taxes_discounts": false,34"id": "inv_JqVZyyKWjCs9cY",35"idempotency_key": null,36"invoice_number": "Receipt No. 123234",37"issued_at": null,38"line_items": [39{40"amount": 20000,41"currency": "INR",42"description": "Crate of sea weed.",43"gross_amount": 20000,44"hsn_code": null,45"id": "li_JqVZyzHIx1exXC",46"item_id": null,47"name": "Crate of sea weed",48"net_amount": 20000,49"quantity": 1,50"ref_id": null,51"ref_type": null,52"sac_code": null,53"tax_amount": 0,54"tax_inclusive": false,55"tax_rate": null,56"taxable_amount": 20000,57"taxes": [],58"type": "invoice",59"unit": null,60"unit_amount": 2000061}62],63"notes": {64"notes_key_1": "Tea, Earl Grey, Hot",65"notes_key_2": "Tea, Earl Grey… decaf."66},67"order_id": null,68"paid_at": null,69"partial_payment": true,70"payment_id": null,71"receipt": "Receipt No. 123234",72"reminder_status": null,73"short_url": null,74"sms_status": "pending",75"status": "cancelled",76"subscription_status": null,77"supply_state_code": null,78"tax_amount": 0,79"taxable_amount": 20000,80"terms": "No Returns; No Refunds",81"type": "invoice",82"user_id": null,83"view_less": true84}
Path Parameters
id
*
string
The unique identifier of the invoice.
Response Parameters
id
string
The unique identifier of the invoice.
entity
string
Indicates the type of entity. Here, it is invoice
.
type
string
Here, it should be invoice
.
invoice_number
string
Unique number you added for internal reference. The minimum character length is 1 and maximum is 40.
customer_id
string
The unique identifier of the customer. You can create customer_id
using the
customer_details
object
Details of the customer.
Show child parameters (6)
order_id
string
The unique identifier of the order associated with the invoice.
line_items
object
Details of the line item that is billed in the invoice. Maximum of 50 line items.
Show child parameters (8)
payment_id
string
Unique identifier of a payment made against this invoice.
status
string
The status of the invoice. Know more about
. Possible values:draft
issued
partially_paid
paid
cancelled
expired
deleted
expire_by
integer
Timestamp, in Unix format, at which the invoice will expire.
issued_at
integer
Timestamp, in Unix format, at which the invoice was issued to the customer.
paid_at
integer
Timestamp, in Unix format, at which the payment was made.
cancelled_at
integer
Timestamp, in Unix format, at which the invoice was cancelled.
expired_at
integer
Timestamp, in Unix format, at which the invoice expired.
sms_status
string
The delivery status of the SMS notification for the invoice sent to the customer. Possible values:
pending
sent
email_status
string
The delivery status of the email notification for the invoice sent to the customer. Possible values:
pending
sent
partial_payment
boolean
Indicates whether the customer can make a partial payment on the invoice. Possible values:
true
: The customer can make partial payments.false
(default): The customer cannot make partial payments.
amount
integer
Amount to be paid using the invoice. Must be in the smallest unit of the currency. For example, if the amount to be received from the customer is ₹300.00, pass the value as 30000
.
amount_paid
integer
Amount paid by the customer against the invoice.
amount_due
integer
The remaining amount to be paid by the customer for the issued invoice.
currency
string
The currency associated with the invoice. You must mandatorily pass this parameter if accepting international payments. If you have passed currency
as a sub-parameter in the line_item
object, you must ensure that the same currency is passed in both places. Know about the
description
string
A brief description of the invoice. The maximum character length is 2048.
notes
object
Any custom notes added to the invoice. Maximum of 2048 characters.
short_url
string
The short URL that is generated. Share this link with customers to accept payments.
date
integer
Timestamp, in Unix format, that indicates the issue date of the invoice.
terms
string
Any terms to be included in the invoice. Maximum of 2048 characters.
comment
string
Any comments to be added in the invoice. Maximum of 2048 characters.
Errors
Operation not allowed for Invoice in cancelled status.
Error Status: 400
You are trying to cancel an invoice which is already in the cancelled status.
Solution
Cancel an Invoice
POST
/v1/invoices/:id/cancel
Click to copy
Use this endpoint to cancel an invoice. Invoices in the paid
state cannot be cancelled.
Is this page helpful?
Path Parameters
id
*
string
The unique identifier of the invoice.
Response Parameters
id
string
The unique identifier of the invoice.
entity
string
Indicates the type of entity. Here, it is invoice
.
type
string
Here, it should be invoice
.
invoice_number
string
Unique number you added for internal reference. The minimum character length is 1 and maximum is 40.
customer_id
string
The unique identifier of the customer. You can create customer_id
using the
customer_details
object
Details of the customer.
Show child parameters (6)
order_id
string
The unique identifier of the order associated with the invoice.
line_items
object
Details of the line item that is billed in the invoice. Maximum of 50 line items.
Show child parameters (8)
payment_id
string
Unique identifier of a payment made against this invoice.
status
string
The status of the invoice. Know more about
. Possible values:draft
issued
partially_paid
paid
cancelled
expired
deleted
expire_by
integer
Timestamp, in Unix format, at which the invoice will expire.
issued_at
integer
Timestamp, in Unix format, at which the invoice was issued to the customer.
paid_at
integer
Timestamp, in Unix format, at which the payment was made.
cancelled_at
integer
Timestamp, in Unix format, at which the invoice was cancelled.
expired_at
integer
Timestamp, in Unix format, at which the invoice expired.
sms_status
string
The delivery status of the SMS notification for the invoice sent to the customer. Possible values:
pending
sent
email_status
string
The delivery status of the email notification for the invoice sent to the customer. Possible values:
pending
sent
partial_payment
boolean
Indicates whether the customer can make a partial payment on the invoice. Possible values:
true
: The customer can make partial payments.false
(default): The customer cannot make partial payments.
amount
integer
Amount to be paid using the invoice. Must be in the smallest unit of the currency. For example, if the amount to be received from the customer is ₹300.00, pass the value as 30000
.
amount_paid
integer
Amount paid by the customer against the invoice.
amount_due
integer
The remaining amount to be paid by the customer for the issued invoice.
currency
string
The currency associated with the invoice. You must mandatorily pass this parameter if accepting international payments. If you have passed currency
as a sub-parameter in the line_item
object, you must ensure that the same currency is passed in both places. Know about the
description
string
A brief description of the invoice. The maximum character length is 2048.
notes
object
Any custom notes added to the invoice. Maximum of 2048 characters.
short_url
string
The short URL that is generated. Share this link with customers to accept payments.
date
integer
Timestamp, in Unix format, that indicates the issue date of the invoice.
terms
string
Any terms to be included in the invoice. Maximum of 2048 characters.
comment
string
Any comments to be added in the invoice. Maximum of 2048 characters.
Errors
Operation not allowed for Invoice in cancelled status.
Error Status: 400
You are trying to cancel an invoice which is already in the cancelled status.
Solution
1curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]23-X POST https://api.razorpay.com/v1/invoices/inv_JqVZyyKWjCs9cY/cancel \
Success
Failure
1{2"amount": 20000,3"amount_due": null,4"amount_paid": null,5"billing_end": null,6"billing_start": null,7"cancelled_at": 1657203958,8"comment": "Fresh sea weed mowed this morning",9"created_at": 1657203943,10"currency": "INR",11"currency_symbol": "₹",12"customer_details": {13"billing_address": null,14"contact": "9876543210",15"customer_contact": "9876543210",16"customer_email": "gaurav.kumar@example.com",17"customer_name": "Gaurav Kumar",18"email": "gaurav.kumar@example.com",19"gstin": null,20"id": "cust_DtHaBuooGHTuyZ",21"name": "Gaurav Kumar",22"shipping_address": null23},24"customer_id": "cust_DtHaBuooGHTuyZ",25"date": 1588076279,26"description": "Domestic invoice for Gaurav Kumar.",27"email_status": "pending",28"entity": "invoice",29"expire_by": 1924991999,30"expired_at": null,31"first_payment_min_amount": null,32"gross_amount": 20000,33"group_taxes_discounts": false,34"id": "inv_JqVZyyKWjCs9cY",35"idempotency_key": null,36"invoice_number": "Receipt No. 123234",37"issued_at": null,38"line_items": [39{40"amount": 20000,41"currency": "INR",42"description": "Crate of sea weed.",43"gross_amount": 20000,44"hsn_code": null,45"id": "li_JqVZyzHIx1exXC",46"item_id": null,47"name": "Crate of sea weed",48"net_amount": 20000,49"quantity": 1,50"ref_id": null,51"ref_type": null,52"sac_code": null,53"tax_amount": 0,54"tax_inclusive": false,55"tax_rate": null,56"taxable_amount": 20000,57"taxes": [],58"type": "invoice",59"unit": null,60"unit_amount": 2000061}62],63"notes": {64"notes_key_1": "Tea, Earl Grey, Hot",65"notes_key_2": "Tea, Earl Grey… decaf."66},67"order_id": null,68"paid_at": null,69"partial_payment": true,70"payment_id": null,71"receipt": "Receipt No. 123234",72"reminder_status": null,73"short_url": null,74"sms_status": "pending",75"status": "cancelled",76"subscription_status": null,77"supply_state_code": null,78"tax_amount": 0,79"taxable_amount": 20000,80"terms": "No Returns; No Refunds",81"type": "invoice",82"user_id": null,83"view_less": true84}