API Test Keys

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?

Curl

change language

change language

1
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
2
3
-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": "MYR",
11
"customer_details": {
12
"billing_address": null,
13
"contact": "9876543210",
14
"customer_contact": "9876543210",
15
"customer_email": "gaurav.kumar@example.com",
16
"customer_name": "Gaurav Kumar",
17
"email": "gaurav.kumar@example.com",
18
"id": "cust_DtHaBuooGHTuyZ",
19
"name": "Gaurav Kumar",
20
"shipping_address": null
21
},
22
"customer_id": "cust_DtHaBuooGHTuyZ",
23
"date": 1588076279,
24
"description": "Domestic invoice for Gaurav Kumar.",
25
"email_status": "pending",
26
"entity": "invoice",
27
"expire_by": 1924991999,
28
"expired_at": null,
29
"first_payment_min_amount": null,
30
"gross_amount": 20000,
31
"group_taxes_discounts": false,
32
"id": "inv_JqVZyyKWjCs9cY",
33
"idempotency_key": null,
34
"invoice_number": "Receipt No. 123234",
35
"issued_at": null,
36
"line_items": [
37
{
38
"amount": 20000,
39
"currency": "MYR",
40
"description": "Crate of sea weed.",
41
"gross_amount": 20000,
42
"id": "li_JqVZyzHIx1exXC",
43
"item_id": null,
44
"name": "Crate of sea weed",
45
"net_amount": 20000,
46
"quantity": 1,
47
"ref_id": null,
48
"ref_type": null,
49
"sac_code": null,
50
"tax_amount": 0,
51
"tax_inclusive": false,
52
"tax_rate": null,
53
"taxable_amount": 20000,
54
"taxes": [],
55
"type": "invoice",
56
"unit": null,
57
"unit_amount": 20000
58
}
59
],
60
"notes": {
61
"notes_key_1": "Tea, Earl Grey, Hot",
62
"notes_key_2": "Tea, Earl Grey… decaf."
63
},
64
"order_id": null,
65
"paid_at": null,
66
"partial_payment": true,
67
"payment_id": null,
68
"receipt": "Receipt No. 123234",
69
"reminder_status": null,
70
"short_url": null,
71
"sms_status": "pending",
72
"status": "cancelled",
73
"subscription_status": null,
74
"supply_state_code": null,
75
"tax_amount": 0,
76
"taxable_amount": 20000,
77
"terms": "No Returns; No Refunds",
78
"type": "invoice",
79
"user_id": null,
80
"view_less": true
81
}
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

. Alternatively, you can pass the customer object described in the below fields.

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 MYR 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. Possible value: MYR.

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

. Alternatively, you can pass the customer object described in the below fields.

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 MYR 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. Possible value: MYR.

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

Curl

change language

change language

1
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
2
3
-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": "MYR",
11
"customer_details": {
12
"billing_address": null,
13
"contact": "9876543210",
14
"customer_contact": "9876543210",
15
"customer_email": "gaurav.kumar@example.com",
16
"customer_name": "Gaurav Kumar",
17
"email": "gaurav.kumar@example.com",
18
"id": "cust_DtHaBuooGHTuyZ",
19
"name": "Gaurav Kumar",
20
"shipping_address": null
21
},
22
"customer_id": "cust_DtHaBuooGHTuyZ",
23
"date": 1588076279,
24
"description": "Domestic invoice for Gaurav Kumar.",
25
"email_status": "pending",
26
"entity": "invoice",
27
"expire_by": 1924991999,
28
"expired_at": null,
29
"first_payment_min_amount": null,
30
"gross_amount": 20000,
31
"group_taxes_discounts": false,
32
"id": "inv_JqVZyyKWjCs9cY",
33
"idempotency_key": null,
34
"invoice_number": "Receipt No. 123234",
35
"issued_at": null,
36
"line_items": [
37
{
38
"amount": 20000,
39
"currency": "MYR",
40
"description": "Crate of sea weed.",
41
"gross_amount": 20000,
42
"id": "li_JqVZyzHIx1exXC",
43
"item_id": null,
44
"name": "Crate of sea weed",
45
"net_amount": 20000,
46
"quantity": 1,
47
"ref_id": null,
48
"ref_type": null,
49
"sac_code": null,
50
"tax_amount": 0,
51
"tax_inclusive": false,
52
"tax_rate": null,
53
"taxable_amount": 20000,
54
"taxes": [],
55
"type": "invoice",
56
"unit": null,
57
"unit_amount": 20000
58
}
59
],
60
"notes": {
61
"notes_key_1": "Tea, Earl Grey, Hot",
62
"notes_key_2": "Tea, Earl Grey… decaf."
63
},
64
"order_id": null,
65
"paid_at": null,
66
"partial_payment": true,
67
"payment_id": null,
68
"receipt": "Receipt No. 123234",
69
"reminder_status": null,
70
"short_url": null,
71
"sms_status": "pending",
72
"status": "cancelled",
73
"subscription_status": null,
74
"supply_state_code": null,
75
"tax_amount": 0,
76
"taxable_amount": 20000,
77
"terms": "No Returns; No Refunds",
78
"type": "invoice",
79
"user_id": null,
80
"view_less": true
81
}