> 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/package-management/package-management-api/code-samples.md).

# Code Samples

{% hint style="info" icon="rectangle-api" %}
All requests require `Authorization: Bearer YOUR_JWT`.
{% endhint %}

### Retrieve package details

{% hint style="info" icon="rectangle-api" %}
`GET` `/packagemanagement/v1/{tenantCode}/orders/{orderReference}/packages/{packageReference}`
{% endhint %}

{% code fullWidth="true" expandable="true" %}

```bash
curl -L \
  --url 'https://api.sandbox.esw.com/packagemanagement/v1/TENANT/orders/ORDER-123/packages/PACKAGE-123' \
  --header 'Authorization: Bearer YOUR_JWT' \
  --header 'Accept: application/json'
```

{% endcode %}

#### Response

{% code expandable="true" %}

```json
{
  "tenantCode": "GOCAS",
  "orderReference": "ORDER-123",
  "packageReference": "PACKAGE-123",
  "eShopPackageReference": "ESHOP-PACKAGE-123",
  "eswCarrierIdentifier": "DHL",
  "carrierReference": "CARRIER-123",
  "parcelCarrierReference": "PARCEL-123",
  "shippingStatus": "Complete",
  "weight": {
    "weight": 1.34,
    "weightUnit": "kg"
  },
  "goodsDescription": "Clothing and accessories",
  "originFulfillmentCentreCode": "USDC1",
  "serviceLevel": "POST",
  "dangerousGoods": false,
  "dimensionInfo": [
    {
      "source": "Carrier",
      "length": 30,
      "width": 20,
      "height": 10,
      "measurementUnit": "cm",
      "weight": {
        "weight": 1.34,
        "weightUnit": "kg"
      }
    }
  ],
  "holdReleaseStatus": "Release",
  "palletIdentifier": "PALLET-001",
  "trackingUrl": "https://carrier.example/track/CARRIER-123",
  "consigneeAddress": {
    "firstName": "Jordan",
    "lastName": "Smith",
    "address1": "1 Main Street",
    "address2": "Apartment 2",
    "address3": "Building A",
    "city": "New York",
    "postalCode": "10001",
    "poBox": "PO Box 123",
    "region": "NY",
    "countryIso": "US",
    "email": "jordan.smith@example.com",
    "telephone": "+12125550123"
  },
  "shippingInfo": {
    "amount": 12.5,
    "currency": "USD"
  },
  "packageItems": [
    {
      "productCode": "TSHIRT-001",
      "lineItemId": 1,
      "quantity": 2,
      "productDescription": "Cotton T-shirt",
      "productCustomsDescription": "Cotton shirt",
      "countryOfOriginIso": "US",
      "weight": {
        "weight": 0.35,
        "weightUnit": "kg"
      },
      "unitPriceInfo": {
        "amount": 25,
        "currency": "USD"
      },
      "dangerousGoods": false,
      "hsCode": "610910",
      "metaData": "{\"color\":\"blue\"}"
    }
  ],
  "metaData": "{\"warehouseZone\":\"A1\"}",
  "shippingDocumentation": [
    {
      "document": "JVBERi0xLjQK...",
      "type": "ShippingLabel",
      "format": "Pdf",
      "link": "https://carrier.example/labels/PACKAGE-123",
      "documentStatus": "Created"
    }
  ]
}
```

{% endcode %}

### Create a package

{% hint style="success" icon="rectangle-api" %}
`POST` `/packagemanagement/v1/{tenantCode}/orders/{orderReference}/packages`
{% endhint %}

{% code fullWidth="true" expandable="true" %}

```bash
curl -L \
  --url 'https://api.sandbox.esw.com/packagemanagement/v1/TENANT/orders/ORDER-123/packages' \
  --header 'Authorization: Bearer YOUR_JWT' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data '{
    "packageReference": "PACKAGE-123",
    "weight": {
      "weight": 1.34,
      "weightUnit": "kg"
    },
    "shippingStatus": "Complete",
    "goodsDescription": "Clothing and accessories",
    "serviceLevel": "POST",
    "parentOrderReference": "PARENT-ORDER-123",
    "eswCarrierIdentifier": "DHL",
    "carrierReference": "CARRIER-123",
    "originFulfillmentCentreCode": "USDC1",
    "shippingInfo": {
      "amount": 12.5,
      "currency": "USD"
    },
    "insuranceInfo": {
      "amount": 100,
      "currency": "USD"
    },
    "dangerousGoodsInfo": {
      "dangerousGoods": false,
      "dangerousGoodsClassificationCode": "",
      "dangerousGoodsUnNumber": "",
      "dangerousGoodsContentId": ""
    },
    "dimensionInfo": {
      "length": 30,
      "width": 20,
      "height": 10,
      "measurementUnit": "cm",
      "weight": {
        "weight": 1.34,
        "weightUnit": "kg"
      }
    },
    "consigneeAddress": {
      "firstName": "Jordan",
      "lastName": "Smith",
      "address1": "1 Main Street",
      "address2": "Apartment 2",
      "address3": "Building A",
      "city": "New York",
      "poBox": "PO Box 123",
      "region": "NY",
      "postalCode": "10001",
      "countryIso": "US",
      "email": "jordan.smith@example.com",
      "telephone": "+12125550123"
    },
    "packageItems": [
      {
        "productCode": "TSHIRT-001",
        "lineItemId": 1,
        "quantity": 2,
        "productDescription": "Cotton T-shirt",
        "productCustomsDescription": "Cotton shirt",
        "countryOfOriginIso": "US",
        "weight": {
          "weight": 0.35,
          "weightUnit": "kg"
        },
        "unitPriceInfo": {
          "amount": 25,
          "currency": "USD"
        },
        "dangerousGoods": false,
        "hsCode": "610910",
        "metaData": "{\"color\":\"blue\"}"
      }
    ],
    "metaData": "{\"warehouseZone\":\"A1\"}"
  }'
```

