> 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/returns-api/grp-returns-api/code-samples.md).

# Code Samples

{% hint style="warning" icon="message-code" %}
**GRP Returns API**

Refer to the full [API reference](/api-reference/returns-api.md) for detailed endpoint and parameter descriptions.
{% endhint %}

***

## Label Requests

### Requests a preprinted label.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/label-requests
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/label-requests' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "outboundOrderReference": "123456",
    "shippingReference": "123456",
    "shopperAddress": {
      "firstName": "John",
      "lastName": "Smith",
      "address1": "2107 Massachusetts Avenue",
      "address2": "Northwood",
      "city": "Washington",
      "region": "DC",
      "postalCode": "20008",
      "countryIso": "US",
      "email": "shopper@domain.com",
      "telephone": "187456998745"
    },
    "orderItems": [
      {
        "productCode": "0607337",
        "lineItemId": "1",
        "quantity": 2,
        "productDescription": "Ultra Slim Watch"
      }
    ]
  }'
```

{% endcode %}

{% code expandable="true" %}

```
200 OK
The label has been successfully requested.
No content
```

{% endcode %}

***

## Ingestion

### Creates an Outbound Order.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/outbound-orders
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/outbound-orders' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "orderReference": "1636646500",
    "contactInformation": {
      "firstName": "John",
      "lastName": "Smith",
      "unit": "Unit 12",
      "poBox": "PO Box 1",
      "address1": "2107 Massachusetts Avenue",
      "address2": "Northwood",
      "city": "Washington",
      "region": "DC",
      "postalCode": "20008",
      "countryIso": "US",
      "email": "shipper@domain.com",
      "telephone": "187456998745",
      "cultureLanguageIso": "en-GB"
    },
    "orderItems": [
      {
        "productCode": "0607337",
        "lineItemId": "1",
        "quantity": 2,
        "productDescription": "Ultra Slim Watch",
        "productCustomsDescription": "Watch",
        "composition": "100% polyurethane",
        "countryOfOriginIso": "CN",
        "hsCode": "6211490",
        "weight": {
          "value": 0.5,
          "unit": "Kg"
        },
        "unitPrice": {
          "value": 99.99,
          "currencyCode": "USD"
        },
        "productImageUrl": "https://cdn.brand.com/img/221",
        "color": "Black",
        "size": "Small",
        "category": "Watches",
        "personalized": false,
        "dangerousGoods": false,
        "prohibitedForReturns": false
      }
    ]
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "id": "FBAFBA-1636646500",
  "orderItems": [
    {
      "id": "0013db57-885d-462b-a24c-80312a9c3207",
      "productCode": "0607377",
      "lineItemId": "1",
      "productDescription": "Gocas Ultra Slim watch"
    }
  ]
}
```

{% endcode %}

***

### Updates an Outbound Order.

