# Update Customer API

## Update Customer.

<mark style="color:green;">`POST`</mark> [https://\<sub domain>.kapturecrm.com/ms/customer/customer/api/v1/add-update](https://devapi.kapturecrm.com/ms/customer/customer/api/v1/add-update)

{% 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 updated. Here are the  list of parameters.\ <br>

<table><thead><tr><th>Name</th><th width="125">Mandatory</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>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>name</td><td>No</td><td>Text</td><td>Name of the customer</td></tr><tr><td>email</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
{
    "customer_info": {
        "customer_name": "ABC",
        "phone": "9380491257",
        "email_id": "",
        "locality": "",
        "city": "",
        "state": "",
        "country": "India",
        "address": "jalsa",
        "type": "",
        "classification": "",
        "pincode": "",
        "customer_code": "",
        "customer_id": "191690263",
        "customer_assign_emp_name": "",
        "customer_assign_emp_code": "",
        "customer_assign_emp_email": "",
        "zone": "",
        "customer_remarks": "",
        "individual": false,
        "organization": true,
        "channel_partner": false,
        "remarks": "testing",
        "primary_source": "",
        "secondary_source": "",
        "tertiary_source": "",
        "additional_fields": {},
        "associate_fields": {},
        "update": false
    },
    "contact_info": [
        {
            "contact_id": "",
            "title": "no",
            "first_name": "Salman",
            "last_name": "Khan",
            "contact_person_name": "",
            "country_code": "",
            "contact_person_phone": "9380491257",
            "contact_person_email": "",
            "additional_contact_phone": "",
            "dob": "",
            "gender": "Male",
            "update": false,
            "matchEmailPhone": false
        }
    ],
    "enquiry_info": {
        "enquiry_id": "",
        "assign_emp_name": "",
        "assign_emp_code": "",
        "assign_emp_email": "",
        "round_robin_key": "",
        "next_follow_up_date": "",
        "action": "",
        "subStatus": "",
        "additional_fields": {},
        "associate_fields": {},
        "update": false,
        "remarks": "testing"
    }
}
```

{% 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 |
| {"message": "Name, Email Id, and Phone Number required", "status": "failed"} | name and phone\|email are either missing or empty in request body.                  |

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

```json
{
    "status": "success",
    "customer": {
        "result": true,
        "customer_id": 191690263,
        "action": "CUSTOMER",
        "action_event": "UPDATE_CUSTOMER",
        "contact_id": 210006001
    },
    "message": "Customer Updated successfully !Contact Added successfully !"
}
```

{% 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/customer/api/v1/add-update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <Your Token>' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data '{
    "customer_info": {
        "customer_name": "ABC",
        "phone": "9380491257",
        "email_id": "",
        "locality": "",
        "city": "",
        "state": "",
        "country": "India",
        "address": "jalsa",
        "type": "",
        "classification": "",
        "pincode": "",
        "customer_code": "",
        "customer_id": "191690263",
        "customer_assign_emp_name": "",
        "customer_assign_emp_code": "",
        "customer_assign_emp_email": "",
        "zone": "",
        "customer_remarks": "",
        "individual": false,
        "organization": true,
        "channel_partner": false,
        "remarks": "testing",
        "primary_source": "",
        "secondary_source": "",
        "tertiary_source": "",
        "additional_fields": {},
        "associate_fields": {},
        "update": false
    },
    "contact_info": [
        {
            "contact_id": "",
            "title": "no",
            "first_name": "Salman",
            "last_name": "Khan",
            "contact_person_name": "",
            "country_code": "",
            "contact_person_phone": "9380491257",
            "contact_person_email": "",
            "additional_contact_phone": "",
            "dob": "",
            "gender": "Male",
            "update": false,
            "matchEmailPhone": false
        }
    ],
    "enquiry_info": {
        "enquiry_id": "",
        "assign_emp_name": "",
        "assign_emp_code": "",
        "assign_emp_email": "",
        "round_robin_key": "",
        "next_follow_up_date": "",
        "action": "",
        "subStatus": "",
        "additional_fields": {},
        "associate_fields": {},
        "update": false,
        "remarks": "testing"
    }
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

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

payload = json.dumps({
  "customer_info": {
    "customer_name": "ABC",
    "phone": "9380491257",
    "email_id": "",
    "locality": "",
    "city": "",
    "state": "",
    "country": "India",
    "address": "jalsa",
    "type": "",
    "classification": "",
    "pincode": "",
    "customer_code": "",
    "customer_id": "191690263",
    "customer_assign_emp_name": "",
    "customer_assign_emp_code": "",
    "customer_assign_emp_email": "",
    "zone": "",
    "customer_remarks": "",
    "individual": False,
    "organization": True,
    "channel_partner": False,
    "remarks": "testing",
    "primary_source": "",
    "secondary_source": "",
    "tertiary_source": "",
    "additional_fields": {},
    "associate_fields": {},
    "update": False
  },
  "contact_info": [
    {
      "contact_id": "",
      "title": "no",
      "first_name": "Salman",
      "last_name": "Khan",
      "contact_person_name": "",
      "country_code": "",
      "contact_person_phone": "9380491257",
      "contact_person_email": "",
      "additional_contact_phone": "",
      "dob": "",
      "gender": "Male",
      "update": False,
      "matchEmailPhone": False
    }
  ],
  "enquiry_info": {
    "enquiry_id": "",
    "assign_emp_name": "",
    "assign_emp_code": "",
    "assign_emp_email": "",
    "round_robin_key": "",
    "next_follow_up_date": "",
    "action": "",
    "subStatus": "",
    "additional_fields": {},
    "associate_fields": {},
    "update": False,
    "remarks": "testing"
  }
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic <Your Token>',
  '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/ms/customer/customer/api/v1/add-update',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Basic <Your Token>',
    'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
  },
  body: JSON.stringify({
    "customer_info": {
      "customer_name": "ABC",
      "phone": "9380491257",
      "email_id": "",
      "locality": "",
      "city": "",
      "state": "",
      "country": "India",
      "address": "jalsa",
      "type": "",
      "classification": "",
      "pincode": "",
      "customer_code": "",
      "customer_id": "191690263",
      "customer_assign_emp_name": "",
      "customer_assign_emp_code": "",
      "customer_assign_emp_email": "",
      "zone": "",
      "customer_remarks": "",
      "individual": false,
      "organization": true,
      "channel_partner": false,
      "remarks": "testing",
      "primary_source": "",
      "secondary_source": "",
      "tertiary_source": "",
      "additional_fields": {},
      "associate_fields": {},
      "update": false
    },
    "contact_info": [
      {
        "contact_id": "",
        "title": "no",
        "first_name": "Salman",
        "last_name": "Khan",
        "contact_person_name": "",
        "country_code": "",
        "contact_person_phone": "9380491257",
        "contact_person_email": "",
        "additional_contact_phone": "",
        "dob": "",
        "gender": "Male",
        "update": false,
        "matchEmailPhone": false
      }
    ],
    "enquiry_info": {
      "enquiry_id": "",
      "assign_emp_name": "",
      "assign_emp_code": "",
      "assign_emp_email": "",
      "round_robin_key": "",
      "next_follow_up_date": "",
      "action": "",
      "subStatus": "",
      "additional_fields": {},
      "associate_fields": {},
      "update": false,
      "remarks": "testing"
    }
  })

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

```

{% endtab %}
{% endtabs %}
