> For the complete documentation index, see [llms.txt](https://docs.akinon.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akinon.com/technical-guides/oms/commands/shipment/recreate-shipment-of-the-package-command.md).

# Recreate Shipment of the Package Command

This command deletes a package's existing shipment and shipping label and generates a **new AWB, shipment and shipping label** through the cargo company integration, using the selected (or currently assigned) cargo company.

### <mark style="color:red;">Business Logic</mark>

* Deletes the package's current shipment and shipping label records.
* Generates a brand new AWB, shipment and shipping label via the cargo company integration.
* If no cargo company is provided, the package's current cargo company is reused.

### <mark style="color:red;">Difference from</mark> <mark style="color:red;"></mark><mark style="color:red;">`UPDATE_SHIPMENT_INFO_OF_THE_PACKAGE`</mark>

* `UPDATE_SHIPMENT_INFO_OF_THE_PACKAGE` updates the existing shipment with a tracking number you provide (in-place update).
* `RECREATE_SHIPMENT_OF_THE_PACKAGE` produces a **new** AWB through the cargo company integration, replacing the shipment and label entirely. This is the command to use when a package was assigned to the wrong cargo company.

### <mark style="color:red;">Applicable Package States</mark>

* Valid states: `packed`, `shipped`, `delivery_failed`, `attempted_delivery`.
* The package remains in the same state after the command runs.
* `ready_for_customer_pickup` is **not** supported (in-store flow — no cargo regeneration is required).

### <mark style="color:red;">Endpoint</mark>

```http
POST /api/v1/oms/packages/{packageId}/command/
```

Recreate the shipment and shipping label of a package.

#### Prerequisites

* Package must be in `packed`, `shipped`, `delivery_failed`, or `attempted_delivery` state.
* Package must have an existing shipment.
* A valid state transition for the `RECREATE_SHIPMENT_OF_THE_PACKAGE` command must exist for the package's current state.
* Either `transition` (transition ID) or `slug` (transition slug) must be provided in the request body.

#### Request Requirements

* If `transition` is provided, `slug` is not required.
* If `slug` is provided, `transition` is not required.
* At least one of `transition` or `slug` must be present.
* `input_parameters.cargo_company` is **optional**. When omitted, the package's current cargo company is used to generate the new AWB.

#### Side Effects

* The existing shipment and shipping label are replaced with new ones.
* A new AWB (tracking number) and label are produced by the cargo company integration.

#### Response

* Returns **HTTP 204 No Content** on success.
* The regenerated package/shipment can be retrieved separately if needed.

### <mark style="color:red;">Authentication</mark>

Token-based authentication. Send the token in the request header:

```http
Authorization: Token <api-token>
```

### <mark style="color:red;">Path Parameters</mark>

| Name        | In   | Type    | Required | Description                                    |
| ----------- | ---- | ------- | -------- | ---------------------------------------------- |
| `packageId` | path | integer | Yes      | The ID of the package to recreate shipment for |

### <mark style="color:red;">Request Body</mark>

| Field                            | Type    | Required | Description                                                                                  |
| -------------------------------- | ------- | -------- | -------------------------------------------------------------------------------------------- |
| `input_parameters`               | object  | Yes      | Command input parameters.                                                                    |
| `input_parameters.cargo_company` | integer | No       | ID of an active cargo company to use for the new AWB. If omitted, the current one is reused. |
| `transition`                     | integer | No\*     | State transition ID to execute (required if `slug` is not provided).                         |
| `slug`                           | string  | No\*     | State transition slug to execute (required if `transition` is not provided).                 |

At least one of `transition` or `slug` is required.

### <mark style="color:red;">Examples</mark>

{% tabs %}
{% tab title="Reuse existing cargo company (with slug)" %}

```json
{
  "input_parameters": {},
  "slug": "RECREATE_SHIPMENT_OF_THE_PACKAGE"
}
```

{% endtab %}

{% tab title="Switch to a different cargo company (with slug)" %}

```json
{
  "input_parameters": {
    "cargo_company": 42
  },
  "slug": "RECREATE_SHIPMENT_OF_THE_PACKAGE"
}
```

{% endtab %}

{% tab title="With transition ID" %}

```json
{
  "input_parameters": {
    "cargo_company": 42
  },
  "transition": 931
}
```

{% endtab %}
{% endtabs %}

### <mark style="color:red;">Responses</mark>

#### `204 No Content`

Shipment recreated successfully. No response body.

#### `400 Bad Request`

Invalid parameters or validation errors.

Missing transition/slug:

```json
{
  "non_field_errors": [
    "transition or slug required."
  ]
}
```

#### `404 Not Found`

No package matches the given ID, or no command exists with the supplied transition ID/slug.

{% tabs %}
{% tab title="Package not found" %}

```json
{
  "detail": "No Package matches the given query."
}
```

{% endtab %}

{% tab title="Command not found" %}

```json
{
  "detail": "No commands with this id or slug"
}
```

{% endtab %}
{% endtabs %}

#### `406 Not Acceptable`

The command could not be completed. The response contains a descriptive message.

{% tabs %}
{% tab title="Package has no shipment" %}

```json
{
  "message": "package_commands_100_6:Package object has no shipment! Package: 12345"
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.akinon.com/technical-guides/oms/commands/shipment/recreate-shipment-of-the-package-command.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
