# Get a product's stock

Fetches a product's stock. Works with Shopify and WooCommerce accounts.

```http
GET https://api.pozy.ai/v1/commerce/inventory
```

- Area: Commerce / Commerce
- Auth: Authorization: Bearer pz_live_...

## Query parameters

- `accountId` (string, required)
- `productId` (string, required)

## Example request

```bash
curl -X GET "https://api.pozy.ai/v1/commerce/inventory?accountId=696e0b682d0a31188e7a2ba9&productId=659773d34b353e6821202f21" \
  -H "Authorization: Bearer $POZY_API_KEY"
```

```ts
const res = await fetch("https://api.pozy.ai/v1/commerce/inventory?accountId=696e0b682d0a31188e7a2ba9&productId=659773d34b353e6821202f21", {
  headers: { Authorization: `Bearer ${process.env.POZY_API_KEY}` },
});
const data = await res.json();
if (!res.ok) throw new Error(data?.error ?? `Request failed with status ${res.status}`);
console.log(data);
```

```python
import os
import requests

resp = requests.get(
    "https://api.pozy.ai/v1/commerce/inventory",
    headers={"Authorization": f"Bearer {os.environ['POZY_API_KEY']}"},
    params={
        "accountId": "696e0b682d0a31188e7a2ba9",
        "productId": "659773d34b353e6821202f21",
    },
    timeout=30,
)
resp.raise_for_status()
print(resp.json())
```

## Response 200

- `inventory`, array of object
  - `productId`, string
  - `variantId`, string
  - `sku`, string: Can be null
  - `tracked`, boolean
  - `levels`, array of object
    - `locationId`, string
    - `available`, integer: Can be null
    - `onHand`, integer: Can be null
    - `committed`, integer: Can be null
    - `incoming`, integer: Can be null

```json
{
  "inventory": [
    {
      "productId": "659773d34b353e6821202f21",
      "variantId": "64058b146247283881d19961",
      "sku": "string",
      "tracked": true,
      "levels": [
        {
          "locationId": "6e99c3dd69982b334a43b0b2",
          "available": 1,
          "onHand": 1,
          "committed": 1,
          "incoming": 1
        }
      ]
    }
  ]
}
```
