> 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/parcels/cancel-parcel.md).

# Cancel Parcel

```php
GET /parcels/cancel/{parcel_id}
```

This API is used to change the parcel status from "Submitted" to "Draft".

{% hint style="info" %}
**Note:** Should replace <mark style="color:blue;">{parcel\_id}</mark> with the <mark style="color:blue;">parcel\_code</mark> of the parcel you wish to cancel.
{% endhint %}

#### Headers

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

#### Request body

{% code lineNumbers="true" %}

```json
{
    "Shiply_API_KEY": "your_api_key"
}
```

{% endcode %}

#### Response body

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

<pre class="language-json" data-line-numbers><code class="lang-json">{
<strong>    "parcel_code": "asnf-000-4280034",
</strong>    "description": "Hhhh",
    "customer_user_id": 4,
    "driver_user_id": null,
    "paid_driver_id": null,
    "in_account": 0,
    "parcel_status_id": 1,
    "is_locked": 0,
    "parcel_position_id": 1,
    "address_id": 1469566,
    "recipient_id": 1462547,
    "qr_code": "shiply_rs91357",
    "qr_hash": "",
    "region_cost_map_id": null,
    "total_price": 666,
    "actual_price": 631,
    "parcel_delivery_cost": 35,
    "price_extra_fee": 0,
    "planned_date": null,
    "note": null,
    "weight": 5,
    "length": 43,
    "width": 43,
    "height": 43,
    "size_fee": 0,
    "created_at": "2024-11-16 15:21:57",
    "updated_at": "2024-11-16 16:25:18",
    "customer_invoice_id": null,
    "final_parcel_status_id": null,
    "extra_delivery_cost": 0,
    "is_replacement": 0,
    "commission": 0,
    "customer_private_note": null,
    "cell": null,
    "reference_number": null,
    "discount_value": 0,
    "size": 79507,
    "total_size": 79507,
    "contents": [],
    "promotion_usages": [],
    "companion_parcels": []
}

</code></pre>

The response contains parcel information.
{% endtab %}

{% tab title="Parcel not found" %}
Status code: <mark style="color:red;">404 not found</mark>

{% code lineNumbers="true" %}

```json
{
    "error": "Parcel not found"
}
```

{% endcode %}

This response is returned when the <mark style="color:blue;">{parcel\_id}</mark> provided in the route does not correspond to an existing parcel.
{% endtab %}

{% tab title="Cannot edit parcel" %}
Status code: <mark style="color:red;">400</mark>

{% code lineNumbers="true" %}

```json
{
    "error": "can not edit parcel in this state."
}
```

{% endcode %}

This response is returned when the <mark style="color:blue;">{parcel\_id}</mark> provided in the route corresponds to a parcel that is neither in draft nor submitted status.
{% endtab %}

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

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "error": "Failed to cancel parcel, ......."
}
```

{% endcode %}

This response is returned when a database error occurs while attempting to cancel the parcel.
{% 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 %}