{% hint style="info" icon="rectangle-api" %}
`PUT` /{identifier}/outbound-orders/{orderReference}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request PUT \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/outbound-orders/{orderReference}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "contactInformation": {
      "firstName": "John",
      "lastName": "Smith",
      "unit": "Unit 12",
      "poBox": "PO Box 1",
      "address1": "2107 Massachusetts Avenue",
      "address2": "Northwood",
      "city": "Washington",
      "region": "DC",
      "postalCode": "20008",
      "email": "shipper@domain.com",
      "telephone": "187456998745",
      "cultureLanguageIso": "en-GB"
    },
    "orderItems": [
      {
        "productCode": "0607337",
        "lineItemId": "1",
        "quantity": 2,
        "productDescription": "Ultra Slim Watch",
        "productCustomsDescription": "Watch",
        "composition": "100% polyurethane",
        "countryOfOriginIso": "CN",
        "hsCode": "6211490",
        "weight": {
          "value": 0.5,
          "unit": "Kg"
        },
        "unitPrice": {
          "value": 99.99,
          "currencyCode": "USD"
        },
        "color": "Black",
        "size": "Small",
        "category": "Watches",
        "personalized": false,
        "dangerousGoods": false,
        "prohibitedForReturns": false
      }
    ],
    "customFields": {}
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "contactInformation": {
    "firstName": "John",
    "lastName": "Smith",
    "address1": "2107 Massachusetts Avenue",
    "address2": "Northwood",
    "city": "Washington",
    "region": "DC",
    "postalCode": "20008",
    "countryIso": "US",
    "email": "shipper@domain.com",
    "telephone": "187456998745",
    "cultureLanguageIso": "en-GB"
  },
  "orderItems": [
    {
      "productCode": "0607337",
      "lineItemId": "1",
      "quantity": 2,
      "productDescription": "Ultra Slim Watch"
    }
  ],
  "customFields": {}
}
```

{% endcode %}

***

### Submits an Outbound Shipment.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/outbound-shipments
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/outbound-shipments' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "orderReference": "1636646500",
    "shippingReference": "FBB_1636646500B",
    "barcodeReference": "5 012345 678900",
    "shippingDate": "2022-01-10T11:48:58.708+00:00",
    "contactInformation": {
      "firstName": "John",
      "lastName": "Smith",
      "address1": "2107 Massachusetts Avenue",
      "city": "Washington",
      "postalCode": "20008",
      "countryIso": "US",
      "email": "shipper@domain.com",
      "telephone": "187456998745"
    },
    "shippingItems": [
      {
        "productCode": "0607337",
        "lineItemId": "1",
        "quantity": 2,
        "productDescription": "Ultra Slim Watch",
        "productCustomsDescription": "Watch",
        "composition": "100% polyurethane",
        "countryOfOriginIso": "CN",
        "hsCode": "6211490",
        "weight": {
          "value": 0.5,
          "unit": "Kg"
        },
        "unitPrice": {
          "value": 99.99,
          "currencyCode": "USD"
        },
        "productImageUrl": "https://cdn.brand.com/img/821",
        "color": "Black",
        "size": "Small",
        "category": "Watches",
        "personalized": false,
        "dangerousGoods": false,
        "prohibitedForReturns": false
      }
    ],
    "customFields": {}
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "id": "FBAFBA-1636646500",
  "shippingItems": [
    {
      "id": "0013db57-885d-462b-a24c-80312a9c3207",
      "productCode": "0607377",
      "lineItemId": "1",
      "productDescription": "Ultra Slim"
    }
  ]
}
```

{% endcode %}

***

## Returns

### Get Document.

{% hint style="info" icon="rectangle-api" %}
`GET` /{identifier}/return-orders/{returnOrderNumber}/{documentType}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/return-orders/{returnOrderNumber}/{documentType}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

> `{documentType}` must be one of: `ReturnLabel` | `LastMileLabel`

{% code expandable="true" %}

```json
{
  "orderReference": "1636646500",
  "returnOrderNumber": "5000002303",
  "contentType": "application/pdf",
  "documentStatus": "Ready",
  "label": "base64-encoded-label-content",
  "cultureLanguageIso": "en-GB",
  "documentId": "4c071f76-e27b-4291-a29f-abc123456789",
  "documentType": "ReturnLabel",
  "carrierInfoDetails": {
    "carrierId": "carrier-001",
    "carrierName": "Royal Mail",
    "carrierReference": "FBA_1636646500B",
    "carrierTrackingReference": "TRK123456789"
  }
}
```

{% endcode %}

***

