Customer API's

The Razorpay Customer API allows you to create, retrieve, update, and manage customer profiles. A customer object typically stores details such as name, email, contact number, and any notes for identification or segmentation.

Using this API, you can associate customers with multiple payments or subscriptions, making it easier to track their activity and payment history. It's particularly useful for businesses with recurring billing models or when storing customer data for future transactions.

End Points

Method Endpoint
POST /customer/create
GET /customer/get
GET /customer/get?id=
PUT /customer/update?id=

Create a Customer

The Create Customer endpoint (POST /customer/create) allows you to register a new customer by providing essential information such as their name, contact number, email address, and any additional notes. This customer object can later be associated with orders, payments, and subscriptions.

Creating a customer record ensures easier tracking of user transactions and provides a better user experience, especially in recurring billing or when storing user preferences. The backend automatically assigns a unique customer_id to each newly created customer.

Arguments
name string (optional)

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, Gaurav Kumar.

contact string (optional)

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

email string (optional)

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

fail_existing string (optional)

Possible values: 1 (default) - throws an error if a customer with the same details already exists, 0 - fetches existing customer details instead of throwing an error.

gstin string (optional)

Customer's GST number, if available. For example, 29XAbbA4369J1PA.

notes object (optional)

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

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.customer.create(data);

curl --request POST \
  --url https://www.cloudlesspayment.com/api/customer/create \
  --header 'x-api-key: Your-API-key' \
  --header 'Content-Type: application/json' \
  --data '{
    "name": "Kumar",
    "contact": "909090909090",
    "email": "kumar@gmail.com",
    "fail_existing": false,
    "notes": {
        "notes_key_1": "Tea, Earl Grey, Hot",
        "notes_key_2": "Tea, Earl Grey… decaf."
    }
}'
Body Parameters

{
    "name": "Kumar",
    "contact": "909090909090",
    "email": "kumar@gmail.com",
    "fail_existing": false,
    "notes": {
        "notes_key_1": "Tea, Earl Grey, Hot",
        "notes_key_2": "Tea, Earl Grey… decaf."
    }
}
                                        
