# Inventory

Your stock in our warehouse, per product: what is on hand, what is set aside for orders and shipments, what is free to use, and what is on the way from purchase orders. Dropship orders use it automatically; ship it in bulk with [`POST /v1/shipments`](https://docs.rephut.com/developers/reference/shipments#request-a-shipment-from-your-stock).

The list contains every product that has stock on hand, stock set aside, or stock on the way. It is sorted by SKU.

## List your stock

`GET /v1/inventory`

Products with stock in our warehouse, stock set aside for orders, or stock on the way. Sorted by SKU.

| Property | Value |
|---|---|
| URL | `https://api.rephut.com/v1/inventory` |
| Permission | `catalog:read` |
| Access | Read: counts towards the read limit and works while your account is on hold |
| Idempotency-Key | Not used |
| Success | 200 OK |

### Query parameters

| Field | Type | Required | Description |
|---|---|---|---|
| `page` | integer | No | Page number. See [Pagination](https://docs.rephut.com/developers/pagination). From 1 to 10,000. Default: `1`. |

### Headers

| Header | Required | Value |
|---|---|---|
| `Authorization` | Yes | `Bearer <your API key>`. See [Authentication](https://docs.rephut.com/developers/authentication). |

### Response

`200` with `data`, a list of objects with the fields below (up to one page), and `meta` with `total`, `page`, `limit` and `pageCount`. See [Pagination](https://docs.rephut.com/developers/pagination).

| Field | Type | Description |
|---|---|---|
| `productId` | string | Our product id. Use it in [`POST /v1/shipments/estimate`](https://docs.rephut.com/developers/reference/shipments#estimate-shipping-for-a-shipment-from-your-stock) and [`POST /v1/shipments`](https://docs.rephut.com/developers/reference/shipments#request-a-shipment-from-your-stock). |
| `sku` | string | Our SKU. |
| `name` | string | Product name in English. |
| `attributes` | string | Variant details in English, for example colour and size. |
| `customerSku` | string | Your SKU for this product when it is mapped; empty otherwise. |
| `onHandQty` | integer | Units in our warehouse. |
| `reservedQty` | integer | Units set aside for orders and shipments. |
| `availableQty` | integer | Units free to use: `onHandQty` minus `reservedQty`. |
| `incomingQty` | integer | Bought but not yet in our warehouse. |

### Errors

| Code | HTTP status | Meaning |
|---|---|---|
| `invalid_api_key` | 401 | The API key is missing, malformed, revoked or no longer valid. |
| `account_action_required` | 403 | Sign in to the portal and finish the required account steps first. |
| `api_not_enabled` | 403 | API access is not enabled for this account. |
| `insufficient_scope` | 403 | The API key does not have the permission this call needs. |
| `validation_failed` | 422 | The input is not valid. `details` lists each field and the reason. |
| `rate_limited` | 429 | Too many requests. Wait for the number of seconds in Retry-After. |
| `internal_error` | 500 | Unexpected error. Quote X-Request-Id when you contact support. |

Handle errors by `code`. See [Errors](https://docs.rephut.com/developers/errors).

```bash example=curl
curl 'https://api.rephut.com/v1/inventory?page=1' \
  -H "Authorization: Bearer $FULFILLBOT_API_KEY"
```

```js example=node
const response = await fetch("https://api.rephut.com/v1/inventory?page=1", {
  headers: {
    Authorization: `Bearer ${process.env.FULFILLBOT_API_KEY}`,
  },
});
const result = await response.json();
console.log(response.status, result);
```

```python example=python
import os

import requests

response = requests.get(
    "https://api.rephut.com/v1/inventory?page=1",
    headers={
        "Authorization": f"Bearer {os.environ['FULFILLBOT_API_KEY']}",
    },
    timeout=30,
)
print(response.status_code, response.json())
```

```json example=response status=200
{
  "success": true,
  "data": [
    {
      "productId": "cm3p4r0d0001xyz7k2m9q8w1",
      "sku": "FB-10231-BLK-M",
      "name": "Cotton crew neck T-shirt",
      "attributes": "Black / M",
      "customerSku": "TEE-BLK-M",
      "onHandQty": 160,
      "reservedQty": 20,
      "availableQty": 140,
      "incomingQty": 200
    }
  ],
  "meta": {
    "total": 1,
    "page": 1,
    "limit": 50,
    "pageCount": 1
  }
}
```
