> 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/shopify/shopify-native/integration-workflow/cancellations.md).

# Cancellations

### A. Order-Level Cancellations <a href="#a-order-level-cancellations" id="a-order-level-cancellations"></a>

#### 1. Shopify to ESW

When an order is cancelled in Shopify, the cancellation is sent to ESW through the **Cancel Order API**, ensuring both platforms remain synchronized.

## Cancels the entire order, that is, all line items in the order are cancelled.

> Method to cancel an order by brand order reference

```json
{"openapi":"3.0.1","info":{"title":"Order Transaction API","version":"v2"},"security":[{"Bearer":[]}],"components":{"securitySchemes":{"Bearer":{"type":"apiKey","description":"Please insert JWT with Bearer into field","name":"Authorization","in":"header"}},"schemas":{"OrderActivityRequest":{"required":["actionedBy","activityStatus","reasonCode","transactionDateTime","transactionReference"],"type":"object","properties":{"activityStatus":{"$ref":"#/components/schemas/ActivityStatus"},"reasonCode":{"$ref":"#/components/schemas/OrderActivityReasonCode"},"settlementReference":{"type":"string","description":"Unique reference number of the settlement transaction. When the Retailer is using “self-billing” Settlement model, this field should be sent.","nullable":true},"transactionReference":{"type":"string","description":"Unique reference number of the transaction","format":"uuid"},"transactionDateTime":{"type":"string","description":"The date/time logged by the retailer for the creation of the order transaction in UTC.","format":"date-time"},"actionedBy":{"$ref":"#/components/schemas/ActionedBy"},"actionedByUser":{"type":"string","description":"Identifier for the person who initiated the action, for example, John Smith or johnsmith@test.com.","nullable":true}},"additionalProperties":false,"description":"OrderActivityRequest"},"ActivityStatus":{"enum":["Cancel","Fulfil"],"type":"string","description":"ActivityStatus"},"OrderActivityReasonCode":{"enum":["ShopperCancel","RetailerCancel","Fraud"],"type":"string","description":"Order Activity Reason Code"},"ActionedBy":{"enum":["Retailer","Shopper","EShopWorld","ThirdParty"],"type":"string","description":"To define Who initiated the request"},"OrderTransactionApiResponse":{"type":"object","properties":{"transactionReference":{"type":"string","description":"Unique reference number of the transaction.\r\nIf the retailer sends this data, eSW will honor it. If the retailer does not send this data, eSW will generate the GUID for the transaction.","format":"uuid"}},"additionalProperties":false,"description":"Response from Order API"},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error Identifier code","format":"int32"},"message":{"type":"string","description":"Error Message","nullable":true}},"additionalProperties":false,"description":"Error Response"},"ProblemDetails":{"type":"object","properties":{"type":{"type":"string","nullable":true},"title":{"type":"string","nullable":true},"status":{"type":"integer","format":"int32","nullable":true},"detail":{"type":"string","nullable":true},"instance":{"type":"string","nullable":true}},"additionalProperties":{}}}},"paths":{"/v2/{tenantCode}/Order/{brandOrderReference}/OrderActivity":{"post":{"tags":["Order"],"summary":"Cancels the entire order, that is, all line items in the order are cancelled.","description":"Method to cancel an order by brand order reference","operationId":"OrderActivity","parameters":[{"name":"brandOrderReference","in":"path","description":"Retailer's unique reference number for the order","required":true,"schema":{"type":"string"}},{"name":"tenantCode","in":"path","required":true,"schema":{"type":"string"}}],"requestBody":{"description":"Order Activity Details","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderActivityRequest"}}}},"responses":{"202":{"description":"The request is accepted, but not processed.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrderTransactionApiResponse"}}}},"400":{"description":"The request is invalid","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Error"}}}}},"401":{"description":"The request is unauthorized","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"403":{"description":"The request is forbidden","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"404":{"description":"No order found","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}},"500":{"description":"Internal server error"},"default":{"description":"Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ProblemDetails"}}}}}}}}}
```

#### 2. ESW to Shopify

When ESW cancels an order, the update is communicated to Shopify using the GraphQL `orderCancel` mutation, so both systems display the same order status.

### B. Item-Level Cancellations <a href="#b-item-level-cancellations" id="b-item-level-cancellations"></a>

#### 1. Shopify Item Cancellations

Cancelling specific items in Shopify triggers the ESW Item Cancel API, updating ESW.

#### 2. ESW Item Cancellations

When ESW cancels individual items, Shopify is updated using the `refundCreate` API.


---

# 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/shopify/shopify-native/integration-workflow/cancellations.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.
