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

# Simulate Parcel Lifecycle

```php
POST /parcels/test-parcel
```

This API is used exclusively in the testing environment to simulate the parcel's journey in the production environment. It allows you to change the parcel's status or position, making it delivered, returned, pending, and more.

#### 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="190">Field Name</th><th width="111">Required</th><th width="89">Type</th><th width="356">Note</th></tr></thead><tbody><tr><td>parcel_code</td><td>yes</td><td>string</td><td>The <mark style="color:blue;">parcel_code</mark> of the parcel you wish to simulate.</td></tr><tr><td>parcel_status_id</td><td>yes</td><td>integer</td><td>Can be one of parcel statuses listed here <a data-mention href="/shiply-integration-documentation/general-definitions.md">General Definitions</a></td></tr><tr><td>parcel_position_id</td><td>yes</td><td>integer</td><td>Can be one of parcel positions listed here <a data-mention href="/shiply-integration-documentation/general-definitions.md">General Definitions</a></td></tr><tr><td>returned_reason_id</td><td>no</td><td>integer</td><td>Used for returns parcels only.<br>Can be one of parcel return reasons listed here <a data-mention href="/shiply-integration-documentation/general-definitions.md">General Definitions</a></td></tr></tbody></table>

Request body example:

{% code lineNumbers="true" %}

```json
{
    "parcel_code": "asnf-000-6456898", 
    "parcel_status_id": 2, 
    "parcel_position_id": 2, 
    "Shiply_API_KEY": "your_api_key",
}
```

{% endcode %}

#### Response body

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

```json
{
    "success": true,
    "failedToSubmit": false,
    "parcelResultStatus": {
        "allowed_parcels": [
            "asnf-000-6456898"
        ],
        "allowed_companion_parcels": [],
        "rejected_parcels": [],
        "rejected_companion_parcels": []
    }
}
```

The response includes <mark style="color:blue;">success</mark> flag, which indicates that the parcel is updated successfully.&#x20;
{% endtab %}

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

{% code lineNumbers="true" %}

```json
{
    "success": false,
    "error": "not found"
}
```

{% endcode %}

This response is returned when the <mark style="color:blue;">parcel\_code</mark> provided in the request body does not correspond to an existing 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 %}
