# Get Customer API

## Get Customer.

<mark style="color:green;">`POST`</mark> <https://devapi.kapturecrm.com/search-customer-by-customer-id.html>

{% 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>kapture_customer_id</td><td>Yes</td><td>Number</td><td>The Id of the customer which is generated in Kapture Database</td></tr><tr><td>email_id</td><td>No</td><td>String</td><td>Email Address of the customer</td></tr><tr><td>phone</td><td>No</td><td>Number</td><td>Phone number of the customer</td></tr></tbody></table>

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

```json
[
    {
        "kapture_customer_id": "191121684",
        "email_id": "xyz@gmail.com",
        "phone": "1234567890"
    }
]
```

{% 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"}                                                                       | Customer data pushed successfully.                                                  |
| {"message": "Invalid Auth Key","status": "failed"}                                                | Authorization key is either not passed in header, or incorrect, or expired/disabled |
| {"Customer Details": "Information given by you does not exist in our sytsem.","status": "failed"} | Details provided doesn't match with records available in the system.                |

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

```json
{
    "Customer Details": {
        "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
            }
        ],
        "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
    },
    "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/search-customer-by-customer-id.html' \
--header 'Authorization: Basic <Your Token>' \
--header 'Content-Type: application/json' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data-raw '[
    {
        "kapture_customer_id": "191121684",
        "email_id": "xyz@gmail.com",
        "phone": "1234567890"
    }
]'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

url = "https://devapi.kapturecrm.com/search-customer-by-customer-id.html"

payload = json.dumps([
  {
    "kapture_customer_id": "191121684",
    "email_id": "xyz@gmail.com",
    "phone": "1234567890"
  }
])
headers = {
  'Authorization': 'Basic <Your Token>',
  'Content-Type': 'application/json',
  'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
}

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/search-customer-by-customer-id.html',
  'headers': {
    'Authorization': 'Basic <Your Token>',
    'Content-Type': 'application/json',
    'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
  },
  body: JSON.stringify([
    {
      "kapture_customer_id": "191121684",
      "email_id": "xyz@gmail.com",
      "phone": "1234567890"
    }
  ])

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

```

{% endtab %}
{% endtabs %}
