API Test Keys

Create an Invoice With Customer ID

POST
/v1/invoices

Click to copy

Use this endpoint to create an invoice by passing the customer_id.

Handy Tips

You cannot create GST compliant invoices using APIs. This means you cannot add the following to the invoice when creating an invoice via APIs:

  • tax rate
  • cess
  • HSN code
  • SAC code

Is this page helpful?

Curl

change language

change language

1
curl -u <YOUR_KEY_ID>:<YOUR_KEY_SECRET>
2
-X POST https://api.razorpay.com/v1/invoices \
3
-H 'Content-type: application/json' \
4
-d '{
5
"type": "invoice",
6
"date": 1760714528,
7
"customer_id": "cust_HOQzpsovChhcpl",
8
"line_items": [
9
{
10
"item_id": "item_K6g5L6X43dXjEA"
11
}
12
]
13
}'

Success

Failure

1
{
2
"id": "inv_K6g5bviu09mXo1",
3
"entity": "invoice",
4
"receipt": null,
5
"invoice_number": null,
6
"customer_id": "cust_HOQzpsovChhcpl",
7
"customer_details": {
8
"id": "cust_HOQzpsovChhcpl",
9
"name": null,
10
"email": "gaurav.kumar@example.com",
11
"contact": "+919111111111",
12
"gstin": null,
13
"billing_address": null,
14
"shipping_address": null,
15
"customer_name": null,
16
"customer_email": "gaurav.kumar@example.com",
17
"customer_contact": "+919111111111"
18
},
19
"order_id": "order_K6g5bxSIwYIXJS",
20
"line_items": [
21
{
22
"id": "li_K6g5bwLZuBmb1Q",
23
"item_id": "item_K6g5L6X43dXjEA",
24
"ref_id": null,
25
"ref_type": null,
26
"name": "Cloth",
27
"description": "Cotton Cloth",
28
"amount": 1200,
29
"unit_amount": 1200,
30
"gross_amount": 1200,
31
"tax_amount": 0,
32
"taxable_amount": 1200,
33
"net_amount": 1200,
34
"currency": "INR",
35
"type": "invoice",
36
"tax_inclusive": false,
37
"hsn_code": null,
38
"sac_code": null,
39
"tax_rate": null,
40
"unit": null,
41
"quantity": 1,
42
"taxes": []
43
}
44
],
45
"payment_id": null,
46
"status": "issued",
47
"expire_by": null,
48
"issued_at": 1660734398,
49
"paid_at": null,
50
"cancelled_at": null,
51
"expired_at": null,
52
"sms_status": "pending",
53
"email_status": "pending",
54
"date": 1760714528,
55
"terms": null,
56
"partial_payment": false,
57
"gross_amount": 1200,
58
"tax_amount": 0,
59
"taxable_amount": 1200,
60
"amount": 1200,
61
"amount_paid": 0,
62
"amount_due": 1200,
63
"currency": "INR",
64
"currency_symbol": "₹",
65
"description": null,
66
"notes": [],
67
"comment": null,
68
"short_url": "https://rzp.io/i/ksYThDL",
69
"view_less": true,
70
"billing_start": null,
71
"billing_end": null,
72
"type": "invoice",
73
"group_taxes_discounts": false,
74
"created_at": 1660734398
75
}
Request Parameters
type

*

string

Indicates the type of entity. Here, it is invoice.

description
string

A brief description of the invoice.

draft
string

Invoice is created in draft state when value is set to 1.

customer_id

*

string

You can pass the customer_id in this field, if you are using the

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

customer
object

Customer details.

Show child parameters (5)

line_items
object

Details of the line item that is billed in the invoice. Maximum of 50 line items.

Show child parameters (6)

expire_by
integer

Timestamp, in Unix format, at which the invoice will expire.

sms_notify
boolean

Defines who handles the SMS notification. Possible values:

  • 0: You send the notification to the customer.
  • 1 (default): Razorpay sends the notification to the customer.

email_notify
boolean

Defines who handles the email notification. Possible values:

  • 0: You send the notification to the customer.
  • 1 (default): Razorpay sends the notification to the customer.

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.

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

notes
string

Any custom notes added to the invoice. Maximum of 2048 characters.

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 ₹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

The API <key/secret> provided is invalid.

Error Status: 4xx

The API key or secret are not entered or an invalid API key is used.

Solution

customer is required.

Error Status: 400

An invoice is issued without adding customer details.

Solution

the merchant doesn't have international activated.

Error Status: 400

The line_items object has an international currency set. For example, USD, is not enabled for your account.

Solution

Currency of all items should be the same as of the invoice.

Error Status: 400

There is a difference in currency entered between line_items and invoice currency.

Solution

expire_by should be at least 15 minutes after current time.

Error Status: 400

The expiry date is before or within 15 minutes of the current time

Solution

line_items is required.

Error Status: 400

A mandatory field is empty.

