> For the complete documentation index, see [llms.txt](https://fez-delivery-co.gitbook.io/fezcorporate-api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fez-delivery-co.gitbook.io/fezcorporate-api-docs/api-endpoints/orders/search.md).

# Search

Search Order

## Endpoint => /orders/search

<mark style="color:green;">`POST`</mark> `/orders/search`

#### Headers

| Name                                             | Type   | Description       |
| ------------------------------------------------ | ------ | ----------------- |
| Authorization <mark style="color:red;">\*</mark> | String | Your Bearer Token |
| secret-key<mark style="color:red;">\*</mark>     | String | Your Secret Key   |

#### Request Body

| Name                                        | Type    | Description                                                                                                                                                                                                                                      |
| ------------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| startDate<mark style="color:red;">\*</mark> | String  | Start of the search date range                                                                                                                                                                                                                   |
| orderNo                                     | String  | Order number                                                                                                                                                                                                                                     |
| recipientName                               | String  | Recipient Name                                                                                                                                                                                                                                   |
| recipientPhone                              | String  | Recipient Phone or Mobile number                                                                                                                                                                                                                 |
| orderStatus                                 | String  | Enum value: Pending Pick-Up,Picked-Up,Dispatched,Delivered,Returned                                                                                                                                                                              |
| OrgRep                                      | String  | This is the user\_id of the user who created the order                                                                                                                                                                                           |
| endDate<mark style="color:red;">\*</mark>   | String  | End of the search date range                                                                                                                                                                                                                     |
| page<mark style="color:red;">\*</mark>      | Integer | The endpoint returns a maximum of 50 records. If the search result is more that 50, a link object is created that specifies the page Number of the next page. Please pass this number in your subsequent request to fetch the remaining records. |

{% tabs %}
{% tab title="200: OK Success" %}

```json
{
  "status": "Success",
  "description": "Order Fetched Successfully",
  "orders": {
    "current_page": 1,
    "data": [
      {
        "orderNo": "O41027012333",
        "recipientName": "Femi",
        "recipientEmail": "",
        "recipientAddress": "Idumota",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:46:33",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      },
      {
        "orderNo": "JN7327012333",
        "recipientName": "Femi2",
        "recipientEmail": "",
        "recipientAddress": "Idumota3",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:46:33",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      },
      {
        "orderNo": "9KDT27012348",
        "recipientName": "Femi",
        "recipientEmail": "",
        "recipientAddress": "Idumota",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:46:48",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      },
      {
        "orderNo": "M7W727012349",
        "recipientName": "Femi2",
        "recipientEmail": "",
        "recipientAddress": "Idumota3",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:46:49",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      },
      {
        "orderNo": "JHAZ27012319",
        "recipientName": "Femi2",
        "recipientEmail": "",
        "recipientAddress": "Idumota3",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:47:19",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      },
      {
        "orderNo": "333R27012331",
        "recipientName": "Femi",
        "recipientEmail": "",
        "recipientAddress": "Idumota",
        "recipientPhone": "08000000000000",
        "orderStatus": "Pending Pick-Up",
        "statusDescription": null,
        "cost": "900",
        "createdBy": "C-39006-611",
        "OrgRep": "G-ylNt-c7xD",
        "orderDate": "2023-01-27 02:53:31",
        "pickUpDate": "0000-00-00 00:00:00",
        "dispatchDate": null,
        "deliveryDate": null,
        "returnReason": null,
        "returnDate": null
      }
    ],
    "first_page_url": "https://apisandbox.fezdelivery.co/v1/orders/search?page=1",
    "from": 1,
    "last_page": 1,
    "last_page_url": "https://apisandbox.fezdelivery.co/v1/orders/search?page=1",
    "next_page_url": null,
    "path": "https://apisandbox.fezdelivery.co/v1/orders/search",
    "per_page": 50,
    "prev_page_url": null,
    "to": 6,
    "total": 6
  }
}
```

{% endtab %}

{% tab title="401 Unauthorized" %}

```
{
    "status": "Error",
    "description": "Organization Secret Key is Required"
}
```

{% endtab %}
{% endtabs %}

```php
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://apisandbox.fezdelivery.co/v1/orders/search',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "startDate":"2019-08-26",
    "endDate":"2023-10-10"
}',
  CURLOPT_HTTPHEADER => array(
    'secret-key: {{Your Secret key}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```

{% hint style="info" %}
The startDate and endDate is based on order Date.
{% endhint %}
