Cancel an Invoice
POST/v1/invoices/:id/cancelClick to copy
Use this endpoint to cancel an invoice. Invoices in the paid state cannot be cancelled.
Is this page helpful?
Curl
change language
change language
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": "",11"currency_symbol": "<currency_symbol>",12"customer_details": {13"billing_address": null,14"contact": "+60123456789",15"customer_contact": "+60123456789",16"customer_email": "nur.aisyah@example.com",17"customer_name": " Nur Aisyah",18"email": "nur.aisyah@example.com",19"gstin": null,20"id": "cust_DtHaBuooGHTuyZ",21"name": " Nur Aisyah",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": "",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 *
stringThe unique identifier of the invoice.
Response Parameters
idstringThe unique identifier of the invoice.
entitystring Indicates the type of entity. Here, it is invoice.
typestring Here, it should be invoice.
invoice_numberstringUnique number you added for internal reference. The minimum character length is 1 and maximum is 40.
customer_idstring The unique identifier of the customer. You can create customer_id using the
customer_detailsobjectDetails of the customer.
Show child parameters (6)
order_idstringThe unique identifier of the order associated with the invoice.
line_itemsobjectDetails of the line item that is billed in the invoice. Maximum of 50 line items.
Show child parameters (8)
payment_idstringUnique identifier of a payment made against this invoice.
statusstringThe status of the invoice. Know more about
. Possible values:draftissuedpartially_paidpaidcancelledexpireddeleted
expire_byintegerTimestamp, in Unix format, at which the invoice will expire.
issued_atintegerTimestamp, in Unix format, at which the invoice was issued to the customer.
paid_atintegerTimestamp, in Unix format, at which the payment was made.
cancelled_atintegerTimestamp, in Unix format, at which the invoice was cancelled.
expired_atintegerTimestamp, in Unix format, at which the invoice expired.
sms_statusstringThe delivery status of the SMS notification for the invoice sent to the customer. Possible values:
pendingsent
email_statusstringThe delivery status of the email notification for the invoice sent to the customer. Possible values:
pendingsent
partial_paymentbooleanIndicates 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.
amountinteger 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 RM 300.00, pass the value as 30000.
amount_paidintegerAmount paid by the customer against the invoice.
amount_dueintegerThe remaining amount to be paid by the customer for the issued invoice.
currencystring The currency associated with the invoice. Possible value: MYR.
descriptionstringA brief description of the invoice. The maximum character length is 2048.
notesobjectAny custom notes added to the invoice. Maximum of 2048 characters.
short_urlstringThe short URL that is generated. Share this link with customers to accept payments.
dateintegerTimestamp, in Unix format, that indicates the issue date of the invoice.
termsstringAny terms to be included in the invoice. Maximum of 2048 characters.
commentstringAny 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/cancelClick to copy
Use this endpoint to cancel an invoice. Invoices in the paid state cannot be cancelled.
Is this page helpful?
Path Parameters
id *
stringThe unique identifier of the invoice.
Response Parameters
idstringThe unique identifier of the invoice.
entitystring Indicates the type of entity. Here, it is invoice.
typestring Here, it should be invoice.
invoice_numberstringUnique number you added for internal reference. The minimum character length is 1 and maximum is 40.
customer_idstring The unique identifier of the customer. You can create customer_id using the
customer_detailsobjectDetails of the customer.
Show child parameters (6)
order_idstringThe unique identifier of the order associated with the invoice.
line_itemsobjectDetails of the line item that is billed in the invoice. Maximum of 50 line items.
Show child parameters (8)
payment_idstringUnique identifier of a payment made against this invoice.
statusstringThe status of the invoice. Know more about
. Possible values:draftissuedpartially_paidpaidcancelledexpireddeleted
expire_byintegerTimestamp, in Unix format, at which the invoice will expire.
issued_atintegerTimestamp, in Unix format, at which the invoice was issued to the customer.
paid_atintegerTimestamp, in Unix format, at which the payment was made.
cancelled_atintegerTimestamp, in Unix format, at which the invoice was cancelled.
expired_atintegerTimestamp, in Unix format, at which the invoice expired.
sms_statusstringThe delivery status of the SMS notification for the invoice sent to the customer. Possible values:
pendingsent
email_statusstringThe delivery status of the email notification for the invoice sent to the customer. Possible values:
pendingsent
partial_paymentbooleanIndicates 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.
amountinteger 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 RM 300.00, pass the value as 30000.
amount_paidintegerAmount paid by the customer against the invoice.
amount_dueintegerThe remaining amount to be paid by the customer for the issued invoice.
currencystring The currency associated with the invoice. Possible value: MYR.
descriptionstringA brief description of the invoice. The maximum character length is 2048.
notesobjectAny custom notes added to the invoice. Maximum of 2048 characters.
short_urlstringThe short URL that is generated. Share this link with customers to accept payments.
dateintegerTimestamp, in Unix format, that indicates the issue date of the invoice.
termsstringAny terms to be included in the invoice. Maximum of 2048 characters.
commentstringAny 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
Curl
change language
change language
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": "",11"currency_symbol": "<currency_symbol>",12"customer_details": {13"billing_address": null,14"contact": "+60123456789",15"customer_contact": "+60123456789",16"customer_email": "nur.aisyah@example.com",17"customer_name": " Nur Aisyah",18"email": "nur.aisyah@example.com",19"gstin": null,20"id": "cust_DtHaBuooGHTuyZ",21"name": " Nur Aisyah",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": "",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}