# Pull Order API

## Pull Order.

<mark style="color:green;">`POST`</mark> [https://\<sub domain>.kapturecrm.com/ms/customer-search/order-search/api/v1/pull-internal](https://devapi.kapturecrm.com/ms/customer-search/order-search/api/v1/pull-internal)[](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:

TTo 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 list of the orders existing in the system. Here are the  list of parameters.\
\
\
Note: Atleast one of the value must be entered out of name, enquiryIds, generationStartDate, generationEndDate, nextFollowupStartDate, nextFollowupEndDate, lastFollowupStartDate, lastFollowupEndDate, expectedClosureStartDate, expectedClosureEndDate, customerIds, statusStr, subStatusStr, creatorOrAssignedIdStr, assignToIdsStr, creatorIdStr, notAssignToIdsStr, country, city, state, leadPriorityStr, secondarySourceId, clientReferenceIds, approvedIds, pricingStatus, attr1, attr2, attr3, attr4, attr5, attr6, attr7, attr8, attr9, attr10, attr11, attr12, attr13, attr14, attr15

<table><thead><tr><th>Name</th><th width="125">Mandatory</th><th width="111">Type</th><th>Description</th></tr></thead><tbody><tr><td>cmId</td><td>Yes</td><td>Number</td><td>Indicates the unique account Id</td></tr><tr><td>customer_Ids</td><td>Yes</td><td>Number</td><td>Kapture generated unique customer id against which the update of information is needed.</td></tr></tbody></table>

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

```json
{
    "cmId": 1000298, //Required field, value must be > 0.
    "name": "",
    "phone": "",
    "email": "",
    "customerIds": "191696570",
    "leadIdStr": "",
    "enquiryIds": "",
    "clientReferenceIds": "",
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": "",
    "attr5": "",
    "attr6": "",
    "attr7": "",
    "attr8": "",
    "attr9": "",
    "attr10": "",
    "attr11": "",
    "attr12": "",
    "attr13": "",
    "attr14": "",
    "attr15": "",
    "viewId": "2",
    "orderIds": "",
    "erpOrderId": "",
    "createStartDate": "",
    "createEndDate": "",
    "bookingStatus": "",
    "bookingSubStatus": "",
    "bookingStartDate": "",
    "bookingEndDate": "",
    "creatorIdStr": "",
    "assignIdStr": "",
    "zoneIdStr": "",
    "blockId": "",
    "unitId": "",
    "approvalDesignationIds": "",
    "agreementStartDate": "",
    "agreementEndDate": "",
    "erpInvoiceId": "",
    "sortParam": "",
	"limit": "",
    "offset": ""
}
```

{% 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
{
    "success": "true",
    "order_details": [
        {
            "id": 23518265,
            "cmId": 1000298,
            "customerId": 191696570,
            "enquiryId": 24284201,
            "createDate": 1715149492000,
            "creatorId": 209803,
            "productQuantity": 0,
            "productValue": 0,
            "discount": 0,
            "remarks": "testing",
            "deliveryStatus": "AP",
            "lastModificationTime": 1715149492000,
            "unitId": 0,
            "blockId": 0,
            "zoneId": 0,
            "basePrice": 0,
            "serviceTax": 0,
            "bookingAmount": 0,
            "retainerFrequency": 0,
            "retainerAmount": 0,
            "subOfficeId": 0,
            "retainerCreditPeriod": 0,
            "parentOrderId": 0,
            "assignedToId": 209803,
            "invoiceSent": false,
            "commissionAmount": 0,
            "totalSaleableArea": 0,
            "builderInvoiceId": 0,
            "enquiryAssignedTo": 0,
            "sellingPrice": 0,
            "cess": 0,
            "extraCharges": 0,
            "warrantyInDays": 0,
            "parentCustomerId": 0,
            "checkedIn": false,
            "includeInterest": false,
            "channelId": 0,
            "deliveredOrderId": 0,
            "commissionPaidAmount": 0,
            "onwardCruiseId": 0,
            "returnCruiseId": 0,
            "approvedByEmployeeId": 0,
            "vatamount": 0
        }
    ]
}
```

{% 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 --request GET 'https://devapi.kapturecrm.com/ms/customer-search/order-search/api/v1/pull-internal' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <Your Token>' \
--header 'Cookie: JSESSIONID=; _KAPTURECRM_SESSION=' \
--data '{
    "cmId": 1000298, 
    "name": "",
    "phone": "",
    "email": "",
    "customerIds": "191696570",
    "leadIdStr": "",
    "enquiryIds": "",
    "clientReferenceIds": "",
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": "",
    "attr5": "",
    "attr6": "",
    "attr7": "",
    "attr8": "",
    "attr9": "",
    "attr10": "",
    "attr11": "",
    "attr12": "",
    "attr13": "",
    "attr14": "",
    "attr15": "",
    "viewId": "2",
    "orderIds": "",
    "erpOrderId": "",
    "createStartDate": "",
    "createEndDate": "",
    "bookingStatus": "",
    "bookingSubStatus": "",
    "bookingStartDate": "",
    "bookingEndDate": "",
    "creatorIdStr": "",
    "assignIdStr": "",
    "zoneIdStr": "",
    "blockId": "",
    "unitId": "",
    "approvalDesignationIds": "",
    "agreementStartDate": "",
    "agreementEndDate": "",
    "erpInvoiceId": "",
    "sortParam": "",
	"limit": "",
    "offset": ""
}'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

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

payload = json.dumps({
  "cmId": 1000298,
  "name": "",
  "phone": "",
  "email": "",
  "customerIds": "191696570",
  "leadIdStr": "",
  "enquiryIds": "",
  "clientReferenceIds": "",
  "attr1": "",
  "attr2": "",
  "attr3": "",
  "attr4": "",
  "attr5": "",
  "attr6": "",
  "attr7": "",
  "attr8": "",
  "attr9": "",
  "attr10": "",
  "attr11": "",
  "attr12": "",
  "attr13": "",
  "attr14": "",
  "attr15": "",
  "viewId": "2",
  "orderIds": "",
  "erpOrderId": "",
  "createStartDate": "",
  "createEndDate": "",
  "bookingStatus": "",
  "bookingSubStatus": "",
  "bookingStartDate": "",
  "bookingEndDate": "",
  "creatorIdStr": "",
  "assignIdStr": "",
  "zoneIdStr": "",
  "blockId": "",
  "unitId": "",
  "approvalDesignationIds": "",
  "agreementStartDate": "",
  "agreementEndDate": "",
  "erpInvoiceId": "",
  "sortParam": "",
  "limit": "",
  "offset": ""
})
headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Basic <Your Token>',
  'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
}

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

print(response.text)

```

{% endtab %}

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

```
var request = require('request');
var options = {
  'method': 'GET',
  'url': 'https://devapi.kapturecrm.com/ms/customer-search/order-search/api/v1/pull-internal',
  'headers': {
    'Content-Type': 'application/json',
    'Authorization': 'Basic <Your Token>',
    'Cookie': 'JSESSIONID=; _KAPTURECRM_SESSION='
  },
  body: JSON.stringify({
    "cmId": 1000298,
    "name": "",
    "phone": "",
    "email": "",
    "customerIds": "191696570",
    "leadIdStr": "",
    "enquiryIds": "",
    "clientReferenceIds": "",
    "attr1": "",
    "attr2": "",
    "attr3": "",
    "attr4": "",
    "attr5": "",
    "attr6": "",
    "attr7": "",
    "attr8": "",
    "attr9": "",
    "attr10": "",
    "attr11": "",
    "attr12": "",
    "attr13": "",
    "attr14": "",
    "attr15": "",
    "viewId": "2",
    "orderIds": "",
    "erpOrderId": "",
    "createStartDate": "",
    "createEndDate": "",
    "bookingStatus": "",
    "bookingSubStatus": "",
    "bookingStartDate": "",
    "bookingEndDate": "",
    "creatorIdStr": "",
    "assignIdStr": "",
    "zoneIdStr": "",
    "blockId": "",
    "unitId": "",
    "approvalDesignationIds": "",
    "agreementStartDate": "",
    "agreementEndDate": "",
    "erpInvoiceId": "",
    "sortParam": "",
    "limit": "",
    "offset": ""
  })

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

```

{% endtab %}
{% endtabs %}