{% endcode %}

#### Response

{% code expandable="true" %}

```json
{
  "outcome": "PackageAndLabelCreated",
  "status": "Success",
  "package": {
    "tenantCode": "GOCAS",
    "orderReference": "ORDER-123",
    "packageReference": "PACKAGE-123",
    "eShopPackageReference": "ESHOP-PACKAGE-123",
    "eswCarrierIdentifier": "DHL",
    "carrierReference": "CARRIER-123",
    "shippingStatus": "Complete",
    "weight": {
      "weight": 1.34,
      "weightUnit": "kg"
    },
    "goodsDescription": "Clothing and accessories",
    "originFulfillmentCentreCode": "USDC1",
    "serviceLevel": "POST",
    "dangerousGoods": false,
    "holdReleaseStatus": "Release",
    "trackingUrl": "https://carrier.example/track/CARRIER-123"
  }
}
```

{% endcode %}

### Update package details

{% hint style="warning" icon="rectangle-api" %}
`PUT` `/packagemanagement/v1/{tenantCode}/orders/{orderReference}/packages/{packageReference}`
{% endhint %}

{% code fullWidth="true" expandable="true" %}

```bash
curl -L \
  --request PUT \
  --url 'https://api.sandbox.esw.com/packagemanagement/v1/TENANT/orders/ORDER-123/packages/PACKAGE-123' \
  --header 'Authorization: Bearer YOUR_JWT' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json' \
  --data '{
    "shippingStatus": "Complete",
    "weight": {
      "weight": 1.34,
      "weightUnit": "kg"
    },
    "carrierReference": "CARRIER-123",
    "carrierServiceDescription": "DHL Express Worldwide",
    "originFulfillmentCentreCode": "USDC1",
    "eswCarrierIdentifier": "DHL",
    "serviceLevel": "EXP2",
    "consigneeAddress": {
      "address1": "1 Main Street",
      "address2": "Apartment 2",
      "address3": "Building A",
      "city": "New York",
      "poBox": "PO Box 123",
      "postalCode": "10001",
      "region": "NY"
    },
    "dimensionInfo": {
      "length": 30,
      "width": 20,
      "height": 10,
      "measurementUnit": "cm",
      "weight": {
        "weight": 1.34,
        "weightUnit": "kg"
      }
    },
    "metaData": "{\"warehouseZone\":\"A2\"}"
  }'
```

{% endcode %}

#### Response

{% code expandable="true" %}

```json
{
  "outcome": "PackageUpdated",
  "status": "Success",
  "package": {
    "tenantCode": "TENANT",
    "orderReference": "ORDER-123",
    "packageReference": "PACKAGE-123",
    "eShopPackageReference": "ESHOP-PACKAGE-123",
    "eswCarrierIdentifier": "DHL",
    "carrierReference": "CARRIER-123",
    "shippingStatus": "Complete",
    "weight": {
      "weight": 1.34,
      "weightUnit": "kg"
    },
    "serviceLevel": "EXP2",
    "trackingUrl": "https://carrier.example/track/CARRIER-123",
    "consigneeAddress": {
      "firstName": "Jordan",
      "lastName": "Smith",
      "address1": "1 Main Street",
      "city": "New York",
      "postalCode": "10001",
      "region": "NY",
      "countryIso": "US",
      "email": "jordan.smith@example.com",
      "telephone": "+12125550123"
    },
    "metaData": "{\"warehouseZone\":\"A2\"}"
  }
}
```

{% endcode %}

### Delete a package

{% hint style="danger" icon="rectangle-api" %}
`DELETE` `/packagemanagement/v1/{tenantCode}/orders/{orderReference}/packages/{packageReference}`
{% endhint %}

{% code fullWidth="true" expandable="true" %}

```bash
curl -L \
  --request DELETE \
  --url 'https://api.sandbox.esw.com/packagemanagement/v1/TENANT/orders/ORDER-123/packages/PACKAGE-123' \
  --header 'Authorization: Bearer YOUR_JWT' \
  --header 'Accept: application/json'
```

{% endcode %}

#### Response

{% code expandable="true" %}

```
204 No Content
No content
```

{% endcode %}

### Retrieve package documentation

{% hint style="info" icon="rectangle-api" %}
`GET` `/packagemanagement/v1/{tenantCode}/documentation/{eShopPackageReference}`
{% endhint %}

Retrieve the documentation records for an eShop package reference.

{% code fullWidth="true" expandable="true" %}

```bash
curl -L \
  --url 'https://api.sandbox.esw.com/packagemanagement/v1/TENANT/documentation/ESHOP-PACKAGE-123' \
  --header 'Authorization: Bearer YOUR_JWT' \
  --header 'Accept: application/json'
```

{% endcode %}

#### Response

{% code expandable="true" %}

```json
[
  {
    "document": "JVBERi0xLjQK...",
    "type": "ShippingLabel",
    "format": "Pdf",
    "link": "https://carrier.example/labels/PACKAGE-123",
    "documentStatus": "Created"
  }
]
```

{% endcode %}


---

# 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://developer.esw.com/package-management/package-management-api/code-samples.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.
