API Test Keys

Create an Invoice With Customer Details

POST
/v1/invoices

Click to copy

Use this endpoint to create an invoice using details such as name, billing_address and shipping_address.

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
"description": "Invoice for the month of January 2020",
7
"partial_payment": true,
8
"customer": {
9
"name": "Gaurav Kumar",
10
"contact": "+919876543210",
11
"email": "gaurav.kumar@example.com",
12
"billing_address": {
13
"line1": "Bakers Street",
14
"line2": "Country Road",
15
"zipcode": "560068",
16
"city": "Bengaluru",
17
"state": "Karnataka",
18
"country": "in"
19
},
20
"shipping_address": {
21
"line1": "Bakers Street",
22
"line2": "Country Road",
23
"zipcode": "560068",
24
"city": "Bengaluru",
25
"state": "Karnataka",
26
"country": "IN"
27
}
28
},
29
"line_items": [
30
{
31
"name": "Master Cloud Computing in 30 Days",
32
"description": "Book by Ravena Ravenclaw",
33
"amount": 399,
34
"currency": "",
35
"quantity": 1
36
}
37
],
38
"sms_notify": true,
39
"email_notify": false,
40
"currency": "",
41
"expire_by": 1589765167,
42
"notes": {
43
"key1": "Testing."
44
}
45
}'

Success

Failure

1
{
2
"id": "inv_E7q0tqkxBRzdau",
3
"entity": "invoice",
4
"receipt": null,
5
"invoice_number": null,
6
"customer_id": "cust_E7q0trFqXgExmT",
7
"customer_details": {
8
"id": "cust_E7q0trFqXgExmT",
9
"name": "Gaurav Kumar",
10
"email": "gaurav.kumar@example.com",
11
"contact": "+919876543210",
12
"gstin": null,
13
"billing_address": {
14
"id": "addr_E7q0ttqh4SGhAC",
15
"type": "billing_address",
16
"primary": true,
17
"line1": "Bakers Street",
18
"line2": "Country Road",
19
"zipcode": "560068",
20
"city": "Bengaluru",
21
"state": "Karnataka",
22
"country": "in"
23
},
24
"shipping_address": {
25
"id": "addr_E7q0ttKwVA1h2V",
26
"type": "shipping_address",
27
"primary": true,
28
"line1": "Bakers Street",
29
"line2": "Country Road",
30
"zipcode": "560068",
31
"city": "Bengaluru",
32
"state": "Karnataka",
33
"country": "in"
34
},
35
"customer_name": "Gaurav Kumar",
36
"customer_email": "gaurav.kumar@example.com",
37
"customer_contact": "+919876543210"
38
},
39
"order_id": "order_E7q0tvRpC0WJwg",
40
"line_items": [
41
{
42
"id": "li_E7q0tuPNg84VbZ",
43
"item_id": null,
44
"ref_id": null,
45
"ref_type": null,
46
"name": "Master Cloud Computing in 30 Days",
47
"description": "Book by Ravena Ravenclaw",
48
"amount": 399,
49
"unit_amount": 399,
50
"gross_amount": 399,
51
"tax_amount": 0,
52
"taxable_amount": 399,
53
"net_amount": 399,
54
"currency": "",
55
"type": "invoice",
56
"tax_inclusive": false,
57
"hsn_code": null,
58
"sac_code": null,
59
"tax_rate": null,
60
"unit": null,
61
"quantity": 1,
62
"taxes": []
63
}
64
],
65
"payment_id": null,
66
"status": "issued",
67
"expire_by": 1589765167,
68
"issued_at": 1579765167,
69
"paid_at": null,
70
"cancelled_at": null,
71
"expired_at": null,
72
"sms_status": "pending",
73
"email_status": "pending",
74
"date": 1579765167,
75
"terms": null,
76
"partial_payment": true,
77
"gross_amount": 399,
78
"tax_amount": 0,
79
"taxable_amount": 399,
80
"amount": 399,
81
"amount_paid": 0,
82
"amount_due": 399,
83
"currency": "",
84
"currency_symbol": "$",
85
"description": "Invoice for the month of January 2020",
86
"notes": [],
87
"comment": null,
88
"short_url": "https://rzp.io/i/2wxV8Xs",
89
"view_less": true,
90
"billing_start": null,
91
"billing_end": null,
92
"type": "invoice",
93
"group_taxes_discounts": false,
94
"created_at": 1579765167
95
}
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:

  • true (default): Razorpay sends the notification to the customer.
  • false: You send the notification to the customer.

email_notify
boolean

Defines who handles the email notification. Possible values:

  • true (default): Razorpay sends the notification to the customer.
  • false: You send 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, 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. ref_num : string A unique reference number for the invoice, used for internal tracking and reconciliation.

receipt
string

A unique receipt number that you can provide for the invoice, for your internal reference.

currency_symbol
string

For example, ₹.

billing_end
integer

Unix timestamp marking the end of the billing period for the invoice.

gross_amount
integer

