# Update Order API

## Update Order.

<mark style="color:green;">`POST`</mark> [https://\<sub domain>.kapturecrm.com/ms/customer/order/api/v1/add-update](https://devapi.kapturecrm.com/ms/customer/order/api/v1/add-update)[](https://devapi.kapturecrm.com/select-customer-between-start-and-end-dates.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 user name and password  in the Authorization header. For authentication, use the following header, which will help you generate your Basic Auth token:

```
Basic <Your Token>
```

### Request Body

The request body should be a JSON object containing the details of the customer against which the order needs to be updated along with the order details. 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_name</td><td>Yes</td><td>Date</td><td>Indicates the name of the customer exisiting in the System.</td></tr><tr><td>order_id</td><td>Yes</td><td>Number</td><td>Kapture generated unique order id against which the update of information is needed.</td></tr></tbody></table>

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

```json
{
    "customer_info": {
        "customer_name": "ABC",
        "phone": "9380491257",
        "email_id": "abc@abc.min",
        "locality": "",
        "city": "",
        "state": "",
        "country": "India",
        "address": "jalsa",
        "type": "",
        "classification": "",
        "pincode": "",
        "customer_code": "",
        "customer_id": "",
        "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": "",
            "last_name": "",
            "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"
    },
    "order_info": {
        "order_id": "23518265",
        "assign_emp_name": "",
        "assign_emp_code": "",
        "assign_emp_email": "",
        "delivery_status": "",
        "erp_order_id": "",
        "erp_invoice_no": "",
        "create_date": "",
        "remarks": "testing 2345",
        "invoice_no": "3141341",
        "invoice_date": "",
        "unit_name": "",
        "block_name": "",
        "ticket_id": "",
        "encryptOrder": "",
        "payment_mode": "",
        "dealDetails": "",
        "associate_fields": {},
        "update": true
    }
}
```

{% 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 added order against the customer. If successful, the response will include the customer ID, order 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
{
    "status": "success",
    "message": "Order Updated successfully !",
    "Order": {
        "result": true,
        "customer_id": 191696570,
        "enquiry_id": 24284719,
        "action": "ORDER",
        "action_event": "ORDER_FIELD_UPDATION",
        "contact_id": 210006001
    }
}
```

{% 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/order/api/v1/add-update' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <Your Token>' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data-raw '{
    "customer_info": {
        "customer_name": "ABC",
        "phone": "9380491257",
        "email_id": "abc@abc.min",
        "locality": "",
        "city": "",
        "state": "",
        "country": "India",
        "address": "jalsa",
        "type": "",
        "classification": "",
        "pincode": "",
        "customer_code": "",
        "customer_id": "",
        "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": "",
            "last_name": "",
            "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"
    },
    "order_info": {
        "order_id": "23518265",
        "assign_emp_name": "",
        "assign_emp_code": "",
        "assign_emp_email": "",
        "delivery_status": "",
        "erp_order_id": "",
        "erp_invoice_no": "",
        "create_date": "",
        "remarks": "testing 2345",
        "invoice_no": "3141341",
        "invoice_date": "",
        "unit_name": "",
        "block_name": "",
        "ticket_id": "",
        "encryptOrder": "",
        "payment_mode": "",
        "dealDetails": "",
        "associate_fields": {},
        "update": true
    }
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

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

payload = json.dumps({
  "customer_info": {
    "customer_name": "ABC",
    "phone": "9380491257",
    "email_id": "abc@abc.min",
    "locality": "",
    "city": "",
    "state": "",
    "country": "India",
    "address": "jalsa",
    "type": "",
    "classification": "",
    "pincode": "",
    "customer_code": "",
    "customer_id": "",
    "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": "",
      "last_name": "",
      "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"
  },
  "order_info": {
    "order_id": "23518265",
    "assign_emp_name": "",
    "assign_emp_code": "",
    "assign_emp_email": "",
    "delivery_status": "",
    "erp_order_id": "",
    "erp_invoice_no": "",
    "create_date": "",
    "remarks": "testing 2345",
    "invoice_no": "3141341",
    "invoice_date": "",
    "unit_name": "",
    "block_name": "",
    "ticket_id": "",
    "encryptOrder": "",
    "payment_mode": "",
    "dealDetails": "",
    "associate_fields": {},
    "update": True
  }
})
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/order/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": "abc@abc.min",
      "locality": "",
      "city": "",
      "state": "",
      "country": "India",
      "address": "jalsa",
      "type": "",
      "classification": "",
      "pincode": "",
      "customer_code": "",
      "customer_id": "",
      "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": "",
        "last_name": "",
        "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"
    },
    "order_info": {
      "order_id": "23518265",
      "assign_emp_name": "",
      "assign_emp_code": "",
      "assign_emp_email": "",
      "delivery_status": "",
      "erp_order_id": "",
      "erp_invoice_no": "",
      "create_date": "",
      "remarks": "testing 2345",
      "invoice_no": "3141341",
      "invoice_date": "",
      "unit_name": "",
      "block_name": "",
      "ticket_id": "",
      "encryptOrder": "",
      "payment_mode": "",
      "dealDetails": "",
      "associate_fields": {},
      "update": true
    }
  })

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

```

{% endtab %}
{% endtabs %}
