> 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/order-api/order-api/use-cases.md). Agents can also search and read this documentation through its [MCP server](https://developer.esw.com/~gitbook/mcp).

# Use cases

End-to-end Order API scenarios, from creation to appeasements and finance ops.

End-to-end scenarios showing how the Checkout API could be used.

## Quick Reference

Every call used across the scenarios below, with its purpose and whether it's safe for an agent to run autonomously (see [agentic consumption](#id-07-agentic-consumption-where-to-checkpoint) for the human-in-the-loop reasoning behind each checkpoint).

| Method | Endpoint                           | Purpose                                   | Agent Safety                                         |
| ------ | ---------------------------------- | ----------------------------------------- | ---------------------------------------------------- |
| POST   | `/Order`                           | Create an order                           | Safe                                                 |
| GET    | `/Order/{ref}`                     | Poll order status                         | Safe — read-only                                     |
| POST   | `/Order/{ref}/Allocation`          | Assign line items to fulfilment centre(s) | **Checkpoint** — triggers label generation           |
| POST   | `/Order/{ref}/LineItemActivity`    | Fulfil or cancel a specific line item     | Safe (not separately addressed below — see note)     |
| POST   | `/Order/{ref}/OrderActivity`       | Cancel the entire order                   | **Checkpoint** — reason code changes the refund path |
| POST   | `/Order/{ref}/Replacement`         | Batch replacement, ships new inventory    | **Checkpoint**                                       |
| POST   | `/Order/{ref}/LineItem`            | Single line item replacement              | **Checkpoint** — same class as `Replacement`         |
| POST   | `/Order/{ref}/Appeasement`         | Order-level refund                        | **Checkpoint**                                       |
| POST   | `/Order/{ref}/LineItemAppeasement` | Line-item refund                          | **Checkpoint**                                       |
| PUT    | `/Order/{ref}/ContactDetails`      | Update delivery contact                   | Safe                                                 |
| PATCH  | `/Order/{ref}/LineItem`            | Product substitution                      | Safe                                                 |
| POST   | `/Order/{ref}/Comment`             | Internal note, no order-state effect      | Safe                                                 |

{% hint style="info" icon="lightbulb" %}

#### Before picking a `reasonCode`, `activityStatus`, `actionedBy`, `appeasementsType`, or `contactDetailsType` value

The Decision Tables page has a "use this when / do not use this when" row for every allowed value of these fields — it's the authoritative source for which value to pick, not the examples on this page. The examples below show one valid combination each; Decision Tables shows the full decision boundary.
{% endhint %}

{% hint style="warning" icon="triangle-exclamation" %}

#### `actionedBy` has four values in Decision Tables, three in the Create Order schema

Decision Tables lists `Retailer`, `Shopper`, `EShopWorld`, and `ThirdParty` as valid `actionedBy` values. The `OrderCreate` request schema's `ActionedBy` enum only defines `Retailer`, `Shopper`, and `EShopWorld` — no `ThirdParty`. If `ThirdParty` is valid on activity/cancellation endpoints but not on order creation, that's worth stating explicitly wherever `actionedBy` is documented; if it's meant to be valid everywhere, the `Create an Order` schema needs updating. Flagging rather than guessing which side is correct.
{% endhint %}

{% hint style="warning" icon="bug-slash" %}

#### Error handling — general

Per the `Create an Order` schema, the API returns `202` (accepted, not yet processed), `400` (validation failure, body is an array of `{code, message}` errors — not retryable without changes), `401` (missing/expired token — refresh once and retry), `403` (forbidden), `404` (not found), and `500` (server error — retry with backoff). A `202` means accepted for async processing, not completed — always confirm final state with a follow-up `GET` rather than treating `202` as done.
{% endhint %}

## 01 - Order Lifecycle

### Checkout Order — Standard Flow

#### **Business Scenario**

A shopper in Ireland completes checkout on your site. They purchase two items, pay with Apple Pay in EUR, and select standard delivery. Your OMS must create this order in ESW for cross-border fulfilment, duty calculation, and payment capture.

{% stepper %}
{% step %}

#### Submit the order with full details

Include the brand order reference, both currency ISOs, the delivery country, contact details (delivery + payment), all line items with pricing, delivery option, and payment info.

{% code title="HTTP POST /api/v2/Order — full checkout order" expandable="true" %}

```http
POST /api/v2/Order
Authorization: Bearer {token}
Content-Type: application/json

{
  "brandOrderReference": "WEB-20241014-8821",
  "orderType": "Checkout",
  "transactionReference": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "transactionDateTime": "2024-10-14T15:56:18.455Z",
  "actionedBy": "Shopper",
  "shopperCurrencyIso": "EUR",
  "retailerCurrencyIso": "USD",
  "deliveryCountryIso": "IE",
  "shopperExperience": {
    "shopperCultureLanguageIso": "en-IE",
    "registeredProfileId": "CUST-44170"
  },
  "contactDetails": [
    {
      "contactDetailsType": "IsDeliveryAndPayment",
      "firstName": "Aoife",
      "lastName": "Murphy",
      "address1": "42 Grafton Street",
      "city": "Dublin",
      "postalCode": "D02 HX65",
      "country": "IE",
      "email": "aoife.murphy@example.com",
      "telephone": "+353851234567"
    }
  ],
  "lineItems": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "product": {
        "title": "Merino Wool Sweater",
        "description": "100% merino wool crew neck, charcoal",
        "productCode": "MRN-SW-CH-M",
        "hsCode": "611011",
        "countryOfOriginIso": "NZ",
        "color": "charcoal",
        "size": "M",
        "productUnitPriceInfo": {
          "price": { "currency": "EUR", "amount": "119.00" }
        }
      }
    },
    {
      "lineItemId": "2",
      "quantity": 2,
      "product": {
        "title": "Cotton T-Shirt",
        "description": "Organic cotton crew tee, white",
        "productCode": "TEE-WHT-L",
        "productUnitPriceInfo": {
          "price": { "currency": "EUR", "amount": "35.00" }
        }
      }
    }
  ],
  "deliveryOption": {
    "eshopDeliveryOptionCode": "Standard",
    "type": "Home",
    "vatRate": 23,
    "priceInfo": { "price": { "currency": "EUR", "amount": "9.99" } }
  },
  "payment": {
    "method": "ApplePay",
    "last4Digits": "4242",
    "paymentAttemptRef": "1CBA8F0C-F7EE-437C-A450-B63ADD08CA5A",
    "priceInfo": { "price": { "currency": "EUR", "amount": "198.99" } }
  },
  "weight": { "weightTotal": 0.85, "weightUnit": "KG" }
}
```

{% endcode %}
{% endstep %}

{% step %}

#### Store the transaction reference

The `202 Accepted` response returns the `transactionReference`. Persist this in your OMS for tracking and idempotent retries.
{% endstep %}

{% step %}

#### Poll for confirmation

Use `GET /Order/WEB-20241014-8821` after a short delay. The order should appear with `status: "Received"` and each article in `"Created"` status.
{% endstep %}
{% endstepper %}

Sequence summary: `POST /Order` → store `transactionReference` (no API call) → `GET /Order/{ref}` (poll until `Received`)

### Non-Checkout & Offline Orders

#### **Business Scenario**

Your warehouse management system creates orders directly from B2B purchase orders or phone orders. Use `NonCheckoutEcommerce` or `Offline` order types so ESW knows not to expect a pre-existing payment authorization.

{% code title="JSON — Key differences for non-checkout" %}

```jsonc
{
  "orderType": "NonCheckoutEcommerce", // or "Offline" for phone/in-store
  "actionedBy": "Retailer",
  "actionedByUser": "warehouse-bot@acme.com"
}
```

{% endcode %}

{% hint style="warning" %}
`NonCheckoutEcommerce` orders typically require payment detail collection after creation. The `canAllowNonCheckOutRefund` flag on the order response controls whether refunds can be issued without a prior checkout payment.
{% endhint %}

### Multi-Item Cart with Metadata

#### **Business Scenario**

A shopper orders 5 different products. Two are customized (monogrammed), one is return-prohibited (underwear), and the retailer needs to pass custom metadata (loyalty tier, gift wrap preference) that drives downstream processing logic.

{% code title="JSON — Line item with customization and metadata" expandable="true" %}

```json
{
  "lineItemId": "3",
  "quantity": 1,
  "product": {
    "title": "Monogrammed Leather Wallet",
    "description": "Full grain leather bifold, initials: AOM",
    "productCode": "WLLT-LTH-BLK",
    "isReturnProhibited": false,
    "isCustomized": true,
    "productUnitPriceInfo": { "price": { "currency": "EUR", "amount": "85.00" } },
    "weightInfo": { "weightTotal": 0.15, "weightUnit": "KG" }
  },
  "metadataItems": [
    { "name": "giftWrap", "value": "premium-gold" },
    { "name": "loyaltyTier", "value": "platinum" }
  ]
}
```

{% endcode %}

### Ship-from-Store & PUDO

#### **Business Scenario**

The shopper selects in-store pickup (PUDO) or the order ships from a physical retail store instead of a central warehouse. You must provide `originDetails` with the store address and use `IsStoreDelivery` for the contact type.

{% code title="JSON — Origin details and PUDO delivery" expandable="true" %}

```jsonc
{
  "deliveryOption": {
    "eshopDeliveryOptionCode": "PUDO",
    "type": "Store",
    "priceInfo": { "price": { "currency": "EUR", "amount": "0.00" } }
  },
  "originDetails": {
    "originType": "Store",
    "address1": "15 Henry Street",
    "city": "Dublin",
    "country": "IE",
    "email": "henry-st-store@acme.com"
  },
  "contactDetails": [
    {
      "contactDetailsType": "IsStoreDelivery"
      // ... store address ...
    }
  ]
}
```

{% endcode %}

## 02 - Fulfilment

### Warehouse Allocation

#### **Business Scenario**

After order creation, your fulfilment engine determines which warehouse(s) will ship each item. You must allocate each line item to a fulfilment country and optionally a specific fulfilment centre ID. This triggers downstream shipping label generation.

{% code title="HTTP POST /api/v2/Order/WEB-20241014-8821/Allocation" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/Allocation
Content-Type: application/json

{
  "transactionReference": "b2c3d4e5-f6a7-8901-bcde-f12345678901",
  "transactionDateTime": "2024-10-14T16:30:00Z",
  "actionedBy": "Retailer",
  "actionedByUser": "wms-allocator@acme.com",
  "lineItems": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "articles": [
        {
          "activityStatus": "Allocate",
          "fulfilmentCountryIso": "GB",
          "fulfilmentCentreId": "DC-LONDON-01"
        }
      ]
    },
    {
      "lineItemId": "2",
      "quantity": 2,
      "articles": [
        {
          "activityStatus": "Allocate",
          "fulfilmentCountryIso": "GB",
          "fulfilmentCentreId": "DC-LONDON-01"
        },
        {
          "activityStatus": "Allocate",
          "fulfilmentCountryIso": "NL",
          "fulfilmentCentreId": "DC-AMSTERDAM-02"
        }
      ]
    }
  ]
}
```

{% endcode %}

{% hint style="info" %}
Split allocation: Line item 2 has two articles allocated to different warehouses. This is common when inventory is split across DCs. Each article becomes an independent fulfilment unit.
{% endhint %}

### Split Shipment Fulfilment

#### **Business Scenario**

DC-LONDON-01 ships the sweater and one t-shirt today. DC-AMSTERDAM-02 will ship the second t-shirt tomorrow. You fulfil each batch separately using LineItemActivity with `Fulfil` status, targeting specific quantities.

{% code title="HTTP — First shipment — London DC" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/LineItemActivity
Content-Type: application/json

{
  "activityStatus": "Fulfil",
  "reasonCode": "ItemFulfilled",
  "lineItemId": "1",
  "quantity": 1,
  "transactionReference": "c3d4e5f6-...",
  "transactionDateTime": "2024-10-15T09:00:00Z",
  "actionedBy": "Retailer"
}

# Then a second call for line item 2, quantity 1
```