The gross amount for this invoice, in the smallest currency unit (paise for INR). For example, 50000.

billing_start
integer

Unix timestamp marking the start of the billing period for the invoice.

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

Not a valid type.

Error Status: 400

The value passed for type is not one of the supported types. The API echoes the rejected value, for example Not a valid type: invoiceee.

Solution

The amount must be at least INR 1.00.

Error Status: 400

A line-item amount is below the per-currency minimum (100 paise / ₹1.00 for INR). Also returned for zero or negative line-item amounts.

Solution

The amount must be an integer.

Error Status: 400

A non-integer value (for example a decimal like 100.5 or a string like "abc") was passed for a line_items[].amount.

Solution

The quantity must be at least 1.

Error Status: 400

A line-item quantity was passed as 0 or a negative value.

Solution

The email must be a valid email address.

Error Status: 400

The value passed for customer.email is not in a valid email format.

Solution

Contact number contains invalid characters, only digits and + symbol are allowed.

Error Status: 400

The customer.contact value contains characters other than digits and the + symbol.

Solution

The partial payment field must be true or false.

Error Status: 400

A non-boolean value was passed for partial_payment.

Solution

{any extra field} is/are not required and should not be sent.

Error Status: 400

The request body contains fields that are not part of the Invoices API schema.

Solution

Invoices disabled because fee bearer is customer.

Error Status: 400

Your account has the customer fee bearer model enabled, which is not compatible with invoice creation.

Solution

Item cannot be used as it is inactive.

Error Status: 400

A line_items[].item_id passed in the request refers to an item that has been marked inactive.

Solution

The merchant doesn't have international activated.

Error Status: 400

The currency passed is different from your account's default currency, but international payments are not enabled on your account.

Solution

Currency is not supported.

Error Status: 400

The currency value is not a recognised ISO-4217 currency code or is outside the list supported by Razorpay.

Solution

Invoice amount exceeds maximum payment amount allowed.

Error Status: 400

The total invoice amount (sum of line_items[].amount * quantity) exceeds the per-payment maximum configured for your account.

Solution

expire_by should be at least 15 minutes after current time.

Error Status: 400

The expire_by value is in the past or less than 15 minutes from the current server time.

Solution

Request failed. Please try after sometime.

Error Status: 429

You have exceeded the daily rate limit for invoice creation. This per-day rate limit applies to test-mode accounts and unregistered live-mode accounts. In test mode the limit is 300 invoices/day; in live mode for unregistered businesses it is 10,000 invoices/day. Registered live-mode accounts are not subject to this limit.

Solution

Create an Invoice With Customer Details

POST
/v1/invoices

Click to copy

Use this endpoint to create an invoice using details such as name, billing_address and shipping_address.

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:

  • true (default): Razorpay sends the notification to the customer.
  • false: You send the notification to the customer.

email_notify
boolean

Defines who handles the email notification. Possible values:

  • true (default): Razorpay sends the notification to the customer.
  • false: You send 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, 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. ref_num : string A unique reference number for the invoice, used for internal tracking and reconciliation.

receipt
string

A unique receipt number that you can provide for the invoice, for your internal reference.

currency_symbol
string

For example, ₹.

billing_end
integer

Unix timestamp marking the end of the billing period for the invoice.

gross_amount
integer

The gross amount for this invoice, in the smallest currency unit (paise for INR). For example, 50000.

billing_start
integer

Unix timestamp marking the start of the billing period for the invoice.

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

Not a valid type.

Error Status: 400

The value passed for type is not one of the supported types. The API echoes the rejected value, for example Not a valid type: invoiceee.

Solution

The amount must be at least INR 1.00.

Error Status: 400

A line-item amount is below the per-currency minimum (100 paise / ₹1.00 for INR). Also returned for zero or negative line-item amounts.

Solution

The amount must be an integer.

Error Status: 400

A non-integer value (for example a decimal like 100.5 or a string like "abc") was passed for a line_items[].amount.

Solution

The quantity must be at least 1.

Error Status: 400

A line-item quantity was passed as 0 or a negative value.

Solution

The email must be a valid email address.

Error Status: 400

The value passed for customer.email is not in a valid email format.

Solution

Contact number contains invalid characters, only digits and + symbol are allowed.

Error Status: 400

The customer.contact value contains characters other than digits and the + symbol.

Solution

The partial payment field must be true or false.

Error Status: 400

A non-boolean value was passed for partial_payment.

Solution

{any extra field} is/are not required and should not be sent.

Error Status: 400

The request body contains fields that are not part of the Invoices API schema.

Solution

Invoices disabled because fee bearer is customer.

Error Status: 400

Your account has the customer fee bearer model enabled, which is not compatible with invoice creation.

Solution

Item cannot be used as it is inactive.

Error Status: 400

A line_items[].item_id passed in the request refers to an item that has been marked inactive.

Solution

The merchant doesn't have international activated.

Error Status: 400

The currency passed is different from your account's default currency, but international payments are not enabled on your account.

Solution

Currency is not supported.

Error Status: 400

