# Pull Customer API by Date Range

## Pull Customer.

<mark style="color:green;">`POST`</mark> [https://\<sub domain>.kapturecrm.com/select-customer-between-start-and-end-dates.html](<https://devapi.kapturecrm.com/select-customer-between-start-and-end-dates.html&#xD;&#xA;>)

{% hint style="info" %}

```
NOTE: Please replace with your sub domain name in the API.
```

{% endhint %}

### Authentication:

To access this API endpoint, you need to include your API key in the request headers. For authentication, use the following header:

```
Basic <Your Token>
```

### Request Body

The request body should be a JSON object containing the details of the customer to be fetched. Here are the  list of parameters.\
\
\
Note: Either of kapture\_customer\_id,email\_id or phone is mandatory to fetch data.

<table><thead><tr><th>Name</th><th width="125">Mandatory</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>createStartDate</td><td>Yes</td><td>Date</td><td>Date should be in YYYY-MM-DD format. Also at one hit we can pull a data of max 24 hours.</td></tr><tr><td>createEndDate</td><td>Yes</td><td>String</td><td>Date should be in YYYY-MM-DD format. Also at one hit we can pull a data of max 24 hours.</td></tr><tr><td>cm_id</td><td>Yes</td><td>String</td><td>The Acount id which is unique.</td></tr></tbody></table>

{% tabs %}
{% tab title="Body Request" %}

```json
{
    "cm_id": 1000298,
    "isAllCustomerPage": false, //Accepts boolean value [true/false], get configuration 
  and search based on all customer page search criteria         
     	   	"name": "",
    "phone": "",
    "email": "",
    "designationType": "",
    "customer_id": "",
    "customerCode": "",
    "zoneIdStr": "",
    "zone_id": 0, //When zoneIdStr value is empty, this will be 
    checked
 	"assignedToId": 0,
    "assignedToIdStr": "", //When assignedToId value is empty, this will be 
    checked
 	"isOrganisation": true, //Accepts boolean value [true/false]
    "isIndividual": "true", //Accepts boolean value [true/false], condition is 
     checked only when isOrganisation value is false
 	"isChannelPartner": "", //Accepts boolean value [true/false], condition is 
    checked only when isIndividual value is false
      		"createStartDate": "2024-05-01", //Date format - [yyyy-mm-dd]
    "createEndDate": "2024-05-02", //Date format - [yyyy-mm-dd]
    "primarySourceId": 0,
    "secondarySourceId": 0,
    "tertiarySourceId": 0,
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": "",
    "attr5": "",
    "attr6": "",
    "attr7": "",
    "attr8": "",
    "attr9": "",
    "attr10": "",
    "attr11": "",
    "attr12": "",
    "attr13": "",
    "attr14": "",
    "attr15": "",
    "limit": "", //Default limit is 100 to display records
    "offset": "" // To skip a certain number of rows in the result set of a query
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Please map in the request body if there's any extra associate body according to your use case.**
{% endhint %}

### Response Body

The API responds with a JSON object containing the details of the updated customer. If successful, the response will include the customer ID and the other relevant information.

| Response                                           | Response Messages                                                                   |
| -------------------------------------------------- | ----------------------------------------------------------------------------------- |
| { ..., "status": "success"}                        | List of customers fetched successfully.                                             |
| {"message": "Invalid Auth Key","status": "failed"} | Authorization key is either not passed in header, or incorrect, or expired/disabled |

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

```json
{
    "message": [
        {
            "id": 191121684,
            "cmId": 1000298,
            "isOrganization": true,
            "name": "Sashank",
            "website": "",
            "address": " ",
            "state": "",
            "city": "",
            "country": "",
            "latitude": "",
            "longitude": "",
            "currentStatus": "N",
            "generationDate": "May 2, 2024 4:15:42 PM",
            "creatorId": 0,
            "channelPartnerId": 0,
            "remarks": "",
            "ratePlanId": 0,
            "customerCode": "",
            "isChannelPartner": false,
            "pinCode": "",
            "campaignId": 0,
            "campaignItemId": 0,
            "campaignActivityId": 0,
            "totalNoOfEnquiries": 1,
            "feedbackOnCustomer": "0",
            "contacts": [
                {
                    "id": 209432475,
                    "cmId": 1000298,
                    "leadId": 191121684,
                    "contactPerson": "Sashank",
                    "gender": " ",
                    "phone": "9380491326",
                    "additionalPhone": "",
                    "email": "sashank@gmail.com",
                    "isPrimaryContact": true,
                    "isActive": true,
                    "generationDate": {
                        "year": 2024,
                        "month": 4,
                        "dayOfMonth": 2,
                        "hourOfDay": 16,
                        "minute": 15,
                        "second": 42
                    },
                    "parentContactId": 0,
                    "subOfficeId": 0,
                    "creatorId": 0,
                    "age": 0,
                    "maritalStatus": " ",
                    "isGuest": false,
                    "phoneCountryCode": "",
                    "enquiryId": 0,
                    "orderId": 0,
                    "isMergeEnable": false,
                    "isMobileMasked": false,
                    "isEmailMasked": false,
                    "showBirthYear": false
                }
            ],
            "lastModificationTime": {
                "year": 2024,
                "month": 4,
                "dayOfMonth": 2,
                "hourOfDay": 16,
                "minute": 15,
                "second": 42
            },
            "imageReferenceId": "CUS_2024-05-02 16:15:42.249",
            "classification": "",
            "customerType": "",
            "customerLevel": 0,
            "zone": 0,
            "companyParentId": 0,
            "assignedToId": 0,
            "maxCreditAmt": 0.0,
            "maxCreditPeriod": 0,
            "historyEmpId": 0,
            "channelPartnerEmpId": 0,
            "deleted": false,
            "companyStatus": "A",
            "isExistingCustomer": false,
            "isExistingContact": false,
            "syncStatus": false,
            "syncdLocationId": "0",
            "crossRemarks": "",
            "syncedStepNumber": 0,
            "outStandingAmount": 0.0,
            "salesAdminZone": 0,
            "referralId": 0,
            "isApi": false
        },
        {
            "id": 191125635,
            "cmId": 1000298,
            "isOrganization": true,
            "name": "rahul",
            "website": "",
            "address": " ",
            "state": "",
            "city": "",
            "country": "",
            "latitude": "",
            "longitude": "",
            "currentStatus": "N",
            "generationDate": "May 2, 2024 4:38:14 PM",
            "creatorId": 0,
            "channelPartnerId": 0,
            "remarks": "",
            "ratePlanId": 0,
            "customerCode": "",
            "isChannelPartner": false,
            "pinCode": "",
            "campaignId": 0,
            "campaignItemId": 0,
            "campaignActivityId": 0,
            "totalNoOfEnquiries": 1,
            "feedbackOnCustomer": "0",
            "contacts": [
                {
                    "id": 209436434,
                    "cmId": 1000298,
                    "leadId": 191125635,
                    "contactPerson": "rahul",
                    "gender": " ",
                    "phone": "1234567890",
                    "additionalPhone": "",
                    "email": "xyz@gmail.com",
                    "isPrimaryContact": true,
                    "isActive": true,
                    "generationDate": {
                        "year": 2024,
                        "month": 4,
                        "dayOfMonth": 2,
                        "hourOfDay": 16,
                        "minute": 38,
                        "second": 14
                    },
                    "parentContactId": 0,
                    "subOfficeId": 0,
                    "creatorId": 0,
                    "age": 0,
                    "maritalStatus": " ",
                    "isGuest": false,
                    "phoneCountryCode": "",
                    "enquiryId": 0,
                    "orderId": 0,
                    "isMergeEnable": false,
                    "isMobileMasked": false,
                    "isEmailMasked": false,
                    "showBirthYear": false
                }
            ],
            "lastModificationTime": {
                "year": 2024,
                "month": 4,
                "dayOfMonth": 2,
                "hourOfDay": 16,
                "minute": 38,
                "second": 14
            },
            "imageReferenceId": "CUS_2024-05-02 16:38:14.026",
            "classification": "",
            "customerType": "",
            "customerLevel": 0,
            "zone": 0,
            "companyParentId": 0,
            "assignedToId": 0,
            "maxCreditAmt": 0.0,
            "maxCreditPeriod": 0,
            "historyEmpId": 0,
            "channelPartnerEmpId": 0,
            "deleted": false,
            "companyStatus": "A",
            "isExistingCustomer": false,
            "isExistingContact": false,
            "syncStatus": false,
            "syncdLocationId": "0",
            "crossRemarks": "",
            "syncedStepNumber": 0,
            "outStandingAmount": 0.0,
            "salesAdminZone": 0,
            "referralId": 0,
            "isApi": false
        }
    ],
    "status": "success"
}
```

{% endtab %}
{% endtabs %}

### Error Codes

| Error Codes | Description                                      |
| ----------- | ------------------------------------------------ |
| 400         | Bad Request - Invalid parameters or missing data |
| 401         | Unauthorized - Invalid or missing API key        |
| 403         | Forbidden - Insufficient permissions             |
| 404         | Not Found - Resource or endpoint not found       |
| 500         | Internal Server Error - Server-side issue        |

### Example of a working curl

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

```json
curl --location 'https://devapi.kapturecrm.com/ms/customer-search/customer-search/api/v1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <Your Token>' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data '{
    "cm_id": ,
    "isAllCustomerPage": false, 
  and search based on all customer page search criteria         
     	   	"name": "",
    "phone": "",
    "email": "",
    "designationType": "",
    "customer_id": "",
    "customerCode": "",
    "zoneIdStr": "",
    "zone_id": 0, 
    checked
 	"assignedToId": 0,
    "assignedToIdStr": "", 
    checked
 	"isOrganisation": true, 
    "isIndividual": "true", 
     checked only when isOrganisation value is false
 	"isChannelPartner": "", 
    checked only when isIndividual value is false
      		"createStartDate": "2024-05-07", 
    "createEndDate": "2024-05-08", 
    "primarySourceId": 0,
    "secondarySourceId": 0,
    "tertiarySourceId": 0,
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": "",
    "attr5": "",
    "attr6": "",
    "attr7": "",
    "attr8": "",
    "attr9": "",
    "attr10": "",
    "attr11": "",
    "attr12": "",
    "attr13": "",
    "attr14": "",
    "attr15": "",
    "limit": "", 
    "offset": "" 
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://devapi.kapturecrm.com/ms/customer-search/customer-search/api/v1"

payload = "{\r\n    \"cm_id\": ,\r\n    \"isAllCustomerPage\": false, \n  and search based on all customer page search criteria         \r\n     \t   \t\"name\": \"\",\r\n    \"phone\": \"\",\r\n    \"email\": \"\",\r\n    \"designationType\": \"\",\r\n    \"customer_id\": \"\",\r\n    \"customerCode\": \"\",\r\n    \"zoneIdStr\": \"\",\r\n    \"zone_id\": 0, \n    checked\r\n \t\"assignedToId\": 0,\r\n    \"assignedToIdStr\": \"\", \n    checked\r\n \t\"isOrganisation\": true, \n    \"isIndividual\": \"true\", \n     checked only when isOrganisation value is false\r\n \t\"isChannelPartner\": \"\", \n    checked only when isIndividual value is false\r\n      \t\t\"createStartDate\": \"2024-05-07\", \n    \"createEndDate\": \"2024-05-08\", \n    \"primarySourceId\": 0,\r\n    \"secondarySourceId\": 0,\r\n    \"tertiarySourceId\": 0,\r\n    \"attr1\": \"\",\r\n    \"attr2\": \"\",\r\n    \"attr3\": \"\",\r\n    \"attr4\": \"\",\r\n    \"attr5\": \"\",\r\n    \"attr6\": \"\",\r\n    \"attr7\": \"\",\r\n    \"attr8\": \"\",\r\n    \"attr9\": \"\",\r\n    \"attr10\": \"\",\r\n    \"attr11\": \"\",\r\n    \"attr12\": \"\",\r\n    \"attr13\": \"\",\r\n    \"attr14\": \"\",\r\n    \"attr15\": \"\",\r\n    \"limit\": \"\", \n    \"offset\": \"\" \n}"
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic <Your Token>',
  'Cookie': 'JSESSIONID=A8CFBB4FADB4FB4A9D61A38F409F8765; _KAPTURECRM_SESSION=vvDfyfbPm5c0Uo79xpT1wZbJQSoTTL'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

```

{% endtab %}

{% tab title="Node.js" %}

```
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://devapi.kapturecrm.com/ms/customer-search/customer-search/api/v1',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Basic c2FzaGFuay5nb2Vua2FAa2FwdHVyZWNybS5jb206S2FwdHVyZUAyNjE4',
    'Cookie': 'JSESSIONID=B2895F5BD36B2E75B91CFD0EE0F3B54C; _KAPTURECRM_SESSION=vvDfyfbPm5c0Uo79xpT1wZbJQSoTTL'
  },
  body: '{\r\n    "cm_id": ,\r\n    "isAllCustomerPage": false, \n  and search based on all customer page search criteria         \r\n     	   	"name": "",\r\n    "phone": "",\r\n    "email": "",\r\n    "designationType": "",\r\n    "customer_id": "",\r\n    "customerCode": "",\r\n    "zoneIdStr": "",\r\n    "zone_id": 0, \n    checked\r\n 	"assignedToId": 0,\r\n    "assignedToIdStr": "", \n    checked\r\n 	"isOrganisation": true, \n    "isIndividual": "true", \n     checked only when isOrganisation value is false\r\n 	"isChannelPartner": "", \n    checked only when isIndividual value is false\r\n      		"createStartDate": "2024-05-07", \n    "createEndDate": "2024-05-07", \n    "primarySourceId": 0,\r\n    "secondarySourceId": 0,\r\n    "tertiarySourceId": 0,\r\n    "attr1": "",\r\n    "attr2": "",\r\n    "attr3": "",\r\n    "attr4": "",\r\n    "attr5": "",\r\n    "attr6": "",\r\n    "attr7": "",\r\n    "attr8": "",\r\n    "attr9": "",\r\n    "attr10": "",\r\n    "attr11": "",\r\n    "attr12": "",\r\n    "attr13": "",\r\n    "attr14": "",\r\n    "attr15": "",\r\n    "limit": "", \n    "offset": "" \n}'

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dev.kapture.cx/kapture-api/reference/api-reference/pull-customer-api-by-date-range.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