{% endcode %}

### Partial Fulfilment with Remaining Cancel

#### **Business Scenario**

A customer ordered 3 units of a product. The warehouse can only ship 2. You fulfil 2 and cancel the remaining 1 as out of stock — two separate `LineItemActivity` calls, one with `Fulfil` and one with `Cancel`.

#### Step 1 — Fulfil available:

* `activityStatus: "Fulfil"`, `quantity: 2`, `reasonCode: "ItemFulfilled"`

#### Step 2 — Cancel remainder:

* `activityStatus: "Cancel"`, `quantity: 1`, `reasonCode: "OutOfStock"`

## 03 - Cancellation

### Shopper Cancels Entire Order

#### **Business Scenario**

The shopper contacts support within the cancellation window requesting a full order cancellation. The CS agent triggers a full order cancel via OrderActivity. All line items and articles are cancelled, and any captured payment is refunded.

{% code title="HTTP POST /api/v2/Order/WEB-20241014-8821/OrderActivity" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/OrderActivity
Content-Type: application/json

{
  "activityStatus": "Cancel",
  "reasonCode": "ShopperCancel",
  "transactionReference": "d4e5f6a7-...",
  "transactionDateTime": "2024-10-14T17:00:00Z",
  "actionedBy": "Shopper",
  "actionedByUser": "aoife.murphy@example.com"
}

# 202 Accepted — full order cancellation queued
```

{% endcode %}

### Fraud Team Cancels Order

#### **Business Scenario**

Fraud detection flags an order. The fraud team cancels it using `reasonCode: "Fraud"` and `actionedBy: "Retailer"`. This triggers a different refund path than a shopper cancellation

{% code title="JSON — Fraud cancellation payload" expandable="true" %}

```json
{
  "activityStatus": "Cancel",
  "reasonCode": "Fraud",
  "actionedBy": "Retailer",
  "actionedByUser": "fraud-team@acme.com",
  "transactionReference": "e5f6a7b8-...",
  "transactionDateTime": "2024-10-14T17:15:00Z"
}
```

{% endcode %}

{% hint style="info" %}
A third order-level reason exists per Decision Tables: `RetailerCancel`, for operational or commercial cancellations initiated by the retailer rather than the shopper or a fraud review. Not shown as its own example here, but it follows the same `OrderActivity` shape with `reasonCode: "RetailerCancel"`.
{% endhint %}

### Line Item Cancellation

#### **Business Scenario**

The shopper wants to keep the sweater but cancel both t-shirts. You use LineItemActivity targeting line item 2 with the full quantity. Line item 1 remains unaffected.

{% code overflow="wrap" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/LineItemActivity
```

{% endcode %}

{% code overflow="wrap" expandable="true" %}

```json
{
  "activityStatus": "Cancel",
  "reasonCode": "ShopperCancel",
  "lineItemId": "2",
  "quantity": 2,          
  "transactionReference": "f6a7b8c9-...",
  "transactionDateTime": "2024-10-14T17:30:00Z",
  "actionedBy": "Shopper"
}
```

{% endcode %}

### Out-of-Stock Cancellation

#### **Business Scenario**

Cancel just 1 unit using `reasonCode: "OutOfStock"` with `quantity: 1`. The remaining article continues through fulfilment normally.

{% code title="JSON — Single article out-of-stock cancel" expandable="true" %}

```jsonc
{
  "activityStatus": "Cancel",
  "reasonCode": "OutOfStock",
  "lineItemId": "2",
  "quantity": 1, // only 1 of 2
  "actionedBy": "Retailer",
  "actionedByUser": "inventory-sync@acme.com"
  // ... transaction fields ...
}
```

{% endcode %}

## 04 - Replacements

### Lost Package — Full Reship

#### **Business Scenario**

Carrier tracking shows the package was lost in transit. The CS team creates a replacement order for all items. Since the package is lost, `exchange: false` — no return is expected from the shopper.

<pre class="language-jsonc" data-title="HTTP POST /api/v2/Order/WEB-20241014-8821/Replacement" data-expandable="true"><code class="lang-jsonc">POST /api/v2/Order/WEB-20241014-8821/Replacement
Content-Type: application/json

{
  "reasonCode": "LostPackage",
<strong>  "exchange": false, // no return needed — package is lost
</strong>  "items": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "replacementOrderDetails": {
        "replacementBrandOrderReference": "WEB-20241014-8821-R1",
        "replacementLineItemId": "1"
      }
    },
    {
      "lineItemId": "2",
      "quantity": 2,
      "replacementOrderDetails": {
        "replacementBrandOrderReference": "WEB-20241014-8821-R1",
        "replacementLineItemId": "2"
      }
    }
  ],
  "transactionReference": "a7b8c9d0-...",
  "transactionDateTime": "2024-10-20T11:00:00Z",
  "actionedBy": "Retailer",
  "actionedByUser": "cs-agent-lisa@acme.com"
}
</code></pre>

