> For the complete documentation index, see [llms.txt](https://shiply-integration-apis.gitbook.io/shiply-integration-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shiply-integration-apis.gitbook.io/shiply-integration-documentation/integration-apis/shipping-address/calculate-shipping-cost.md).

# Calculate Shipping Cost

```php
POST /parcels/fees
```

This API calculates the shipping cost based on the selected shipping address, which includes the specified city and village.

#### Headers

<table><thead><tr><th width="374">Key</th><th>Value</th></tr></thead><tbody><tr><td>Accept</td><td>application/json</td></tr><tr><td>Content-Type</td><td>application/json</td></tr></tbody></table>

#### **Request body**

Request parameters:

<table><thead><tr><th width="134">Field Name</th><th width="102">Required</th><th width="93">Type</th><th>Notes</th></tr></thead><tbody><tr><td>village_id</td><td>yes</td><td>integer</td><td>It must be a valid <strong>village</strong> id selected from the list retrieved by this API: <a data-mention href="/shiply-integration-documentation/integration-apis/shipping-address/get-cities-and-villages.md">Get Cities And Villages</a></td></tr><tr><td>price</td><td>no</td><td>numeric</td><td>The parcel price, used to calculate extra price fee.</td></tr></tbody></table>

Request body example:

{% code lineNumbers="true" %}

```json
{
    "village_id": 148, 
    "price": 700,
    "Shiply_API_KEY": "your_api_key"
}
```

{% endcode %}

#### **Response body**

{% tabs %}
{% tab title="Succss" %}
Status code: <mark style="color:green;">200 OK</mark>

{% code lineNumbers="true" %}

```json
{
    "delivery_cost": "17.00",
    "returned_delivery_cost": "0.00",
    "extra_price": 0,
    "returned_extra_price": 0
}
```

{% endcode %}

The response contains 4 values:&#x20;

* <mark style="color:blue;">delivery\_cost</mark>: Shipping cost for the selected village.
* <mark style="color:blue;">extra\_price</mark>: The extra price that exceeds customer's parcel price threshold.&#x20;
* <mark style="color:blue;">returned\_extra\_price</mark>: The returned extra price that exceeds customer's parcel price threshold.
* <mark style="color:blue;">returned\_delivery\_cost</mark>: Shipping cost for the selected village for returned parcels.
  {% endtab %}

{% tab title="Unauthorized" %}
Status code: <mark style="color:green;">200 OK</mark>

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "errors": [
        "unauthorized"
    ]
}
```

{% endcode %}

This response is returned when the <mark style="color:blue;">Shiply\_API\_KEY</mark> is not included in the request body.
{% endtab %}
{% endtabs %}
