> 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

# DecrementInventory

# Package: catalogV1

# Namespace: InventoryWriteApi

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/inventory/decrement-inventory.md

## Permission Scopes:
Manage Products: SCOPE.DC-STORES.MANAGE-PRODUCTS

## Introduction

Subtracts a set number of items from inventory.

---

## REST API

### Schema

```
 Method: decrementInventory
 Description: Subtracts a set number of items from inventory.
 URL: https://www.wixapis.com/stores/v2/inventoryItems/decrement
 Method: POST
 Method parameters:
   param name: decrementData | type: array<decrementData>    | validation: minItems 1, maxItems 300
              - ONE-OF: 
                 - name: inventoryId | type: string | description: Inventory item GUID.  | validation: maxLength 36
                 - name: productId | type: string | description: Product GUID.  | validation: maxLength 36
              - name: variantId | type: string | description: Variant GUID.  | validation: format GUID
              - name: decrementBy | type: integer | description: Number to decrement inventory by.  | validation: minimum 1
              - name: preorderRequest | type: boolean | description: Whether the request to decrement the item's inventory was made as part of a purchase that includes preorder items. If true and the item is available for preorder, we allow negative inventory. If false and the item is not available for preorder, we allow regular buy flow (no negative inventory).  
 Return type: DecrementInventoryResponse
  EMPTY-OBJECT {}


```

### Examples

### DecrementInventory
```curl
~~~cURL
curl -X POST https://www.wixapis.com/stores/v2/inventoryItems/decrement \
   -H 'Content-Type: application/json' \
   -H 'Authorization: <AUTH>' \
   --data-binary '
       {
         "decrementData": [
           {
             "productId": "f007074f-d7a8-a68b-e6c1-7d7c3de021ff",
             "variantId": "00000000-0000-0001-0005-9ccb19c4e6f0",
             "decrementBy": 2
           }
         ]
       }'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.stores.inventory.decrementInventory(decrementData)
 Description: Subtracts a set number of items from inventory.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  decrementData
 Method parameters: 
   param name: decrementData | type: array<DecrementData>   | required: true | validation: minItems 1, maxItems 300
              - ONE-OF: 
                 - name: inventoryId | type: string | description: Inventory item GUID.  | validation: maxLength 36
                 - name: productId | type: string | description: Product GUID.  | validation: maxLength 36
              - name: variantId | type: string | description: Variant GUID.  | validation: format GUID
              - name: decrementBy | type: integer | description: Number to decrement inventory by.  | validation: minimum 1
              - name: preorderRequest | type: boolean | description: Whether the request to decrement the item's inventory was made as part of a purchase that includes preorder items. If true and the item is available for preorder, we allow negative inventory. If false and the item is not available for preorder, we allow regular buy flow (no negative inventory).  
 Return type: PROMISE<DecrementInventoryResponse>
  EMPTY-OBJECT {}


```

### Examples

### Decrement the inventory of a product's first variant
```javascript
/**************************************
 * Backend code - inventory.web.js/ts *
 **************************************/

import { Permissions, webMethod } from '@wix/web-methods';
import { inventory } from '@wix/stores';

export const decrementInventory = webMethod(Permissions.Anyone, (decrementData) => {
  return inventory.decrementInventory(decrementData);
});

/**************
 * Page code *
 **************/

import { decrementInventory } from 'backend/inventory.web';

async function decrementHandler() {

  const productId = "3fb6a3c8-988b-8755-04bd-ks75ae0b18ea"
  let variants = await getProductVariants(productId);

  decrementInventory(
    [{
      variantId: variants[0]._id,
      productId: productId,
      decrementBy: 1
    }])
    .then(() => {
      console.log("Inventory decremented successfully")
    })
    .catch(error => {
      // Inventory decrement failed
      console.error(error);
    })
}
```

### Decrement inventory
Decrease inventory quantity for a product variant

```javascript
import { inventory } from "@wix/stores";

const decrementData = [
  {
    productId: "c43d36c5-c35a-91ec-1c33-d28efc70d5a6",
    variantId: "00000000-0000-0000-0000-000000000000",
    decrementBy: 2
  }
];

async function decrementInventory() {
  const response = await inventory.decrementInventory(decrementData);
  return response;
}

const result = await inventory.decrementInventory(decrementData);



```

### decrementInventory (self-managed)
Self-managed SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { inventory } from '@wix/stores';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { inventory },
  // Include the auth strategy and host as relevant
});


async function decrementInventory(decrementData) {
  const response = await myWixClient.inventory.decrementInventory(decrementData);
};
```

---