### Damaged Goods — Exchange

#### **Business Scenario**

The sweater arrived with a defect. The shopper wants an exchange — same item, sent again. Since the shopper will return the damaged one, set `exchange: true`. This creates a return expectation in the system.

<pre class="language-jsonc" data-title="JSON — Exchange replacement" data-expandable="true"><code class="lang-jsonc">{
  "reasonCode": "DamagedGoods",
<strong>  "exchange": true, // shopper returns the damaged item
</strong>  "items": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "replacementOrderDetails": {
        "replacementBrandOrderReference": "WEB-20241014-8821-EX1",
        "replacementLineItemId": "1"
      }
    }
  ]
  // ... transaction fields ...
}
</code></pre>

### Wrong Item Sent — Different Product

#### **Business Scenario**

The warehouse shipped a size L instead of size M. The replacement order sends the correct size. Use `replacementProduct` to specify the new product details when the replacement differs from the original.

{% code title="JSON — Replacement with different product" %}

```jsonc
{
  "reasonCode": "IncorrectProduct",
  "exchange": true,
  "items": [
    {
      "lineItemId": "1",
      "quantity": 1,
      "replacementOrderDetails": {
        "replacementBrandOrderReference": "WEB-20241014-8821-EX2",
        "replacementLineItemId": "1",
        "replacementProduct": {
          "productCode": "MRN-SW-CH-M",
          "name": "Merino Wool Sweater",
          "description": "100% merino wool crew neck, charcoal, size M",
          "colour": "charcoal",
          "size": "M"
        }
      }
    }
  ]
  // ... transaction fields ...
}
```

