> For the complete documentation index, see [llms.txt](https://docs.swipez.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.swipez.in/customer-management.md).

# Customer management

### Guidelines <a href="#guidelines" id="guidelines"></a>

Below are some of the points you must be aware of while calling Swipez APIs:‌

* All API responses are in JSON format.
* POST requests should include `ContentType: application/json`
* All API response have **status, message,** and **data**.
* Swipez uses API keys to allow access to the API. Once you have signed up at our merchant site, you will be able to see your [AccessKey and SecretKey](https://www.swipez.in/merchant/profile/accesskey).

### Rate limiting

The API is rate limited per user. You will receive a 429 HTTP status code if you exceed the rate limit. The rate limit is 30 requests per minute per user and is subject to change.

‌

### Quick Reference <a href="#quick-reference" id="quick-reference"></a>

| URL                                                                                            | HTTP Verb | Functionality               |
| ---------------------------------------------------------------------------------------------- | --------- | --------------------------- |
| [/api/v1/merchant/customer/save](https://docs.swipez.in/customer-management#create-customer)   | POST      | To create customers.        |
| [/api/v1/merchant/customer/update](https://docs.swipez.in/customer-management#update-customer) | POST      | To update created customer. |
| [/api/v1/merchant/customer/detail](https://docs.swipez.in/customer-management#customer-detail) | POST      | To get customer details.    |
| [/api/v1/merchant/customer/getlist](https://docs.swipez.in/customer-management#customer-list)  | POST      | To get customer list.       |

## Create customer

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/customer/save`

This endpoint allows you to add your customers.\
\
**Download customer format JSON with below steps.** \
1\. Go to customer structure <https://www.swipez.in/merchant/customer/structure> \
2\. Click on "Download JSON" button. \
3\. Choose "Save Customer V1" option.

#### Request Body

| Name                | Type   | Description                     |
| ------------------- | ------ | ------------------------------- |
| access\_key\_id     | string | Your access key.                |
| secret\_access\_key | string | Your secret key.                |
| customer\_code      | string | Your customer unique identifier |
| customer\_name      | string | Customer name                   |
| email               | string | Customer email id.              |
| mobile              | string | Customer mobile number.         |
| address             | string | Customer address.               |
| city                | string | Customer city.                  |
| state               | string | Customer state.                 |
| zipcode             | string | Customer pincode                |
| custom\_fields      | array  | Customer custom column value    |

{% tabs %}
{% tab title="200 Customer saved successfully" %}

```
{
    "reqtime": "2021-03-02 11:34:24",
    "resptime": "2021-03-02 11:34:25",
    "srvrsp": [
        [
            {
                "customer_id": "13059",
                "customer_code": "C000360",
                "customer_name": "Test Customer",
                "email": "user@swipez.in"
            }
        ]
    ],
    "errcode": 0,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```

curl --location --request POST '<BASE URL>/api/v1/merchant/customer/save' \
--header 'Content-Type: application/json' \
--data-raw '{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"customer": [
		{
			"customer_code": "Cust-254",
			"customer_name": "Rohit Sharma",
			"email": "user@swipez.in",
			"mobile": "9999999999",
			"address": "Behala Manton Super Market, Room 43, Behala",
			"city": "Kolkata",
			"state": " West Bengal",
			"zipcode": "700034",
			"custom_fields": [
				{
					"id": "4839",
					"name": "Customer GSTN",
					"type": "gst",
					"value": "33BRSPP2039T1ZU"
				},
				{
					"id": "4840",
					"name": "Company Name",
					"type": "company_name",
					"value": "Swipez"
				}
			]
		}
	]
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/customer/save',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"customer": [
		{
			"customer_code": "Cust-254",
			"customer_name": "Rohit Sharma",
			"email": "user@swipez.in",
			"mobile": "9999999999",
			"address": "Behala Manton Super Market, Room 43, Behala",
			"city": "Kolkata",
			"state": "West Bengal",
			"zipcode": "700034",
			"custom_fields": [
				{
					"id": "4839",
					"name": "Customer GSTN",
					"type": "gst",
					"value": "33BRSPP2039T1ZU"
				}
			]
		}
	]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Cookie: __cfduid=d4b581ca97b6435b558bd41f9610f82b51614605091; PHPSESSID=h0md9koeohb4t9tpseem501oua'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

## Update customer

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/customer/update`

This endpoint allows you to update your customer data.\
\
**Download customer format JSON with below steps.** \
1\. Go to customer structure <https://www.swipez.in/merchant/customer/structure> \
2\. Click on "Download JSON" button. \
3\. Choose "Update Customer V1" option.

#### Request Body

| Name                | Type    | Description                   |
| ------------------- | ------- | ----------------------------- |
| access\_key\_id     | string  | Your access key               |
| secret\_access\_key | string  | Your secret key.              |
| customer\_id        | integer | System generated customer id. |
| customer\_code      | string  | Customer unique identifier.   |
| customer\_name      | string  | Customer name.                |
| email               | string  | Customer email id.            |
| mobile              | string  | Customer mobile number.       |
| address             | string  | Customer address.             |
| city                | string  | Customer city.                |
| state               | string  | Customer state.               |
| zipcode             | string  | Customer zipcode.             |
| custom\_fields      | string  | Customer custom column value. |

{% tabs %}
{% tab title="200 Customer updated successfully." %}

```
{
    "reqtime": "2021-03-02 11:34:24",
    "resptime": "2021-03-02 11:34:25",
    "srvrsp": [
        [
            {
                "customer_id": "13059",
                "customer_code": "C000360",
                "customer_name": "Test Customer",
                "email": "user@swipez.in"
            }
        ]
    ],
    "errcode": 0,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```

curl --location --request POST '<BASE URL>/api/v1/merchant/customer/update' \
--header 'Content-Type: application/json' \
--data-raw '{
"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
"customer": [
		{
			"customer_id": "125484",
			"customer_code": "Cust-254",
			"customer_name": "Rohit Sharma",
			"email": "user@swipez.in",
			"mobile": "9999999999",
			"address": "Behala Manton Super Market, Room 43, Behala",
			"city": "Kolkata",
			"state": " West Bengal",
			"zipcode": "700034",
			"custom_fields": [
				{
					"id": "4839",
					"name": "Customer GSTN",
					"type": "gst",
					"value": "33BRSPP2039T1ZU"
				},
				{
					"id": "4840",
					"name": "Company Name",
					"type": "company_name",
					"value": "Swipez"
				}
			]
		}
	]
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/customer/update',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"customer": [
		{
			"customer_id": "125484",
			"customer_code": "Cust-254",
			"customer_name": "Rohit Sharma",
			"email": "user@swipez.in",
			"mobile": "9999999999",
			"address": "Behala Manton Super Market, Room 43, Behala",
			"city": "Kolkata",
			"state": "West Bengal",
			"zipcode": "700034",
			"custom_fields": [
				{
					"id": "4839",
					"name": "Customer GSTN",
					"type": "gst",
					"value": "33BRSPP2039T1ZU"
				}
			]
		}
	]
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Cookie: __cfduid=d4b581ca97b6435b558bd41f9610f82b51614605091; PHPSESSID=h0md9koeohb4t9tpseem501oua'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

## Customer list

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/customer/getlist`

This endpoint allows you to get list of invoices.

#### Request Body

| Name                | Type   | Description                                                                       |
| ------------------- | ------ | --------------------------------------------------------------------------------- |
| access\_key\_id     | string | Your access key.                                                                  |
| secret\_access\_key | string | Your secret key.                                                                  |
| searchby            | string | Filter by type (customer\_code, name, email, mobile, city, state, zipcode, group) |
| keyword             | string | Filter keyword.                                                                   |

{% tabs %}
{% tab title="200 Customers successfully retrieved." %}

```
{
    "reqtime": "2021-03-02 10:09:15",
    "resptime": "2021-03-02 10:09:15",
    "total_records": 2,
    "srvrsp": [
        {
            "invoice_id": "R000029148",
            "invoice_number": null,
            "bill_date": "2021-03-01",
            "due_date": "2021-03-01",
            "sent_date": "2021-03-01 18:59:41",
            "customer_code": "12121",
            "customer_name": "Rohit Sharma ",
            "customer_group": "All,Cricket",
            "email": "rohit@swipez.in",
            "mobile": "9999999999",
            "address": "26/2, Herms paras, near Joggers park,Kalyani nagar",
            "city": "Mumbai",
            "state": "Maharashtra",
            "zipcode": "400214",
            "amount": "590.00",
            "paid_amount": "0.00",
            "status": "Paid offline",
            "cycle_name": "Test",
            "franchise_id": "0",
            "franchise_name": null,
            "created_by": "Test company"
        },
        {
            "invoice_id": "R000029147",
            "invoice_number": "INV655",
            "bill_date": "2021-02-15",
            "due_date": "2021-02-15",
            "sent_date": "2021-02-15 16:36:01",
            "customer_code": "C000359",
            "customer_name": "Virat Kohli",
            "customer_group": "All",
            "email": "virat@swipez.in",
            "mobile": "9999999998",
            "address": "",
            "city": "Delhi",
            "state": "Delhi",
            "zipcode": "400014",
            "amount": "826.00",
            "paid_amount": "0.00",
            "status": "Paid offline",
            "cycle_name": "Test Fee",
            "franchise_id": "0",
            "franchise_name": null,
            "created_by": "Test company"
        }
        
    ],
    "errcode": null,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```
curl --location --request POST '<BASE URL>/api/v1/merchant/customer/getlist' \
--header 'Content-Type: application/json' \
--data-raw '{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"searchby": "state",
	"keyword": "maharashtra"
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/customer/getlist',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"searchby": "state",
	"keyword": "maharashtra"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}

## Customer detail

<mark style="color:green;">`POST`</mark> `/api/v1/merchant/customer/detail`

This endpoint allows you to get detail of customer.

#### Request Body

| Name                | Type   | Description      |
| ------------------- | ------ | ---------------- |
| access\_key\_id     | string | Your access key. |
| secret\_access\_key | string | Your secret key. |
| customer\_code      | string | Customer code    |

{% tabs %}
{% tab title="200 " %}

```
{
    "reqtime": "2021-03-02 10:09:15",
    "resptime": "2021-03-02 10:09:15",
    "total_records": 2,
    "srvrsp": [
        {
            "invoice_id": "R000029148",
            "invoice_number": null,
            "bill_date": "2021-03-01",
            "due_date": "2021-03-01",
            "sent_date": "2021-03-01 18:59:41",
            "customer_code": "12121",
            "customer_name": "Rohit Sharma ",
            "customer_group": "All,Cricket",
            "email": "rohit@swipez.in",
            "mobile": "9999999999",
            "address": "26/2, Herms paras, near Joggers park,Kalyani nagar",
            "city": "Mumbai",
            "state": "Maharashtra",
            "zipcode": "400214",
            "amount": "590.00",
            "paid_amount": "0.00",
            "status": "Paid offline",
            "cycle_name": "Test",
            "franchise_id": "0",
            "franchise_name": null,
            "created_by": "Test company"
        },
        {
            "invoice_id": "R000029147",
            "invoice_number": "INV655",
            "bill_date": "2021-02-15",
            "due_date": "2021-02-15",
            "sent_date": "2021-02-15 16:36:01",
            "customer_code": "C000359",
            "customer_name": "Virat Kohli",
            "customer_group": "All",
            "email": "virat@swipez.in",
            "mobile": "9999999998",
            "address": "",
            "city": "Delhi",
            "state": "Delhi",
            "zipcode": "400014",
            "amount": "826.00",
            "paid_amount": "0.00",
            "status": "Paid offline",
            "cycle_name": "Test Fee",
            "franchise_id": "0",
            "franchise_name": null,
            "created_by": "Test company"
        }
        
    ],
    "errcode": null,
    "errmsg": "",
    "errlist": null
}
```

{% endtab %}
{% endtabs %}

#### Sample code

{% tabs %}
{% tab title="CURL" %}

```
curl --location --request POST '<BASE URL>/api/v1/merchant/customer/detail' \
--header 'Content-Type: application/json' \
--data-raw '{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"customer_code": "cust-1"
"
}'
```

{% endtab %}

{% tab title="PHP" %}

```

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => '<BASE URL>/api/v1/merchant/customer/detail',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
	"access_key_id": "<GET ACCESS KEY ID FROM YOUR ACCOUNT>",
	"secret_access_key": "<GET SECRET ACCESS KEY FROM YOUR ACCOUNT>",
	"customer_code": "cust-1"
}',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
```

{% endtab %}
{% endtabs %}