### Search Return Methods.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/return-methods/{orderReference}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/return-methods/{orderReference}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "countryIso": "US",
    "cultureLanguageIso": "en-US",
    "returnItems": [
      {
        "orderItemId": "74f82404-d541-4604-8c24-8f74400f614b",
        "quantity": 1,
        "returnReasonCode": "Duplicate Shipment"
      }
    ]
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "returnMethods": [
    {
      "returnMethod": "InBox",
      "returnType": "Refund",
      "carrierIdentifier": "Royal Mail",
      "carrierServiceRouteId": "route-001",
      "isPaperlessRoute": false,
      "paidBy": "Retailer"
    }
  ]
}
```

{% endcode %}

***

### Creates a Return Order.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/orders/{orderReference}/return-orders
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/orders/{orderReference}/return-orders' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "consumerEmailAddress": "shipper@domain.com",
    "cultureLanguageIso": "fr-FR",
    "returnItems": [
      {
        "orderItemId": "74f82404-d541-4604-8c24-8f74400f614b",
        "quantity": 1,
        "returnReasonCode": "Duplicate Shipment"
      }
    ],
    "returnMethod": "InBox",
    "returnType": "Refund",
    "isPaperlessRoute": false,
    "paidBy": "Retailer",
    "carrierIdentifier": "Royal Mail",
    "dropOffLocation": {
      "id": "P73",
      "type": "ParcelShop",
      "name": "POPStation@Kebun Baru CC",
      "address1": "216",
      "address2": "Kebun Baru Community Club",
      "city": "Singapore",
      "postcode": "569897",
      "country": "Singapore"
    },
    "shippingReference": "REF6993876423",
    "barcodeReference": "5 012345 678900",
    "carrierReference": "FBA_1636646500B",
    "weight": {
      "value": 1.2,
      "unit": "Kg"
    },
    "returnAdminCentreCodeOverride": "AUCOW"
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "returnsListingsGuid": "4c071f76-e27b-4291-a29f-abc123456789",
  "returnOrderNumber": "5000002303",
  "returnType": "Refund"
}
```

{% endcode %}

***

### Gets a Return Order.

{% hint style="info" icon="rectangle-api" %}
`GET` /{identifier}/orders/{orderReference}/return-orders/{returnOrderNumber}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/orders/{orderReference}/return-orders/{returnOrderNumber}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "returnOrderNumber": "5000002303",
  "returnType": "Refund",
  "returnMethod": "InBox",
  "status": "Created",
  "returnItems": [
    {
      "id": "bb51fbf1-c86c-4066-b052-ec1515b426d1",
      "returnItemReasonCode": "Duplicate Shipment",
      "returnItemStatus": "Created",
      "rejectionReason": null
    }
  ]
}
```

{% endcode %}

***

### Updates a Return Order.

{% hint style="info" icon="rectangle-api" %}
`PUT` /{identifier}/orders/{orderReference}/return-orders/{returnOrderNumber}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request PUT \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/orders/{orderReference}/return-orders/{returnOrderNumber}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "status": "Cancelled",
    "returnItems": [
      {
        "returnItemId": "bb51fbf1-c86c-4066-b052-ec1515b426d1",
        "returnItemStatus": "Cancelled"
      }
    ]
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "returnOrderNumber": "5000002303",
  "returnType": "Refund",
  "returnMethod": "InBox",
  "status": "Cancelled"
}
```

{% endcode %}

***

### Retrieves a list of return orders.

{% hint style="info" icon="rectangle-api" %}
`GET` /{identifier}/return-orders
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/return-orders?status=Created&startUtc=2024-01-01T00%3A00%3A00Z&endUtc=2024-01-31T23%3A59%3A59Z&returnType=Refund' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

{% code expandable="true" %}

```json
[
  {
    "returnOrderNumber": "5000002303",
    "returnType": "Refund",
    "returnMethod": "InBox",
    "status": "Created",
    "returnItems": [
      {
        "id": "bb51fbf1-c86c-4066-b052-ec1515b426d1",
        "returnItemReasonCode": "Duplicate Shipment",
        "returnItemStatus": "Created",
        "rejectionReason": null
      }
    ]
  }
]
```

{% endcode %}

***

### Retrieves tracking events.