Response Example

 {
    "data": {
        "message": "Razorpay logic executed successfully",
        "result": {
            "action": "create",
            "data": {
                "contact": "909090909090",
                "created_at": 1753156234,
                "email": "kumar@gmail.com",
                "entity": "customer",
                "gstin": null,
                "id": "cust_QvyFrutz4UBEbh",
                "name": "Kumar",
                "notes": {
                    "notes_key_1": "Tea, Earl Grey, Hot",
                    "notes_key_2": "Tea, Earl Grey… decaf."
                },
                "shipping_address": []
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}
                                        

Get All Customer(s)

The Get All Customers endpoint (GET /customer/get) is used to retrieve a complete list of customers created via your Razorpay integration. This can be helpful for displaying a customer database, managing user profiles, or analyzing customer-related metrics. The API typically returns customer details such as name, contact, email, and associated notes. You can extend this API with filters such as date range, contact number, or email to narrow down the results as per your requirements.

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.customer.fetchAll();

curl --request GET \
  --url https://www.cloudlesspayment.com/api/customer/get \
  --header 'x-api-key: Your-API-key'
Response Example

{
    "data": {
        "message": "Razorpay GET logic executed successfully",
        "result": {
            "action": "fetch",
            "data": {
                "count": 12,
                "entity": "collection",
                "items": [
                    {
                        "contact": "909090909090",
                        "created_at": 1753156234,
                        "email": "kumar@gmail.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QvyFrutz4UBEbh",
                        "name": "Kumar",
                        "notes": {
                            "notes_key_1": "Tea, Earl Grey, Hot",
                            "notes_key_2": "Tea, Earl Grey… decaf."
                        },
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1752642165,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QtcHP0aKocPEnV",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1752642155,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QtcHDaX8HeYewh",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1752642087,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QtcG1LIDYomThG",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1752057310,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QqwChNB2oXItYN",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1751632854,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QozfuIPR7GBDGL",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1751458501,
                        "email": null,
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_QoCAKPo4HV2uu4",
                        "name": null,
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": "909090909090",
                        "created_at": 1751007336,
                        "email": "jai@gmail.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_Qm83J5TbUyGKvK",
                        "name": "jai surya",
                        "notes": {
                            "notes_key_1": "Tea, Earl Grey, Hot",
                            "notes_key_2": "Tea, Earl Grey… decaf."
                        },
                        "shipping_address": []
                    },
                    {
                        "contact": "909090909090",
                        "created_at": 1751002600,
                        "email": "gaurav.kumar@example.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_Qm6hw3uQqLJYod",
                        "name": "GauravKumar",
                        "notes": {
                            "notes_key_1": "Tea, Earl Grey, Hot",
                            "notes_key_2": "Tea, Earl Grey… decaf."
                        },
                        "shipping_address": []
                    },
                    {
                        "contact": "07695978704",
                        "created_at": 1734867996,
                        "email": "sriakash149@gmail.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_PaD7BHT2ihZOSm",
                        "name": "Mcube Infotech",
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": null,
                        "created_at": 1732030259,
                        "email": "sriakash149@gmail.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_PNDJEJOwDrnZgC",
                        "name": "Akash",
                        "notes": [],
                        "shipping_address": []
                    },
                    {
                        "contact": "9080709099",
                        "created_at": 1731497731,
                        "email": "akashbhai@example.com",
                        "entity": "customer",
                        "gstin": null,
                        "id": "cust_PKm5m7fGK1DteI",
                        "name": "akashramaswamy",
                        "notes": [],
                        "shipping_address": []
                    }
                ]
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}
                                        

Get a Specific Customer

The Get Customer by ID endpoint (GET /customer/get/<id>) allows you to fetch the details of a specific customer using their unique customer ID. This API is useful when you need to display or manage the profile of a single customer, including their name, contact information, email, notes, and any associated metadata. The customer ID must be provided as a path parameter to retrieve the corresponding customer record from the system.

Arguments
id string (Required)

Unique identifier of the customer to retrieve. Must match an existing customer created earlier.

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.customer.fetchById(customerId);

curl --request GET \
  --url https://www.cloudlesspayment.com/api/customer/get?id=customerId \
  --header 'x-api-key: Your-API-key'
Response Example

{
    "data": {
        "message": "Razorpay GET logic executed successfully",
        "result": {
            "action": "fetch",
            "data": {
                "contact": "909090909090",
                "created_at": 1753156234,
                "email": "kumar@gmail.com",
                "entity": "customer",
                "gstin": null,
                "id": "cust_QvyFrutz4UBEbh",
                "name": "Kumar",
                "notes": {
                    "notes_key_1": "Tea, Earl Grey, Hot",
                    "notes_key_2": "Tea, Earl Grey… decaf."
                },
                "shipping_address": []
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}
                                        

Update a Customer

The Update Customer endpoint (PUT /customer/update) is used to modify an existing customer's details by providing their unique customer ID along with the updated fields. This API enables changes to customer-specific information such as name, contact number, email address, and custom notes. The customer_id must be supplied either as a path parameter or within the request body to identify the customer that needs to be updated.

Arguments
id string (Required)

Unique ID of the customer to update. Must reference an existing customer in the system.

name string (Optional)

Full name of the customer. Useful for personalization and record-keeping.

email string (Optional)

Email address of the customer. Must be a valid email format.

contact string (Optional)

Customer's mobile number in international format. Required for SMS notifications or verification purposes.

Request Example

const cloudlesspay = new CloudlessPayment({ key: "Your-API-key" });
const response = await cloudlesspay.customer.updateById(customerId, data);

curl --request PUT \
  --url https://www.cloudlesspayment.com/api/customer/update?id=customerId \
  --header 'x-api-key: Your-API-key' \
  --header 'Content-Type: application/json' \
  --data '{  
    "contact": "9080709099",
    "email": "akashbhai@example.com",
    "name": "akashramaswamy"
 }'
Body Parameters

{  
   "contact": "9080709099",
   "email": "akashbhai@example.com",
   "name": "akashramaswamy"
}
                                        
Response Example

{
    "data": {
        "message": "Razorpay logic executed successfully",
        "result": {
            "action": "edit",
            "data": {
                "contact": "9080709099",
                "created_at": 1731497731,
                "email": "akashbhai@example.com",
                "entity": "customer",
                "gstin": null,
                "id": "cust_PKm5m7fGK1DteI",
                "name": "akashramaswamy",
                "notes": [],
                "shipping_address": []
            },
            "vendor": "razorpay"
        },
        "vendor": "razorpay"
    },
    "status": "success"
}