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

# Order

Create and confirm an order, then fulfil or cancel line items without first-call errors.

Use the Order API to create an order in ESW. Then manage its lifecycle: confirm it, fulfill line items at dispatch, or cancel eligible items or orders.

This guide creates a single-item order. It then shows the two final paths: fulfillment or cancellation.

**Time:** about 30 minutes

**Environment:** sandbox

### Before you begin

* Your `tenantCode`
* Sandbox client credentials with the Order scopes in the table below. If you have not requested a token yet, follow [Quick start: Authentication](https://developer.esw.com/getting-started/get-started-with-esw/quick-start-guide/authentication.md)
* The order type. `orderType` tells ESW where the order came from and whether a payment already exists:

| `orderType`            | Use it when                                                                                                            |
| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `Checkout`             | The shopper paid through ESW Checkout. Create the order after checkout ends and payment is pre-authorized or confirmed |
| `NonCheckoutEcommerce` | The order came from an ecommerce channel that does not use ESW Checkout                                                |
| `Offline`              | The order was placed by phone, in store, or another channel with no online checkout                                    |

This guide uses `Checkout`. Do not use order creation to change an existing order.

| Scope                              | Grants               |
| ---------------------------------- | -------------------- |
| `order.transaction.create.api.all` | Order create actions |
| `order.transaction.get.api.all`    | Get Order            |
| `order.transaction.update.api.all` | Order update actions |
| `order.transaction.cancel.api.all` | Cancel actions       |

Request a token with the scopes for the actions you call. If an activity call returns `403`, check that the token carries the scope for that action.

{% hint style="info" %}
Paths in this guide are relative to the Order API base URL in the [API Base URLs](broken://pages/7FvWQMF0kTK7HGhlQfmo#api-base-urls) table. Order API paths start with `/api/v2/Order` and do not include the `tenantCode`. Send `Authorization: Bearer <access_token>` and `Content-Type: application/json` on every request.
{% endhint %}

{% stepper %}
{% step %}

#### Create the order

Every write call needs a `transactionReference`, a UUID that is unique for that call. Generate a new one each time with any UUID v4 generator.

```http
POST /api/v2/Order
```

{% code expandable="true" %}

```json
{
  "brandOrderReference": "ORD-2026-0001",
  "transactionReference": "7F3B2C1A-9D4E-4B8A-A1C6-5E2D8F0B3A91",
  "transactionDateTime": "2026-10-01T14:23:00.000Z",
  "actionedBy": "Retailer",
  "orderType": "Checkout",
  "shopperCurrencyIso": "USD",
  "retailerCurrencyIso": "EUR",
  "deliveryCountryIso": "US",
  "shopperExperience": { "shopperCultureLanguageIso": "en-US" },
  "deliveryOption": {
    "eshopDeliveryOptionCode": "Standard",
    "priceInfo": {
      "price": { "currency": "EUR", "amount": "10.00" }
    }
  },
  "contactDetails": [
    {
      "contactDetailsType": "IsDelivery",
      "firstName": "Jane",
      "lastName": "Smith",
      "address1": "350 Fifth Avenue",
      "city": "New York",
      "region": "NY",
      "postalCode": "10118",
      "country": "US",
      "email": "jane.smith@example.com",
      "telephone": "+12125551234"
    }
  ],
  "lineItems": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "product": {
        "productCode": "SKU-00123",
        "title": "Classic Leather Wallet",
        "description": "Slim bifold wallet in full-grain cowhide leather",
        "productUnitPriceInfo": {
          "price": { "currency": "EUR", "amount": "89.95" }
        }
      }
    }
  ]
}
```

{% endcode %}

This example includes every required order field. Contact details are flat: name, address, `email`, and `telephone` sit directly on each `contactDetails` entry, and `contactDetailsType` says what the address is for. `deliveryOption` needs both `eshopDeliveryOptionCode` and `priceInfo`.

Send product and delivery prices in your **retailer currency**. ESW derives shopper-currency amounts using the order currencies and current FX rates.

A successful call returns `202 Accepted`:

```json
{
  "transactionReference": "7F3B2C1A-9D4E-4B8A-A1C6-5E2D8F0B3A91"
}
```

Store the `transactionReference`. It identifies the order creation transaction.
{% endstep %}

{% step %}

#### Confirm the order

`202 Accepted` confirms receipt. It does not confirm that ESW created the order.

Poll this endpoint every 2 seconds for up to 2 minutes, until the order exists and every article reports `Created`. Do not fulfill or cancel items before then.

Read the order back with its `brandOrderReference`:

```http
GET /api/v2/Order/ORD-2026-0001
```

Check that the order exists. Then confirm each entry in `lineItems[].articles` has status `Created`.

Each unit in a line item is tracked as an **article**.

A `404` during this window can mean order creation is still processing. After the retry window, treat a `404` as a configuration or reference error and investigate it.

| Article status | Meaning                                 |
| -------------- | --------------------------------------- |
| `Created`      | In the order and waiting for action     |
| `Shipped`      | Fulfilled and in transit to the shopper |
| `Cancelled`    | Canceled and will not be delivered      |
| {% endstep %}  |                                         |

{% step %}

#### Choose fulfillment or cancellation

The single article in this example is currently `Created`. Choose exactly one path below. An article becomes final after it is `Shipped` or `Cancelled`.

{% tabs %}
{% tab title="Fulfill the line item" %}
When your warehouse confirms the item has left the building, tell ESW. Send the `Fulfil` activity at dispatch, not when the item is picked or packed.

```http
POST /api/v2/Order/ORD-2026-0001/LineItemActivity
```

```json
{
  "lineItemId": "1",
  "quantity": 1,
  "activityStatus": "Fulfil",
  "reasonCode": "ItemFulfilled",
  "transactionReference": "B4D6E8F0-1A2C-4E5B-8C7D-9F0A1B2C3D4E",
  "transactionDateTime": "2026-10-02T09:15:00.000Z",
  "actionedBy": "Retailer"
}
```

ESW moves the article from `Created` to `Shipped`, sends shopper shipment notifications, and starts settlement processing for the fulfilled goods. `ItemFulfilled` is the only valid reason code for a `Fulfil` activity. The API spells the activity `Fulfil`.
{% endtab %}

{% tab title="Cancel the line item or order" %}
Use this path only when the article remains `Created`.

To cancel specific units, use `LineItemActivity` with `activityStatus` set to `Cancel`.

```http
POST /api/v2/Order/ORD-2026-0001/LineItemActivity
```

```json
{
  "lineItemId": "1",
  "quantity": 1,
  "activityStatus": "Cancel",
  "reasonCode": "OutOfStock",
  "transactionReference": "C5E7F901-2B3D-4F6C-9D8E-0A1B2C3D4E5F",
  "transactionDateTime": "2026-10-02T09:17:00.000Z",
  "actionedBy": "Retailer"
}
```

To cancel the entire order, use `OrderActivity`:

```http
POST /api/v2/Order/ORD-2026-0001/OrderActivity
```

```json
{
  "activityStatus": "Cancel",
  "reasonCode": "ShopperCancel",
  "transactionReference": "D6F80A12-3C4E-4A7D-8E9F-1B2C3D4E5F60",
  "transactionDateTime": "2026-10-02T10:30:00.000Z",
  "actionedBy": "Shopper"
}
```

When an order is canceled, all line items move to `Cancelled`. ESW records one `OrderCancel` transaction and updates the order `status` to `Cancelled`.

ESW starts a refund for any pre-authorized payment.
{% endtab %}
{% endtabs %}
{% endstep %}
{% endstepper %}

### Which endpoint do I use?

| Goal                                              | Endpoint                 | `activityStatus` | `reasonCode`     |
| ------------------------------------------------- | ------------------------ | ---------------- | ---------------- |
| Fulfill a line item, in full or in part           | `POST /LineItemActivity` | `Fulfil`         | `ItemFulfilled`  |
| Cancel a line item because it is out of stock     | `POST /LineItemActivity` | `Cancel`         | `OutOfStock`     |
| Cancel a line item at the shopper's request       | `POST /LineItemActivity` | `Cancel`         | `ShopperCancel`  |
| Cancel the entire order at the shopper's request  | `POST /OrderActivity`    | `Cancel`         | `ShopperCancel`  |
| Cancel the entire order for an operational reason | `POST /OrderActivity`    | `Cancel`         | `RetailerCancel` |
| Cancel the entire order because of fraud          | `POST /OrderActivity`    | `Cancel`         | `Fraud`          |

`actionedBy` records who started the action: `Retailer`, `Shopper`, or `EShopWorld`.

### Rules that prevent first-call errors

* **`lineItemId` is a string.** Send `"1"`, not `1`. It must be unique within the order, and it stays the same for the whole order lifecycle.
* **Target line items by `lineItemId`.** `productCode` also works, but it is ambiguous when the same SKU appears on more than one line.
* **`amount` is a string** with a period as the decimal separator and no symbols or thousand separators: `"89.95"`, not `89.95` or `"$89.95"`.
* **Currency and country codes are uppercase.** Use three-letter ISO 4217 codes (`USD`) and two-letter ISO 3166-1 codes (`US`).
* **`quantity` can be partial.** It must be a positive integer that does not exceed the units still in `Created` status. Split a line across several calls, each with its own `transactionReference`.
* **Article statuses are final.** You cannot change an article after it is `Shipped` or `Cancelled`.
* **`metadataItems` must be agreed with ESW** before you use them.

### Common errors

| Error                                              | Cause                                                             | Fix                                                                                  |
| -------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| `400`: `brandOrderReference` is required           | Field missing or empty                                            | Send a value with at least one character                                             |
| `400`: `transactionReference` must be a valid UUID | Malformed UUID                                                    | Use a standard UUID v4                                                               |
| `400`: `orderType` is not valid                    | Value outside the allowed list                                    | Use `Checkout`, `NonCheckoutEcommerce`, or `Offline`                                 |
| `400`: `lineItems` must contain at least one item  | Empty `lineItems` array                                           | Add at least one line item                                                           |
| `400`: `productCode` is required                   | Product has no `productCode`                                      | Give every product a non-empty `productCode`                                         |
| `400`: currency or country code invalid            | Wrong length or lowercase                                         | Use `"USD"` not `"US"`, and `"US"` not `"USA"`                                       |
| `400`: `amount` is not valid                       | `amount` sent as a number                                         | Wrap it in quotes: `"89.95"`                                                         |
| `400` on an activity call                          | `quantity` exceeds the units still available                      | Read the order and check remaining `Created` articles                                |
| `403`                                              | Token not scoped to this `tenantCode` or action                   | Request a token for the right tenant with the right scopes                           |
| `404` after order creation                         | Creation is still processing, or the tenant or reference is wrong | Retry only during the confirmation window. Then check the tenant and order reference |

### Next steps

* Read the detailed [Creating an Order](https://developer.esw.com/order-api/resources/tutorials/creating-an-order.md) and [Cancelling an Order](https://developer.esw.com/order-api/resources/tutorials/cancelling-an-order.md) tutorials.
* Explore replacements and appeasements in the [Order API overview](https://developer.esw.com/order-api/order-api/order-api.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/order.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.