{% hint style="success" icon="rectangle-api" %}
`POST` /{identifier}/tracking-events
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request POST \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/tracking-events' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "returnOrderNumbers": [
      "5000002303",
      "5000002304"
    ]
  }'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "trackingEvents": [
    {
      "returnOrderNumber": "5000002303",
      "events": [
        {
          "eventCode": "DELIVERED",
          "eventDescription": "Package delivered",
          "eventDateTime": "2024-01-15T14:30:00Z",
          "location": "Washington DC"
        }
      ]
    }
  ]
}
```

{% endcode %}

***

## Orders

### Retrieve an outbound order.

{% hint style="info" icon="rectangle-api" %}
`GET` /{identifier}/orders/{orderReference}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/orders/{orderReference}?orderItems=all' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

> `orderItems` query parameter accepts: `all` | `not-returned`

{% code expandable="true" %}

```json
{
  "countryIso": "IE",
  "orderDate": "2022-02-09T10:01:32.9637726+00:00",
  "noOfArticlesAvailableForReturn": 2,
  "noOfArticlesUnavailableForReturn": 1,
  "returnPeriodExpired": false,
  "orderQualifiesForCancel": true,
  "items": [
    {
      "id": "74f82404-d541-4604-8c24-8f74400f614b",
      "productCode": "0607337",
      "lineItemId": "1",
      "productDescription": "Ultra Slim Watch",
      "productCustomsDescription": "Watch",
      "countryOfOriginIso": "CN",
      "hsCode": "6211490",
      "weight": {
        "value": 0.5,
        "unit": "Kg"
      },
      "unitPrice": {
        "value": 99.99,
        "currencyCode": "USD"
      },
      "productImageUrl": "https://cdn.brand.com/img/221",
      "color": "Black",
      "size": "Small",
      "category": "Watches",
      "personalized": false,
      "dangerousGoods": false,
      "prohibitedForReturns": false,
      "availableForReturns": true
    }
  ],
  "returnOrders": [],
  "shopperDetails": {
    "phoneNumber": "+10550304033",
    "locale": "en-IE",
    "firstName": "John",
    "lastName": "Doe",
    "email": "john_doe@domain.com",
    "address": {
      "address1": "2107 Massachusetts Avenue",
      "city": "Washington",
      "postalCode": "20008",
      "countryIso": "US"
    }
  }
}
```

{% endcode %}

***

## Configuration

### Retrieve country configuration.

{% hint style="info" icon="rectangle-api" %}
`GET` /{identifier}/configuration/countries/{countryIso}
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/{identifier}/configuration/countries/{countryIso}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

{% code expandable="true" %}

```json
{
  "countryIso": "US",
  "returnPeriodDays": 30,
  "supportedReturnMethods": [
    "InBox",
    "QRCode"
  ],
  "supportedLocales": [
    {
      "name": "English (Ireland)",
      "cultureInfoCode": "en-IE"
    }
  ]
}
```

{% endcode %}

***

## Location

### Get Return Location.

{% hint style="info" icon="rectangle-api" %}
`GET` /location/
{% endhint %}

{% code expandable="true" %}

```bash
curl -L \
  --request GET \
  --url 'https://returns-oms-api.sandbox.eshopworld.com/location/?identifier={identifier}&CountryCode=US&PostalCode=20008&RouteType=Inbound&City=Washington&Longitude=-77.0366&Latitude=38.9072&MaxDistanceInKms=10&MaxLocations=5&CarrierServiceRouteId=route-001' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Accept: application/json'
```

{% endcode %}

> `RouteType` must be one of: `Inbound` | `Outbound`

{% code expandable="true" %}

```json
{
  "locations": [
    {
      "id": "P73",
      "type": "ParcelShop",
      "name": "POPStation@Kebun Baru CC",
      "address1": "216",
      "address2": "Kebun Baru Community Club",
      "address3": "Ang Mo Kio Avenue 4",
      "city": "Singapore",
      "postcode": "569897",
      "sortcode": "910891",
      "region": "North-East",
      "country": "Singapore",
      "telephone": "12345678910",
      "email": "test@email.com",
      "openingTimesDescription": "24hrs",
      "openingTimes": [
        {
          "day": "Wednesday",
          "opens": "09:00",
          "closes": "18:00"
        }
      ]
    }
  ]
}
```

{% 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/returns-api/grp-returns-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.