{% endcode %}

### Single Line Item Replacement

#### **Business Scenario**

Replacing a single line item rather than a batch — use the dedicated `POST /LineItem` endpoint. Useful when your OMS processes replacements one item at a time.

{% code title="HTTP POST /api/v2/Order/{ref}/LineItem" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/LineItem
Content-Type: application/json

{
  "lineItemId":"1",
  "productCode":"277906",
  "quantity":1,
  "reasonCode":"ShortShip",
  "replacementOrderDetails":{
    "replacementBrandOrderReference":"653241",
    "replacementLineItemId":"1",
    "replacementProduct":{
      "productCode":"277906",
      "name":"PINK LOUNGE WOMENS KNIT",
      "description":"PINK:PFCT FZ PINK LOUNGE WOMENS KNIT 60% COTTON 40% POLYESTER OUTERWEAR",
      "colour":"Red",
      "size":"S"
    }
  },
  "settlementReference":"657100201",
  "transactionReference":"B312A3EA-6YR4-437C-4821-747E7AS787D7",
  "transactionDateTime":"2020-07-23T09:21:39.181Z",
  "actionedBy":"Retailer",
  "actionedByUser":"johnsmith@test.com"
}
```

{% endcode %}

## 05 - Appeasements

### Late Delivery — Shipping Refund

#### **Business Scenario**

The order arrived 5 days late. Company policy grants a full shipping refund as appeasement. Use order-level appeasement with `type: "Shipping"` and the shipping charge amount.

{% code title="HTTP POST /api/v2/Order/{ref}/Appeasement" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/Appeasement
Content-Type: application/json

{
  "type": "Shipping",
  "reasonCode": "LateArrival",
  "transaction": { "amount": 9.99, "currency": "EUR" },
  "fullAppeasement": false,
  "transactionReference": "c9d0e1f2-...",
  "transactionDateTime": "2024-10-25T14:00:00Z",
  "actionedBy": "Retailer",
  "actionedByUser": "cs-agent-john@acme.com"
}
```

{% endcode %}

### Missed Promotion — Merchandise Credit

#### **Business Scenario**

A shopper complains they didn't receive a promotional discount that should have applied. CS issues a merchandise appeasement for the difference — €15 off.

{% code title="JSON — Promo appeasement" %}

```jsonc
{
  "type": "Merchandise",
  "reasonCode": "PromoAppeasement",
  "transaction": { "amount": 15.0, "currency": "EUR" },
  "fullAppeasement": false
  // ... transaction fields ...
}
```

{% endcode %}

### Full Order Appeasement

#### **Business Scenario**

A VIP customer had a terrible experience — wrong items, late delivery, and poor communication. As a goodwill gesture, issue a full order appeasement for the maximum refundable amount in ESW.

{% code title="JSON — Full appeasement — system calculates amount" expandable="true" %}

```jsonc
{
  "type": "Order",
  "reasonCode": "Appeasement",
  "transaction": {
    "amount": "30.00",
    "currency": "EUR"
  },
  "fullAppeasement": "True",
  "settlementReference": "657100201",
  "transactionReference": "AD5F2B2C-7AC1-474A-B421-1905C1A0D113",
  "transactionDateTime": "2020-07-23T09:34:02.758Z",
  "actionedBy": "Retailer",
  "actionedByUser": "johnsmith@test.com"
}
```

{% endcode %}

### Item-Level Appeasement

#### **Business Scenario**

One of the two t-shirts has a small stain. Rather than a full return, offer the shopper a 50% refund on that item. Use LineItemAppeasement to target a specific product and quantity with a partial amount.

{% code title="HTTP POST /api/v2/Order/{ref}/LineItemAppeasement" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/LineItemAppeasement
Content-Type: application/json

{
  "lineItemId": "2",
  "quantity": 1,
  "reasonCode": "Appeasement",
  "transaction": { "amount": 17.5, "currency": "EUR" },
  "fullAppeasement": false,
  "transactionReference": "e1f2a3b4-...",
  "transactionDateTime": "2024-10-27T09:00:00Z",
  "actionedBy": "Retailer"
}
```

{% endcode %}

## 06 - Updates & Ops

### Delivery Address Correction

#### **Business Scenario**

The shopper realizes they entered the wrong apartment number. Before the order ships, the CS agent updates the delivery address. Only `IsDelivery` contact type is supported for updates.

{% code title="HTTP PUT /api/v2/Order/{ref}/ContactDetails" expandable="true" %}

```jsonc
PUT /api/v2/Order/WEB-20241014-8821/ContactDetails
Content-Type: application/json

{
  "transactionReference": "f2a3b4c5-...",
  "transactionDateTime": "2024-10-14T18:00:00Z",
  "actionedBy": "Shopper",
  "contactDetails": {
    "contactDetailsType": "IsDelivery",
    "address1": "42 Grafton Street",
    "address2": "Apt 7B", // corrected
    "city": "Dublin",
    "postalCode": "D02 HX65",
    "email": "aoife.murphy@example.com",
    "telephone": "+353851234567"
  }
}
```

{% endcode %}

### Product Substitution (Line Item Update)

#### **Business Scenario**

The ordered charcoal sweater is discontinued. The warehouse offers a navy alternative at the same price. Use PATCH LineItem to swap the product code and record the reason.

<pre class="language-jsonc" data-title="HTTP PATCH /api/v2/Order/{ref}/LineItem" data-expandable="true"><code class="lang-jsonc">PATCH /api/v2/Order/WEB-20241014-8821/LineItem
Content-Type: application/json

{
  "lineItemId": "1",
<strong>  "productCode": "MRN-SW-NV-M", // new: navy instead of charcoal
</strong>  "quantity": 1,
  "reasonCode": "ProductSubstituted",
  "transactionReference": "a3b4c5d6-...",
  "transactionDateTime": "2024-10-15T08:00:00Z",
  "actionedBy": "Retailer",
  "actionedByUser": "wms-substitution@acme.com"
}
</code></pre>

### Customer Service Agent Notes

**Business Scenario**

During a support call, the CS agent records internal notes on the order — the shopper mentioned the item is a gift, prefers email contact only, etc. These comments are persisted on the order for other agents to see.

{% code title="HTTP POST /api/v2/Order/{ref}/Comment" expandable="true" %}

```http
POST /api/v2/Order/WEB-20241014-8821/Comment
Content-Type: application/json

{
  "comment": "Shopper called — this is a gift order. Contact by email only. Do NOT include prices on packing slip.",
  "user": "cs-agent-lisa@acme.com"
}
```

{% endcode %}

{% code title="200 OK response example" %}

```json
{
  "user": "cs-agent-lisa@acme.com",
  "time": "2024-10-14T18:15:00Z"
}
```

{% endcode %}

### 07 - Agentic Consumption: Where to Checkpoint

{% hint style="info" %}
Human-in-the-loop exceptions
{% endhint %}

#### **Business Scenario**

An AI agent is orchestrating Order API calls on behalf of an OMS or a support workflow — creating orders, allocating stock, handling cancellations, replacements, and appeasements without a human driving each call. Most of this API is safe to run autonomously. A small number of calls should require human confirmation before an agent executes them unsupervised.

{% hint style="warning" %}
**Allocation** (`POST /Order/{ref}/Allocation`) — triggers downstream shipping label generation. A wrong fulfilment center or split-quantity assignment generates a real label before the mistake can be caught.
{% endhint %}

{% hint style="warning" %}
**Order cancellation** (`POST /Order/{ref}/OrderActivity`) — `reasonCode: "ShopperCancel"` and `reasonCode: "Fraud"` trigger different refund paths (a third reason, `RetailerCancel`, exists too — see Decision Tables). An agent selecting the wrong reason code has direct financial consequences, not just a data error.
{% endhint %}

{% hint style="warning" %}
**Replacement** (`POST /Order/{ref}/Replacement`, and the single-item `POST /Order/{ref}/LineItem` variant) — ships new inventory. When `exchange: false` (lost package), no return is expected from the shopper at all, so a misjudged scenario has no recovery path.
{% endhint %}

{% hint style="warning" %}
**Appeasement** (`POST /Order/{ref}/Appeasement`, `POST /Order/{ref}/LineItemAppeasement`) — moves cash to the customer. A `fullAppeasement: true` request has the system calculate the amount automatically, with no confirmation step of its own.
{% endhint %}

{% hint style="info" %}
Everything else in this API — order creation and status polling, `ContactDetails` updates, `LineItem` substitution, and `Comment` — is safe for an agent to execute without a confirmation gate, since a wrong call can be corrected with another call rather than causing irreversible financial or logistical impact. `LineItemActivity` (`Fulfil`/`Cancel`) isn't explicitly covered by this list either way — worth a deliberate decision if agents will drive it, since marking a line item `Fulfil` isn't something a follow-up call can take back.
{% endhint %}


---

# 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/order-api/order-api/use-cases.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.