Solution

Create an Invoice With Customer ID

POST
/v1/invoices

Click to copy

Use this endpoint to create an invoice by passing the customer_id.

Handy Tips

You cannot create GST compliant invoices using APIs. This means you cannot add the following to the invoice when creating an invoice via APIs:

  • tax rate
  • cess
  • HSN code
  • SAC code

Is this page helpful?

Request Parameters
type

*

string

Indicates the type of entity. Here, it is invoice.

description
string

A brief description of the invoice.

draft
string

Invoice is created in draft state when value is set to 1.

customer_id

*

string

You can pass the customer_id in this field, if you are using the

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

customer
object

Customer details.

Show child parameters (5)

line_items
object

Details of the line item that is billed in the invoice. Maximum of 50 line items.

Show child parameters (6)

expire_by
integer

Timestamp, in Unix format, at which the invoice will expire.

sms_notify
boolean

Defines who handles the SMS notification. Possible values:

  • 0: You send the notification to the customer.
  • 1 (default): Razorpay sends the notification to the customer.

email_notify
boolean

Defines who handles the email notification. Possible values:

  • 0: You send the notification to the customer.
  • 1 (default): Razorpay sends the notification to the customer.

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.

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

notes
string

Any custom notes added to the invoice. Maximum of 2048 characters.

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 ₹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

The API <key/secret> provided is invalid.

Error Status: 4xx

The API key or secret are not entered or an invalid API key is used.

Solution

customer is required.

Error Status: 400

An invoice is issued without adding customer details.

Solution

the merchant doesn't have international activated.

Error Status: 400

The line_items object has an international currency set. For example, USD, is not enabled for your account.

Solution

Currency of all items should be the same as of the invoice.

Error Status: 400

There is a difference in currency entered between line_items and invoice currency.

Solution

expire_by should be at least 15 minutes after current time.

Error Status: 400

The expiry date is before or within 15 minutes of the current time

Solution

line_items is required.

Error Status: 400

A mandatory field is empty.

Solution

Curl

change language

change language

1
curl -u <YOUR_KEY_ID>:<YOUR_KEY_SECRET>
2
-X POST https://api.razorpay.com/v1/invoices \
3
-H 'Content-type: application/json' \
4
-d '{
5
"type": "invoice",
6
"date": 1760714528,
7
"customer_id": "cust_HOQzpsovChhcpl",
8
"line_items": [
9
{
10
"item_id": "item_K6g5L6X43dXjEA"
11
}
12
]
13
}'

Success

Failure

1
{
2
"id": "inv_K6g5bviu09mXo1",
3
"entity": "invoice",
4
"receipt": null,
5
"invoice_number": null,
6
"customer_id": "cust_HOQzpsovChhcpl",
7
"customer_details": {
8
"id": "cust_HOQzpsovChhcpl",
9
"name": null,
10
"email": "gaurav.kumar@example.com",
11
"contact": "+919111111111",
12
"gstin": null,
13
"billing_address": null,
14
"shipping_address": null,
15
"customer_name": null,
16
"customer_email": "gaurav.kumar@example.com",
17
"customer_contact": "+919111111111"
18
},
19
"order_id": "order_K6g5bxSIwYIXJS",
20
"line_items": [
21
{
22
"id": "li_K6g5bwLZuBmb1Q",
23
"item_id": "item_K6g5L6X43dXjEA",
24
"ref_id": null,
25
"ref_type": null,
26
"name": "Cloth",
27
"description": "Cotton Cloth",
28
"amount": 1200,
29
"unit_amount": 1200,
30
"gross_amount": 1200,
31
"tax_amount": 0,
32
"taxable_amount": 1200,
33
"net_amount": 1200,
34
"currency": "INR",
35
"type": "invoice",
36
"tax_inclusive": false,
37
"hsn_code": null,
38
"sac_code": null,
39
"tax_rate": null,
40
"unit": null,
41
"quantity": 1,
42
"taxes": []
43
}
44
],
45
"payment_id": null,
46
"status": "issued",
47
"expire_by": null,
48
"issued_at": 1660734398,
49
"paid_at": null,
50
"cancelled_at": null,
51
"expired_at": null,
52
"sms_status": "pending",
53
"email_status": "pending",
54
"date": 1760714528,
55
"terms": null,
56
"partial_payment": false,
57
"gross_amount": 1200,
58
"tax_amount": 0,
59
"taxable_amount": 1200,
60
"amount": 1200,
61
"amount_paid": 0,
62
"amount_due": 1200,
63
"currency": "INR",
64
"currency_symbol": "₹",
65
"description": null,
66
"notes": [],
67
"comment": null,
68
"short_url": "https://rzp.io/i/ksYThDL",
69
"view_less": true,
70
"billing_start": null,
71
"billing_end": null,
72
"type": "invoice",
73
"group_taxes_discounts": false,
74
"created_at": 1660734398
75
}