> 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/inventory/resources/tutorials/retrieving-all-ats-inventory.md).

# Retrieving All ATS Inventory

Retrieve the complete Available-to-Sell (ATS) inventory feed for all applicable SKUs and apply it to a local availability store.

This tutorial retrieves ATS quantities for every applicable SKU with the GET endpoint and applies them to a local store.

**Before you begin:** you need your retailer identifier and credentials from integration setup. See [Authentication](/inventory/inventory-api/authentication.md).

{% stepper %}
{% step %}

#### Get an access token

Request a token and keep the `access_token` value. Send it in the `Authorization` header as `Bearer {access_token}`.
{% endstep %}

{% step %}

#### Call the GET endpoint

No request body and no SKU list are needed.

```bash
curl --request GET 'https://api.sandbox.esw.com/inventory/v1/{identifier}/inventory-availability' \
  --header 'Authorization: Bearer {access_token}'
```

{% endstep %}

{% step %}

#### Apply the quantities, and only on success

On `200`, write each `quantity` against its `sku`. On any other status, leave stored availability unchanged. A failed request is never zero inventory.

```javascript
const response = await fetch(
  `https://api.sandbox.esw.com/inventory/v1/${identifier}/inventory-availability`,
  { headers: { Authorization: `Bearer ${accessToken}` } }
);

if (!response.ok) {
  // Do not write zero. Keep the last known availability and handle the status.
  throw new Error(`Inventory request failed: ${response.status}`);
}

const availability = await response.json(); // [{ sku, quantity }]
for (const { sku, quantity } of availability) {
  await saveAvailability(sku, quantity);
}
```

{% endstep %}

{% step %}

#### Handle errors

* `401` / `403`: handle authentication and authorization failures explicitly.
* `404` / `409`: contact ESW so the fulfillment configuration can be reviewed.
* `500`: apply the agreed retry approach and avoid uncontrolled retries.

See [Response Codes](/inventory/inventory-api/response-codes.md).
{% endstep %}
{% endstepper %}

To check specific SKUs for a delivery market instead, see [Retrieving ATS for Specific SKUs](/inventory/resources/tutorials/retrieving-ats-for-specific-skus.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/inventory/resources/tutorials/retrieving-all-ats-inventory.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.
