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

# Delete Parcel

```php
POST /parcels/deleteParcel
```

This API is used to delete a parcel only if it's status is "Draft".

#### 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

{% code lineNumbers="true" %}

```json
{
    "parcel_id": "asnf-000-9870", 
    "Shiply_API_KEY": "your_api_key"
}
```

{% endcode %}

{% 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 delete.
{% endhint %}

#### Response body

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

{% code lineNumbers="true" %}

```json
{
    "success": true
}
```

{% endcode %}

The response includes a <mark style="color:blue;">success</mark> field, which indicates if the parcel deleted successfully or not.
{% endtab %}

{% tab title="Not Found" %}
Status code: <mark style="color:red;">404 Not Found</mark>

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "message": "parcel not found",
    "errors": [
        "PARCEL_NOT_FOUND"
    ]
}
```

{% endcode %}

This response is returned when the parcel is not found.&#x20;
{% endtab %}

{% tab title="No permission" %}
Status code: <mark style="color:red;">403 Forbidden</mark>&#x20;

{% code lineNumbers="true" %}

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

{% endcode %}

This response is returned when the authenticated user is premium customer employee and has not the permission <mark style="color:blue;">DELETE\_PARCELS</mark>.&#x20;
{% endtab %}

{% tab title="Locked" %}
Status code: <mark style="color:red;">409 Conflict</mark>

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "message": "parcel is locked",
    "errors": [
        "LOCKED_PARCEL"
    ]
}
```

{% endcode %}

This response is returned when the parcel is locked.&#x20;
{% endtab %}

{% tab title="Invalid status" %}
Status code: <mark style="color:red;">409 Conflict</mark>

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "message": "invalid state",
    "errors": [
        "INVALID_PARCEL_STATE"
    ]
}
```

{% endcode %}

This response is returned when the parcel status is not "Draft".&#x20;
{% 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 %}

{% hint style="info" %}
When a parcel is deleted successfully, a **webhook notification** sent to you with the following body:

{\
&#x20;        "event": "parcel\_deleted",&#x20;\
&#x20;        "parcel\_code": "asnf-000-9996023" // deleted parcel code&#x20;\
}
{% endhint %}
