> For the complete documentation index, see [llms.txt](https://developer.esw.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/package.md).

# Package

Create a package with Package API v4.0, handle the label outcome, then update it.

Use the Package API v4.0 to share package details with ESW: weight, dimensions, consignee, and item specifics. ESW uses them to ship, clear customs, and deliver the order, and can return shipping and returns documents in the same call. In this quick start you create a package, read the response correctly, retrieve the package, and update it while it is still pending.

**Time:** about 20 minutes

**Environment:** sandbox

### Before you begin

* Your `brandCode`, ESW's three-letter brand identifier. It is case-sensitive and must match your ESW configuration exactly. The Package API uses `brandCode` instead of `tenantCode`
* Sandbox client credentials with the `logistics.package.api.all` scope. If you have not requested a token yet, follow the [Authentication quick start](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/authentication.md)
* For a `CHECKOUT` package, an order that ESW has already confirmed. The `orderReference` must exist in ESW

{% hint style="info" %}
The Package API has its own sandbox base URL, `https://logistics-package-api.sandbox.eshopworld.com`. It is listed in the [API Base URLs](broken://pages/7FvWQMF0kTK7HGhlQfmo#api-base-urls) table on Authentication.
{% endhint %}

### Choose the order type

`orderType` is required. It describes how the order originated and decides whether you must send `packageItems`.

| `orderType`            | Use it for                                                       | `packageItems`                                                          |
| ---------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------- |
| `CHECKOUT`             | Orders placed through ESW Checkout, so ESW has the order details | Optional. If omitted, all order items are assumed to be in this package |
| `NONCHECKOUT`          | Orders placed outside ESW Checkout and delivered by ESW          | Required                                                                |
| `RETURN`               | Goods the shopper is returning to the retailer                   | Required                                                                |
| `OFFLINE`              | Manual or offline orders with no checkout session                | Required                                                                |
| `NONCHECKOUTECOMMERCE` | Non-checkout orders from an ecommerce channel                    | Required                                                                |

{% stepper %}
{% step %}

#### Get an access token

Request a token with `scope=logistics.package.api.all` using the request from the [Authentication quick start](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/authentication.md). Store it in `ESW_TOKEN`.
{% endstep %}

{% step %}

#### Create a package

This example creates a pending package for a checkout order. You complete it after packing. Save it as `package.json`.

The example does not request documents. Set `shippingDocumentationRequested` to `true` when you need ESW to generate outbound documents during creation.

{% code expandable="true" %}

```json
{
  "brandCode": "<brandCode>",
  "orderReference": "ORD-2026-0001",
  "packageReference": "PKG-2026-0001-001",
  "orderType": "CHECKOUT",
  "shippingStatus": "Pending",
  "shippingDocumentationRequested": false,
  "returnDocumentationRequested": false,
  "weight": { "weight": 0.85, "weightUnit": "KG" },
  "consignee": {
    "firstName": "Jane",
    "lastName": "Smith",
    "address1": "350 Fifth Avenue",
    "city": "New York",
    "postalCode": "10118",
    "region": "NY",
    "country": "US",
    "email": "jane.smith@example.com",
    "telephone": "+12125551234"
  },
  "dimensions": {
    "dimHeight": "10.0",
    "dimLength": "25.0",
    "dimWidth": "15.0",
    "dimWeight": "0.85",
    "dimMeasurementUnit": "CM"
  },
  "serviceLevel": "EXP2",
  "goodsDescription": "Leather goods"
}
```

{% endcode %}

```sh
curl --request POST "https://logistics-package-api.sandbox.eshopworld.com/api/v4/Package" \
  --header "Authorization: Bearer $ESW_TOKEN" \
  --header "Content-Type: application/json" \
  --data @package.json
```

Five fields are always required: `brandCode`, `orderReference`, `packageReference`, `orderType`, and `weight`. Together, `brandCode`, `orderReference`, and `packageReference` form the package's composite key. They cannot be changed after creation.

{% hint style="warning" %}
Set `shippingStatus` explicitly. `Complete` means the package is ready to ship and **locks it from further updates**. If you omit the field, ESW assumes `Complete`. Use `Pending` when you will still change the package, for example the weight or carrier.
{% endhint %}
{% endstep %}

{% step %}

#### Check creation and document outcomes

A successful create returns `200 OK`. A `200` only confirms ESW processed the request. Always read `outcome`.

If you requested shipping or return documents, also check every `documentStatus`. A package can be created when document generation fails.

```json
{
  "outcome": "PackageCreated",
  "statusMessage": "Success",
  "package": {
    "brandCode": "<brandCode>",
    "orderReference": "ORD-2026-0001",
    "packageReference": "PKG-2026-0001-001",
    "eShopPackageReference": 1234567890,
    "shippingStatus": "Pending"
  }
}
```

| `outcome`                      | What to do                                                                                                                                                                                            |
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `PackageAndLabelCreated`       | Package and label created. Print the documents                                                                                                                                                        |
| `PackageCreated`               | Package created                                                                                                                                                                                       |
| `PackageCreatedAndLabelError`  | The package exists but a label failed. Do not recreate it. Retrieve the package, then follow the label-regeneration process agreed with ESW. Escalate with the `eShopPackageReference` if it persists |
| `PackageCreatedAndLabelOnHold` | The package exists and its label is on hold                                                                                                                                                           |
| `PackageNotCreated`            | The package was not created. Read `statusMessage` and fix the request                                                                                                                                 |

Store `eShopPackageReference`. It is ESW's own identifier for the package, used for manifesting, carrier reconciliation, and tracking across systems.

**Handle documents safely.** Each entry in `shippingDocumentation` has a `type`, a `format` (`PDF` or `ZIP`), a `link`, and a `documentStatus`. Documents also arrive base64-encoded in `Document`. Print only entries with `documentStatus` set to `Created`. If you print the first entry without checking, you can miss a failed label.

| Document `type`            | Typical use                                                                                    |
| -------------------------- | ---------------------------------------------------------------------------------------------- |
| `SHIPPING_LABEL`           | Attach to the parcel at the pack station                                                       |
| `ORDER_SALES_INVOICE`      | Commercial invoice for customs, in the parcel pouch                                            |
| `ORDER_SALES_INVOICE_COPY` | Copy to attach externally in some markets                                                      |
| `PACKING_SLIP`             | Item list to include in the parcel                                                             |
| `SUPPORTING_DOCUMENTATION` | Market-specific customs or compliance documents                                                |
| `RETURN_LABEL`             | Pre-paid return label. Only with `returnDocumentationRequested`, which must be agreed with ESW |

Requesting documents makes the response slower, because ESW generates them before it replies. If your integration fetches labels separately, leave both documentation flags as `false`.
{% endstep %}

{% step %}

#### Retrieve the package

Read the package back with its identifiers. `BrandCode` and `PackageReference` are required. `OrderReference` is optional.

```sh
curl --get "https://logistics-package-api.sandbox.eshopworld.com/api/v4/Package" \
  --header "Authorization: Bearer $ESW_TOKEN" \
  --header "Accept: application/json" \
  --data-urlencode "BrandCode=<brandCode>" \
  --data-urlencode "OrderReference=ORD-2026-0001" \
  --data-urlencode "PackageReference=PKG-2026-0001-001"
```

A `200` response returns the package, including `carrierName`, `trackingUrl`, `labelUrl`, and `holdReleaseStatus` (`Release`, `Hold`, or `ReturnToRetailer`).
{% endstep %}

{% step %}

#### Update a pending package

If you created the package with `shippingStatus` set to `Pending`, update it with a `PUT` when packing finishes. Send the three identifiers plus the fields that changed. Save this payload as `update.json`.

```json
{
  "brandCode": "<brandCode>",
  "orderReference": "ORD-2026-0001",
  "packageReference": "PKG-2026-0001-001",
  "shippingStatus": "Complete",
  "weight": { "weight": 0.92, "weightUnit": "KG" },
  "dimensions": {
    "dimHeight": "8.0",
    "dimLength": "22.0",
    "dimWidth": "14.0",
    "dimWeight": "0.92",
    "dimMeasurementUnit": "CM"
  }
}
```

```sh
curl --request PUT "https://logistics-package-api.sandbox.eshopworld.com/api/v4/Package" \
  --header "Authorization: Bearer $ESW_TOKEN" \
  --header "Content-Type: application/json" \
  --data @update.json
```

{% hint style="warning" %}
`PUT /Package` returns **`201`**, not `200`. Configure clients and gateways to accept the full `200`–`299` success range. Integrations that only accept `200` can reject this successful response.
{% endhint %}

Once a package is `Complete`, you cannot update it. A `PUT` that changes nothing also returns an error.
{% endstep %}
{% endstepper %}

### Create a package for a non-checkout order

For `NONCHECKOUT` orders ESW does not hold the product details, so you must supply them. `consignee`, `shippingInfo`, and `serviceLevel` are mandatory, and `packageItems` must describe every item.

{% code expandable="true" %}

```json
{
  "brandCode": "<brandCode>",
  "orderReference": "B2B-2026-00091",
  "packageReference": "PKG-B2B-2026-00091-001",
  "orderType": "NONCHECKOUT",
  "shippingStatus": "Complete",
  "shippingDocumentationRequested": true,
  "weight": { "weight": 2.3, "weightUnit": "KG" },
  "serviceLevel": "Standard",
  "shippingInfo": { "amount": 12.0, "currency": "EUR" },
  "consignee": {
    "firstName": "Marc",
    "lastName": "Dupont",
    "address1": "12 Rue du Commerce",
    "city": "Paris",
    "postalCode": "75015",
    "country": "FR",
    "email": "marc.dupont@example.com",
    "telephone": "+33612345678"
  },
  "packageItems": [
    {
      "productCode": "SKU-00789",
      "quantity": 2,
      "productDescription": "Silk scarf, 90x90cm ivory",
      "productCustomsDescription": "100% pure silk woven scarf, hand-rolled edges",
      "countryOfOrigin": "FR",
      "hsCode": "621410",
      "weight": { "weight": 0.15, "weightUnit": "KG" },
      "unitPrice": { "amount": 149.0, "currency": "EUR" }
    }
  ]
}
```

{% endcode %}

For non-checkout orders each package item also needs `productDescription`, `productCustomsDescription`, `countryOfOrigin`, and `hsCode`. Send `hsCode` as digits only, with no periods or spaces.

`serviceLevel` is one of `POST`, `EXP1`, `EXP2`, `RussiaExpress`, `Standard`, or `Pudo`. Use a value enabled for your brand.

### Rules that prevent first-call errors

* **Identifiers.** `brandCode` is at most 3 characters. `orderReference` and `packageReference` are at most 50. Each `packageReference` must be unique within its order.
* **Weights and prices are numbers.** `weightUnit` is `KG` or `LB`. Use the string form, not `0` or `1`.
* **Dimensions are all or nothing.** Send `dimHeight`, `dimLength`, `dimWidth`, `dimWeight`, and `dimMeasurementUnit` (`CM` or `IN`) together, or none of them. The values are strings. Use `dimLength` for length and `dimWidth` for width, even though the schema descriptions label them the other way around.
* **Consignee needs eight fields** when you include it: `firstName`, `lastName`, `address1`, `city`, `postalCode`, `country`, `email`, and `telephone`. It is optional on `CHECKOUT` orders unless the shopper's address changed after checkout.
* **Package items.** Each item needs `productCode`, `quantity`, and `weight`. Use a quantity above 1 only when the `productCode` and `unitPrice` match. Two items with the same code but different prices need separate entries.
* **Back-order packages.** Set `isBackOrder` to `true` and set `parentOrderReference` to the original order reference so ESW can link the shipments.
* **Agree these with ESW first:** `carrierId`, `distributionCentre`, `hubCode`, dangerous goods, `additionalCarrierData`, and return documentation. Leave `carrierId` out unless your system has already chosen the carrier, because ESW selects it otherwise.

### Common errors

| Status | Cause                                                                                                                                 | Fix                                                                                    |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `400`  | A required field is missing, too long, or invalid, for example `weight` without `weightUnit`, or partial dimensions                   | Fix the fields named in the error list. Do not retry unchanged                         |
| `401`  | Token missing, expired, or malformed                                                                                                  | Refresh the token once and retry. Fail on a second `401`                               |
| `403`  | The token is valid but lacks permission for the brand                                                                                 | Do not retry. Ask ESW to check your brand permissions                                  |
| `404`  | Order not found for a `CHECKOUT` package                                                                                              | Check `orderReference` and that ESW has confirmed the order                            |
| `409`  | A package with this `brandCode`, `orderReference`, and `packageReference` already exists, or a `PUT` hit a package in the wrong state | `GET` the package to inspect its state. Use a new `packageReference` for a new package |
| `422`  | A business rule failed, for example weight over the service level limit                                                               | Fix the constraint in the request. The body is plain text                              |
| `500`  | Unexpected server error                                                                                                               | Retry with exponential backoff, up to three attempts. Contact ESW if it persists       |

### Next steps

* See every field and more examples in [Creating a Package](https://developer.esw.com/package-api/resources/tutorials/creating-a-package.md)
* Learn about [Package Status](https://developer.esw.com/package-api/package-api/concepts/package-status.md), [Labels and Documents](https://developer.esw.com/package-api/package-api/concepts/labels-and-documents.md), and [Manifests](https://developer.esw.com/package-api/package-api/concepts/manifests.md)
* Review every code in [HTTP Status Codes](https://developer.esw.com/package-api/package-api/http-status-codes.md)
* Return to the [Quick Start Guide](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide.md)


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/package.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