The currency value is not a recognised ISO-4217 currency code or is outside the list supported by Razorpay.

Solution

Invoice amount exceeds maximum payment amount allowed.

Error Status: 400

The total invoice amount (sum of line_items[].amount * quantity) exceeds the per-payment maximum configured for your account.

Solution

expire_by should be at least 15 minutes after current time.

Error Status: 400

The expire_by value is in the past or less than 15 minutes from the current server time.

Solution

Request failed. Please try after sometime.

Error Status: 429

You have exceeded the daily rate limit for invoice creation. This per-day rate limit applies to test-mode accounts and unregistered live-mode accounts. In test mode the limit is 300 invoices/day; in live mode for unregistered businesses it is 10,000 invoices/day. Registered live-mode accounts are not subject to this limit.

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
"description": "Invoice for the month of January 2020",
7
"partial_payment": true,
8
"customer": {
9
"name": "Gaurav Kumar",
10
"contact": "+919876543210",
11
"email": "gaurav.kumar@example.com",
12
"billing_address": {
13
"line1": "Bakers Street",
14
"line2": "Country Road",
15
"zipcode": "560068",
16
"city": "Bengaluru",
17
"state": "Karnataka",
18
"country": "in"
19
},
20
"shipping_address": {
21
"line1": "Bakers Street",
22
"line2": "Country Road",
23
"zipcode": "560068",
24
"city": "Bengaluru",
25
"state": "Karnataka",
26
"country": "IN"
27
}
28
},
29
"line_items": [
30
{
31
"name": "Master Cloud Computing in 30 Days",
32
"description": "Book by Ravena Ravenclaw",
33
"amount": 399,
34
"currency": "",
35
"quantity": 1
36
}
37
],
38
"sms_notify": true,
39
"email_notify": false,
40
"currency": "",
41
"expire_by": 1589765167,
42
"notes": {
43
"key1": "Testing."
44
}
45
}'

Success

Failure

1
{
2
"id": "inv_E7q0tqkxBRzdau",
3
"entity": "invoice",
4
"receipt": null,
5
"invoice_number": null,
6
"customer_id": "cust_E7q0trFqXgExmT",
7
"customer_details": {
8
"id": "cust_E7q0trFqXgExmT",
9
"name": "Gaurav Kumar",
10
"email": "gaurav.kumar@example.com",
11
"contact": "+919876543210",
12
"gstin": null,
13
"billing_address": {
14
"id": "addr_E7q0ttqh4SGhAC",
15
"type": "billing_address",
16
"primary": true,
17
"line1": "Bakers Street",
18
"line2": "Country Road",
19
"zipcode": "560068",
20
"city": "Bengaluru",
21
"state": "Karnataka",
22
"country": "in"
23
},
24
"shipping_address": {
25
"id": "addr_E7q0ttKwVA1h2V",
26
"type": "shipping_address",
27
"primary": true,
28
"line1": "Bakers Street",
29
"line2": "Country Road",
30
"zipcode": "560068",
31
"city": "Bengaluru",
32
"state": "Karnataka",
33
"country": "in"
34
},
35
"customer_name": "Gaurav Kumar",
36
"customer_email": "gaurav.kumar@example.com",
37
"customer_contact": "+919876543210"
38
},
39
"order_id": "order_E7q0tvRpC0WJwg",
40
"line_items": [
41
{
42
"id": "li_E7q0tuPNg84VbZ",
43
"item_id": null,
44
"ref_id": null,
45
"ref_type": null,
46
"name": "Master Cloud Computing in 30 Days",
47
"description": "Book by Ravena Ravenclaw",
48
"amount": 399,
49
"unit_amount": 399,
50
"gross_amount": 399,
51
"tax_amount": 0,
52
"taxable_amount": 399,
53
"net_amount": 399,
54
"currency": "",
55
"type": "invoice",
56
"tax_inclusive": false,
57
"hsn_code": null,
58
"sac_code": null,
59
"tax_rate": null,
60
"unit": null,
61
"quantity": 1,
62
"taxes": []
63
}
64
],
65
"payment_id": null,
66
"status": "issued",
67
"expire_by": 1589765167,
68
"issued_at": 1579765167,
69
"paid_at": null,
70
"cancelled_at": null,
71
"expired_at": null,
72
"sms_status": "pending",
73
"email_status": "pending",
74
"date": 1579765167,
75
"terms": null,
76
"partial_payment": true,
77
"gross_amount": 399,
78
"tax_amount": 0,
79
"taxable_amount": 399,
80
"amount": 399,
81
"amount_paid": 0,
82
"amount_due": 399,
83
"currency": "",
84
"currency_symbol": "$",
85
"description": "Invoice for the month of January 2020",
86
"notes": [],
87
"comment": null,
88
"short_url": "https://rzp.io/i/2wxV8Xs",
89
"view_less": true,
90
"billing_start": null,
91
"billing_end": null,
92
"type": "invoice",
93
"group_taxes_discounts": false,
94
"created_at": 1579765167
95
}