# Get stock levels for multiple SKUs

URL: https://docs.sparklayer.io/developers/api/stock/get-stock-levels
Operation: `POST /api/v1/batch-fetch-stock` (operationId `getBatchStock`)
OpenAPI spec: https://docs.sparklayer.io/openapi/stock.yaml

Returns stock levels for the SKUs in `skus`, grouped by SKU. By default only the stock location with the external ID `default` is included: set `filter.all_stock_locations` to `true` to include every location, or pass `filter.stock_location_ids` to choose specific ones. SKUs with no matching stock levels are left out of the response.

`POST /api/v1/batch-fetch-stock`

**Base URLs:** `https://app.sparklayer.io` (Live), `https://test.app.sparklayer.io` (Test)

**Authentication:** send `Authorization: Bearer <access_token>` and `Site-Id: <site id>` with every request. Get the token from [Get an access token](https://docs.sparklayer.io/developers/api/core/get-an-access-token.md); see [Authentication](https://docs.sparklayer.io/developers/authentication.md).

### Example request

```bash
curl -X POST "https://app.sparklayer.io/api/v1/batch-fetch-stock" \
  -H "Authorization: Bearer $SPARKLAYER_TOKEN" \
  -H "Site-Id: $SPARKLAYER_SITE_ID" \
  -H "Content-Type: application/json" \
  -d '{
  "skus": [
    "SKU-1"
  ],
  "filter": {
    "stock_location_ids": [
      "123e4567-e89b-12d3-a456-426614174000"
    ],
    "all_stock_locations": true
  }
}'
```

Set `SPARKLAYER_TOKEN` to an access token and `SPARKLAYER_SITE_ID` to your Site ID. For the test environment, use `https://test.app.sparklayer.io`.

### Header parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `Site-Id` | string | Yes | Your SparkLayer Site ID, from Settings > API in the SparkLayer Dashboard. Example: `jones-climbing` |

### Request body (`application/json`) (required)

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `skus` | string[] | | The SKUs to get stock levels for. |
| `filter` | object | | Which stock locations to include. Without it, only the location with the external ID `default` is included. |
| `filter.stock_location_ids` | (string (uuid))[] | | |
| `filter.all_stock_locations` | boolean | | |

```json
{
  "skus": [
    "SKU-1"
  ],
  "filter": {
    "stock_location_ids": [
      "123e4567-e89b-12d3-a456-426614174000"
    ],
    "all_stock_locations": true
  }
}
```

### Responses

#### 200: The stock levels of each requested SKU that has any, grouped by SKU.

An array. Each item:

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `[].sku` | string | | Product Variant SKU |
| `[].stock_levels` | object[] | | Stock levels for the SKU at each location |
| `[].stock_levels[].stock_level` | integer (int32) | | Quantity of stock held at the location. Default: `0`. |
| `[].stock_levels[].restock_date` | string (date) \| null | | Restock Date |
| `[].stock_levels[].min_stock_level` | integer (int32) | | Allow pre-ordering / overselling up to this qty. For example, if set to -9 and stock level was 0, 9 units could be sold. Default: `0`. |
| `[].stock_levels[].created_at` | string (date-time) | | |
| `[].stock_levels[].updated_at` | string (date-time) | | |
| `[].stock_levels[].stock_location_id` | string (uuid) | | Stock Location ID (internal UUID) |
| `[].stock_levels[].stock_location_name` | string | | Stock Location Name |

```json
[
  {
    "sku": "SKU-1",
    "stock_levels": [
      {
        "stock_level": 9,
        "restock_date": "2020-01-01",
        "min_stock_level": -9,
        "created_at": "2026-01-31T09:00:00Z",
        "updated_at": "2026-01-31T09:00:00Z",
        "stock_location_id": "123e4567-e89b-12d3-a456-426614174000",
        "stock_location_name": "Main Warehouse"
      }
    ]
  }
]
```

#### Other statuses: An error. The body describes the problem: see [Errors](https://docs.sparklayer.io/developers/errors.md).

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `detail` | string | | Human-readable summary of the error |
| `status` | integer | | HTTP Status code returned from API |
| `title` | string | | Machine-readable error code |
| `type` | string \| null | | |
| `errors` | object[] \| null | | A list of errors related to the call |
| `errors[].code` | string | | Machine-readable error code |
| `errors[].property` | string | | The property the error relates to |
| `errors[].message` | string | | Human readable summary of the error |

```json
{
  "detail": "Data Validation Failed",
  "status": 400,
  "title": "invalid-api-request-contents",
  "type": "https://docs.sparklayer.io/api/errors#invalid-api-request-contents",
  "errors": [
    {
      "code": "resource-not-found",
      "property": "stock_location_id",
      "message": "stock_location_id not found"
    }
  ]
}
```
