> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Using the Inventory API

## Article: Using the Inventory API

## Article Link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/inventory/using-the-inventory-api.md

## Article Content:

#  Using the Inventory API

## Step 1 - Call [Get Inventory Variants](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/inventory/get-inventory-variants.md) to retrieve product variants

::::tabs
:::REST_TAB
```curl
curl -X POST https://www.wixapis.com/stores/v2/inventoryItems/be547028-fb08-b962-75e8-3f3e56da9ee3/getVariants \
   -H 'Content-Type: application/json' \
   -H 'Authorization: <AUTH>' \
```
:::
:::SDK_TAB
```js
import { inventory } from "@wix/stores";

const inventoryId = "be547028-fb08-b962-75e8-3f3e56da9ee3"

async function getInventoryVariants(inventoryId) {
  const response = await inventory.getInventoryVariants(inventoryId);
}
```
:::
::::

From the result, you can see whether inventory is being tracked for this product:
```json
{
  "inventoryItem": {
    "id": "f8753103-0b3a-b24a-4931-50de280ac31a",
    "externalId": "078acefc-f4c5-4db5-b6ce-af21d7f53ce5",
    "productId": "078acefc-f4c5-4db5-b6ce-af21d7f53ce5",
    "trackQuantity": true,
    "variants": [
      {
        "variantId": "00000000-0000-0000-0000-000000000000",
        "inStock": true,
        "quantity": 4
      }
    ],
    "lastUpdated": "2020-08-31T20\:05\:40.348Z",
    "numericId": "1598904314932014"
  }
}
```

## Step 2 - Call [Update Inventory Status](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/inventory/update-inventory-variants.md) to update specific variant of a product 

Update whether the product inventory is tracked:
::::tabs
:::REST_TAB
```curl
curl -X PATCH https://www.wixapis.com/stores/v2/inventoryItems/078acefc-f4c5-4db5-b6ce-af21d7f53ce5 \
   -H 'Content-Type: application/json' \
   -H 'Authorization: <AUTH>' \
   -d '
       {
       	"inventoryItem": {
           "trackQuantity": false,
       	}
       }'

```
:::
:::SDK_TAB
```js
import { inventory } from "@wix/stores";

const productId = "078acefc-f4c5-4db5-b6ce-af21d7f53ce5";

const inventoryItem = {
    trackQuantity: false
  }

async function updateInventoryVariants(productId, inventoryItem) {
  const response = await inventory.updateInventoryVariants(
    productId,
    inventoryItem
  );
}

```
:::
::::

For a non-tracked product, you should update the `inStock` value:
::::tabs
:::REST_TAB
```curl
curl -X PATCH https://www.wixapis.com/stores/v2/inventoryItems/078acefc-f4c5-4db5-b6ce-af21d7f53ce5 \
   -H 'Content-Type: application/json' \
   -H 'Authorization: <AUTH>' \
   -d '
       {
       	"inventoryItem": {
       		"trackQuantity": false,
       		"variants": [
            {
                "variantId": "00000000-0000-0001-0005-9a596c8e6f10",
                "inStock": false
            }
          ]
       	}
       }'

```
:::
:::SDK_TAB
```js
import { inventory } from "@wix/stores";

const productId = "078acefc-f4c5-4db5-b6ce-af21d7f53ce5";

const inventoryItem = {
    trackQuantity: false,
    variants: [
      {
          variantId: "00000000-0000-0001-0005-9a596c8e6f10",
          inStock: false
      }
    ]
  }

async function updateInventoryVariants(productId, inventoryItem) {
  const response = await inventory.updateInventoryVariants(
    productId,
    inventoryItem
  );
}

```
:::
::::

For tracked products, you should update quantity:
::::tabs
:::REST_TAB
```curl
curl -X PATCH https://www.wixapis.com/stores/v2/inventoryItems/078acefc-f4c5-4db5-b6ce-af21d7f53ce5 \
   -H 'Content-Type: application/json' \
   -H 'Authorization: <AUTH>' \
   -d '
       {
       	"inventoryItem": {
       		"trackQuantity": false,
       		"variants": [
            {
                "variantId": "00000000-0000-0001-0005-9a596c8e6f10",
                "quantity": 4
            }
          ]
       	}
       }'

```
:::
:::SDK_TAB
```js
import { inventory } from "@wix/stores";

const productId = "078acefc-f4c5-4db5-b6ce-af21d7f53ce5";

const inventoryItem = {
    trackQuantity: false,
    variants: [
      {
          variantId: "00000000-0000-0001-0005-9a596c8e6f10",
          quantity: 4
      }
    ]
  }

async function updateInventoryVariants(productId, inventoryItem) {
  const response = await inventory.updateInventoryVariants(
    productId,
    inventoryItem
  );
}

```
:::
::::