API Test Keys

Create a Customer

POST
/v1/customers

Click to copy

Use this endpoint to create or add a customer with basic details such as name and contact details.

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/customers \
3
-H "Content-Type: application/json" \
4
-d '{
5
"name": "Nur Aisyah",
6
"contact": "+60748901142",
7
"email": "nur.aisyah@example.com",
8
"fail_existing": "0",
9
"notes": {
10
"notes_key_1": "Tea, Earl Grey, Hot",
11
"notes_key_2": "Tea, Earl Grey… decaf."
12
}
13
}'

Success

Failure

1
{
2
"id" : "cust_1Aa00000000004",
3
"entity": "customer",
4
"name" : "Nur Aisyah",
5
"email" : "nur.aisyah@example.com",
6
"contact" : "+60748901142",
7
"gstin": null,
8
"notes": {
9
"notes_key_1":"Tea, Earl Grey, Hot",
10
"notes_key_2":"Tea, Earl Grey… decaf."
11
},
12
"created_at ": 1234567890
13
}
Request Parameters
name
string

Customer's name. Alphanumeric value with period (.), apostrophe ('), forward slash (/), at (@) and parentheses are allowed. The name must be between 3-50 characters in length. For example, Nur Aisyah.

contact
string

The customer's phone number. A maximum length of 15 characters including country code. For example, +60748901142.

email
string

The customer's email address. A maximum length of 64 characters. For example, gaurav.kumar@example.com.

fail_existing
string

Possible values:

  • 0: If a customer with the same details already exists, fetches details of the existing customer.
  • 1 (default): If a customer with the same details already exists, throws an error.

notes
object

This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

Response Parameters
id
string

Unique identifier of the customer. For example, cust_1Aa00000000004.

entity
string

Indicates the type of entity.

name
string

Customer's name. Alphanumeric, with period (.), apostrophe ('), forward slash (/), at (@) and parentheses allowed. The name must be between 3-50 characters in length.

contact
string

The customer's phone number. A maximum length of 15 characters including country code.

email
string

The customer's email address. A maximum length of 64 characters.

notes
json object

This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

created_at
integer

UNIX timestamp, when the customer was created. For example, 1234567890.

Errors

The API <key/secret> provided is invalid.

Error Status: 4xx

The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons:

  • Different keys for test mode and live modes.
  • Expired API key.

Solution

Contact number should be at least 8 digits, including country code.

Error Status: 400

The contact number is less than 8 digits.

Solution

Create a Customer

POST
/v1/customers

Click to copy

Use this endpoint to create or add a customer with basic details such as name and contact details.

Is this page helpful?

Request Parameters
name
string

Customer's name. Alphanumeric value with period (.), apostrophe ('), forward slash (/), at (@) and parentheses are allowed. The name must be between 3-50 characters in length. For example, Nur Aisyah.

contact
string

The customer's phone number. A maximum length of 15 characters including country code. For example, +60748901142.

email
string

The customer's email address. A maximum length of 64 characters. For example, gaurav.kumar@example.com.

fail_existing
string

Possible values:

  • 0: If a customer with the same details already exists, fetches details of the existing customer.
  • 1 (default): If a customer with the same details already exists, throws an error.

notes
object

This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

Response Parameters
id
string

Unique identifier of the customer. For example, cust_1Aa00000000004.

entity
string

Indicates the type of entity.

name
string

Customer's name. Alphanumeric, with period (.), apostrophe ('), forward slash (/), at (@) and parentheses allowed. The name must be between 3-50 characters in length.

contact
string

The customer's phone number. A maximum length of 15 characters including country code.

email
string

The customer's email address. A maximum length of 64 characters.

notes
json object

This is a key-value pair that can be used to store additional information about the entity. It can hold a maximum of 15 key-value pairs, 256 characters (maximum) each. For example, "note_key": "Beam me up Scotty”.

created_at
integer

UNIX timestamp, when the customer was created. For example, 1234567890.

Errors

The API <key/secret> provided is invalid.

Error Status: 4xx

The API credentials passed in the API call differ from the ones generated on the Dashboard. Possible reasons:

  • Different keys for test mode and live modes.
  • Expired API key.

Solution

Contact number should be at least 8 digits, including country code.

Error Status: 400

The contact number is less than 8 digits.

Solution

Curl

change language

change language

1
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
2
-X POST https://api.razorpay.com/v1/customers \
3
-H "Content-Type: application/json" \
4
-d '{
5
"name": "Nur Aisyah",
6
"contact": "+60748901142",
7
"email": "nur.aisyah@example.com",
8
"fail_existing": "0",
9
"notes": {
10
"notes_key_1": "Tea, Earl Grey, Hot",
11
"notes_key_2": "Tea, Earl Grey… decaf."
12
}
13
}'

Success

Failure

1
{
2
"id" : "cust_1Aa00000000004",
3
"entity": "customer",
4
"name" : "Nur Aisyah",
5
"email" : "nur.aisyah@example.com",
6
"contact" : "+60748901142",
7
"gstin": null,
8
"notes": {
9
"notes_key_1":"Tea, Earl Grey, Hot",
10
"notes_key_2":"Tea, Earl Grey… decaf."
11
},
12
"created_at ": 1234567890
13
}