
## Warehouse stock

`GET /v1/warehouses/:id/stock`

Returns product stock in a warehouse — one row per product that is recorded in this warehouse. Read-only: the quantity cannot be changed through this endpoint.

## Path parameters

| Parameter | Type | Description |
|----------|-----|---------|
| `id` | number | Warehouse identifier from the [warehouse list](/docs/entities/warehouses/list) |

## Query parameters

| Parameter | Type | Default | Description |
|----------|-----|-----------|---------|
| `productId` | number | - | Product identifier from the [catalog product list](/docs/entities/catalog-products/list), a canonical positive safe integer. Selects only this product within the requested warehouse |
| `limit` | number | `50` | Number of rows (up to 5000). When `limit > 50`, the response is automatically assembled from several Bitrix24 pages |
| `offset` | number | `0` | Offset from the start of the selection, **row-exact**: `offset=1` starts at the second row. Bitrix24 only moves the selection by a whole page of 50, so Vibecode fetches the covering page and trims the extra rows off the head. When the requested window is not covered by a single page, `data` arrives empty with `hasMore: true` and `meta.warnings` carries `OFFSET_BEYOND_FETCHED_PAGE`: raise `limit` |

## Examples

### curl — personal key

```bash
curl "https://vibecode.bitrix24.com/v1/warehouses/1/stock?productId=200" \
  -H "X-Api-Key: YOUR_API_KEY"
```

### curl — OAuth application

```bash
curl "https://vibecode.bitrix24.com/v1/warehouses/1/stock?productId=200" \
  -H "X-Api-Key: YOUR_APP_KEY" \
  -H "Authorization: Bearer USER_SESSION_TOKEN"
```

### JavaScript — personal key

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/warehouses/1/stock?productId=200', {
  headers: {
    'X-Api-Key': 'YOUR_API_KEY',
  },
})

const { success, data, meta } = await res.json()
```

### JavaScript — OAuth application

```javascript
const res = await fetch('https://vibecode.bitrix24.com/v1/warehouses/1/stock?productId=200', {
  headers: {
    'X-Api-Key': 'YOUR_APP_KEY',
    'Authorization': 'Bearer USER_SESSION_TOKEN',
  },
})

const { success, data, meta } = await res.json()
```

## Response fields

| Field | Type | Description |
|------|-----|---------|
| `success` | boolean | Always `true` on success |
| `data` | array | Stock rows in the warehouse |
| `data[].id` | number | Stock row identifier. Use it to read a single row with [Warehouse stock record](/docs/entities/warehouses/stock-record) |
| `data[].productId` | number | Product identifier — see the [catalog product list](/docs/entities/catalog-products/list) |
| `data[].storeId` | number | Warehouse identifier from the [warehouse list](/docs/entities/warehouses/list), equal to `id` in the path |
| `data[].amount` | number | Quantity in the warehouse. May be `null` — treat as `0` |
| `data[].quantityReserved` | number | Reserved quantity. May be `null` — treat as `0` |
| `meta.total` | number | Number of stock rows in the warehouse |
| `meta.hasMore` | boolean | Whether there are rows beyond the current page (`offset + data.length < total`). When `true`, raise `limit` (up to 5000) or move `offset` |

## Response example

```json
{
  "success": true,
  "data": [
    {
      "id": 3,
      "productId": 200,
      "storeId": 1,
      "amount": 15,
      "quantityReserved": 30
    },
    {
      "id": 5,
      "productId": 201,
      "storeId": 1,
      "amount": 54,
      "quantityReserved": null
    },
    {
      "id": 9,
      "productId": 202,
      "storeId": 1,
      "amount": null,
      "quantityReserved": null
    }
  ],
  "meta": {
    "total": 3,
    "hasMore": false
  }
}
```

## Error response example

400 — an invalid warehouse `id`:

```json
{
  "success": false,
  "error": {
    "code": "INVALID_PARAMS",
    "message": "id must be a positive integer in canonical form — digits only, no leading zero, sign, fraction or exponent"
  }
}
```

## Errors

| HTTP | Code | Description |
|------|-----|---------|
| 400 | `INVALID_PARAMS` | `id`, `productId` or `limit` is not a canonical positive integer (`12.5`, `12abc`, `1e2`, `007` are rejected before the Bitrix24 call), or `offset` is negative |
| 400 | `UNSUPPORTED_FILTER` | a `filter[]` parameter was passed — this endpoint does not support it and does not forward it to Bitrix24 |
| 401 | `TOKEN_MISSING` | The API key has no configured tokens |
| 403 | `SCOPE_DENIED` | The API key does not have the `catalog` scope |
| 502 | `BITRIX_UNAVAILABLE` | Bitrix24 is unavailable |

The full list of common API errors — [Errors](/docs/errors).

## Known specifics

**Empty warehouse.** If the warehouse has no products with stock, `data` is an empty array and `meta.total` is `0`.

## See also

- [Aggregated product stock](/docs/entities/warehouses/stock-totals)
- [Get a warehouse](/docs/entities/warehouses/get)
- [Catalog products](/docs/entities/catalog-products)
- [API reference](/docs/api-reference)

- [Warehouse stock record](/docs/entities/warehouses/stock-record)
