# Fetch Delivery Cost

{% hint style="info" %}
By default, the cost returned when state field is not passed is based on the weight of the parcel being between 0-5kg.

To get the cost of the delivery based on the weight of the parcel, please add the weight field.

Please note that the delivery cost API assumes pick up location (state) is the state configured in your organization's profile and the cost returned is between a pick up location in that state to any state you pass in the request. For example, if your business is configured to be operating out of Rivers State, the cost returned from this endpoint will be from Rivers State to any state passed in the request as the destination state or from Rivers to all the 36 States and FCT,if the state field is empty.
{% endhint %}

Delivery Cost

## Endpoint => /order/cost

<mark style="color:green;">`POST`</mark> `/order/cost`

{% hint style="info" %}
Kindly use **`cost`** (lowercase) instead of **`Cost`** in the response body.\
Please note that the actual amount charged is the sum of **VAT and cost**, which represents the **total cost**.
{% endhint %}

#### 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                                                    |
| ----------- | ------- | -------------------------------------------------------------- |
| state       | String  | The Destination State to deliver to                            |
| pickUpState | String  | The State from which the Item is leaving (Optional)            |
| weight      | Numeric | Weight of order (Optional)                                     |
| locker      | Boolean | Indicate that the delivery should via locker. (Default: false) |

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

```json
{
    "status": "Success",
    "description": "Cost Fetched Successfully",
    "Cost": {
        "state": "Kano",
        "cost": 6000
    },
    "cost": {
        "state": "Kano",
        "cost": 6000
    },
    "vat": {
        "vatAmount": 450,
        "vatPercent": "7.50"
    },
    "totalCost": 6450
}
```

{% 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/order/cost',
  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 =>'{
    "state":"Kano"
}',
  CURLOPT_HTTPHEADER => array(
    'secret-key: {{Your Secret Key}}'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fez-delivery-co.gitbook.io/fezcorporate-api-docs/api-endpoints/orders/fetch-delivery-cost.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
