> 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

# QueryInventoryItems

# Package: catalogV3

# Namespace: InventoryService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/inventory-items-v3/query-inventory-items?apiView=SDK.md

## Permission Scopes:
Read inventory in v3 catalog: SCOPE.STORES.INVENTORY_ITEM_READ

## Introduction

Retrieves a list of up to 1,000 inventory items, given the provided filtering, sorting, and cursor paging.

To learn about working with _Query_ endpoints, see
[API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md),
and [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md).
Learn more about the differences between [_Query_ and _Search_](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-search-query-and-list-methods.md) methods.

---

## REST API

### Schema

```
 Method: queryInventoryItems
 Description: Retrieves a list of up to 1,000 inventory items, given the provided filtering, sorting, and cursor paging.  To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), and [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md). Learn more about the differences between [_Query_ and _Search_](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-search-query-and-list-methods.md) methods.
 URL: https://www.wixapis.com/stores/v3/inventory-items/query
 Method: POST
 This method is cacheable: Responses from this method are cached for optimal performance.
 Method parameters:
   param name: query | type: QueryV2    
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 1000, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#sorting).  | validation: maxItems 10
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: locationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: variantId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: trackQuantity | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: inStock | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: quantity | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: availabilityStatus | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: productId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: preorderInfo.enabled | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.name | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.directCategoryIds | operators: $hasSome, $hasAll, $exists, $isEmpty | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.variantName | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.variantSku | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.brand.id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: stockOverrides.lowStockThreshold | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: stockOverrides.lowStock | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryInventoryItemsResponse
  - name: inventoryItems | type: array<InventoryItem> | description: List of inventory items.  | validation: minItems 1, maxItems 1000
     - ONE-OF: 
        - name: inStock | type: boolean | description: Indicates that inventory is tracked by status rather than quantity.  When set to `true`, the item is marked as available for sale without tracking exact quantities. When set to `false`, the item is marked as out of stock. This tracking method is useful for made-to-order products or items with unlimited inventory.  When using this tracking method, `trackQuantity` is `false` and preorder limits aren't supported.  
        - name: quantity | type: integer | description: Indicates that inventory is tracked by quantity.  Set this field to the number of items currently in stock. This tracking method is useful when you need to know exactly how many items are available.  When using this tracking method, `trackQuantity` is `true`. Quantity can be negative when inventory is decremented for an order that has already been paid.  | validation: minimum -99999, maximum 99999
     - name: id | type: string | description: Inventory item GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the inventory item is updated. To prevent conflicting changes, the current revision must be passed when updating the inventory item.  Ignored when creating an inventory item.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the inventory item was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the inventory item was last updated.  | read-only: true | validation: format date-time
     - name: variantId | type: string | description: Variant GUID.  | validation: format GUID, immutable
     - name: locationId | type: string | description: Stores location GUID. If not specified when creating an inventory item, the store's default location is used.  | validation: format GUID, immutable
     - name: productId | type: string | description: Product GUID.  | validation: minLength 1, maxLength 36, immutable
     - name: trackQuantity | type: boolean | description: Whether the quantity is being tracked.  | read-only: true 
     - name: availabilityStatus | type: AvailabilityStatus | description: Inventory item availability status.  | read-only: true 
         - enum:
         -     OUT_OF_STOCK: Item is out of stock. For tracked inventory, `quantity` is zero or negative and preorder isn't available.
         -     IN_STOCK: Item is in stock and available for purchase. For tracked inventory, see the `quantity` field for the exact amount in stock.
         -     PREORDER: Item is available for preorder only. Stock is zero or negative, but preorder is enabled with remaining capacity.
     - name: preorderInfo | type: PreorderInfo | description: Item preorder info.  Preorder settings are configured per inventory item, so each variant-location combination can have its own preorder configuration.  > **Note:** The product entity's `inventory.preorderStatus` and `inventory.preorderAvailability` fields reflect only the default location's preorder state.  
        - name: enabled | type: boolean | description: Whether preorder is enabled for this inventory item.  > **Note:** Preorder can't be enabled for digital products or products with subscriptions.  Default: `false`  
        - name: message | type: string | description: Message displayed to customers when the item is out of stock and preorder is enabled.  | validation: minLength 1, maxLength 250
        - name: limit | type: integer | description: Maximum number of items that can be preordered after stock reaches zero.  Supported only for inventory items with `trackQuantity = true`.  Default: `100000`  | validation: minimum 0, maximum 100000, format int32
        - name: counter | type: integer | description: Number of times this item has been preordered.  Supported only for inventory items with `trackQuantity = true`.  | read-only: true | validation: minimum 0, maximum 99999, format int32
        - name: quantity | type: integer | description: Remaining quantity available for preorder.  Supported only for items with `trackQuantity` set to `true`.  | read-only: true | validation: format int32
     - name: product | type: Product | description: Associated product and variant details.  | read-only: true 
        - name: name | type: string | description: Product name.  | validation: maxLength 80
        - name: directCategoryIds | type: array<string> | description: List of category GUIDs that this product is included in directly.  | validation: maxItems 2000, format GUID
        - name: variantName | type: string | description: Variant name.  | validation: minLength 1, maxLength 250
        - name: variantSku | type: string | description: Variant SKU (stock keeping unit).  | validation: minLength 1, maxLength 40
        - name: variantVisible | type: boolean | description: Whether the variant is visible in the store.  
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the inventory item object.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: pagingMetadata | type: PlatformPagingMetadataV2 | description: Paging metadata.  
     - name: count | type: integer | description: The number of items returned in this response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursors to navigate through result pages. Returned if cursor paging was used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### Examples

### Query Inventory Items
Query Inventory Items with filter by ids and sort by creation date

```curl
curl -X POST 'https://www.wixapis.com/stores/v3/inventory-items/query' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH>' \
-d '{
      "query": {
        "sort": [
          {
            "fieldName": "createdDate",
            "order": "DESC"
          }
        ],
        "filter": {
          "id": {
            "$in": [
              "9c346207-6467-434f-aa9e-8999c32d119d"
            ]
          }
        }
      }
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.stores.inventoryItemsV3.queryInventoryItems(query)
 Description: Retrieves a list of up to 1,000 inventory items, given the provided filtering, sorting, and cursor paging.  To learn about working with _Query_ endpoints, see [API Query Language](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md), and [Sorting and Paging](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-sorting-and-paging.md). Learn more about the differences between [_Query_ and _Search_](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-search-query-and-list-methods.md) methods.
 This method is cacheable: Responses from this method are cached for optimal performance.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: InventoryItemQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor token pointing to a page of results. Not used in the first request. Following requests use the cursor token and not `filter` or `sort`.  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 1000, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/api-reference/articles/work-with-wix-apis/data-retrieval/about-the-wix-api-query-language.md#sorting).  | validation: maxItems 10
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
 Query fields:
   - field: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: locationId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: none | aggregatable: undefined | searchable: undefined
   - field: variantId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: trackQuantity | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: inStock | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: quantity | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: availabilityStatus | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: productId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: preorderInfo.enabled | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.name | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.directCategoryIds | operators: $hasSome, $hasAll, $exists, $isEmpty | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.variantName | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: product.variantSku | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryInventoryItemsResponse>
  - name: inventoryItems | type: array<InventoryItem> | description: List of inventory items.  | validation: minItems 1, maxItems 1000
     - ONE-OF: 
        - name: inStock | type: boolean | description: Indicates that inventory is tracked by status rather than quantity.  When set to `true`, the item is marked as available for sale without tracking exact quantities. When set to `false`, the item is marked as out of stock. This tracking method is useful for made-to-order products or items with unlimited inventory.  When using this tracking method, `trackQuantity` is `false` and preorder limits aren't supported.  
        - name: quantity | type: integer | description: Indicates that inventory is tracked by quantity.  Set this field to the number of items currently in stock. This tracking method is useful when you need to know exactly how many items are available.  When using this tracking method, `trackQuantity` is `true`. Quantity can be negative when inventory is decremented for an order that has already been paid.  | validation: minimum -99999, maximum 99999
     - name: _id | type: string | description: Inventory item GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the inventory item is updated. To prevent conflicting changes, the current revision must be passed when updating the inventory item.  Ignored when creating an inventory item.  | read-only: true | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the inventory item was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the inventory item was last updated.  | read-only: true 
     - name: variantId | type: string | description: Variant GUID.  | validation: format GUID, immutable
     - name: locationId | type: string | description: Stores location GUID. If not specified when creating an inventory item, the store's default location is used.  | validation: format GUID, immutable
     - name: productId | type: string | description: Product GUID.  | validation: minLength 1, maxLength 36, immutable
     - name: trackQuantity | type: boolean | description: Whether the quantity is being tracked.  | read-only: true 
     - name: availabilityStatus | type: AvailabilityStatus | description: Inventory item availability status.  | read-only: true 
         - enum:
         -     OUT_OF_STOCK: Item is out of stock. For tracked inventory, `quantity` is zero or negative and preorder isn't available.
         -     IN_STOCK: Item is in stock and available for purchase. For tracked inventory, see the `quantity` field for the exact amount in stock.
         -     PREORDER: Item is available for preorder only. Stock is zero or negative, but preorder is enabled with remaining capacity.
     - name: preorderInfo | type: PreorderInfo | description: Item preorder info.  Preorder settings are configured per inventory item, so each variant-location combination can have its own preorder configuration.  > **Note:** The product entity's `inventory.preorderStatus` and `inventory.preorderAvailability` fields reflect only the default location's preorder state.  
        - name: enabled | type: boolean | description: Whether preorder is enabled for this inventory item.  > **Note:** Preorder can't be enabled for digital products or products with subscriptions.  Default: `false`  
        - name: message | type: string | description: Message displayed to customers when the item is out of stock and preorder is enabled.  | validation: minLength 1, maxLength 250
        - name: limit | type: integer | description: Maximum number of items that can be preordered after stock reaches zero.  Supported only for inventory items with `trackQuantity = true`.  Default: `100000`  | validation: minimum 0, maximum 100000, format int32
        - name: counter | type: integer | description: Number of times this item has been preordered.  Supported only for inventory items with `trackQuantity = true`.  | read-only: true | validation: minimum 0, maximum 99999, format int32
        - name: quantity | type: integer | description: Remaining quantity available for preorder.  Supported only for items with `trackQuantity` set to `true`.  | read-only: true | validation: format int32
     - name: product | type: Product | description: Associated product and variant details.  | read-only: true 
        - name: name | type: string | description: Product name.  | validation: maxLength 80
        - name: directCategoryIds | type: array<string> | description: List of category GUIDs that this product is included in directly.  | validation: maxItems 2000, format GUID
        - name: variantName | type: string | description: Variant name.  | validation: minLength 1, maxLength 250
        - name: variantSku | type: string | description: Variant SKU (stock keeping unit).  | validation: minLength 1, maxLength 40
        - name: variantVisible | type: boolean | description: Whether the variant is visible in the store.  
     - name: extendedFields | type: ExtendedFields | description: Custom field data for the inventory item object.  [Extended fields](https://dev.wix.com/docs/build-apps/develop-your-app/extensions/backend-extensions/schema-plugins/about-schema-plugin-extensions.md) must be configured in the app dashboard before they can be accessed with API calls.  
        - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
  - name: pagingMetadata | type: PlatformPagingMetadataV2 | description: Paging metadata.  
     - name: count | type: integer | description: The number of items returned in this response.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursors to navigate through result pages. Returned if cursor paging was used.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000


```

### Examples

### Query inventory items by ID
Retrieve specific inventory items by ID, sorted by newest first.

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

async function queryInventoryItems() {
  const response = await inventoryItemsV3.queryInventoryItems({
    sort: [
      {
        fieldName: "_createdDate",
        order: "DESC",
      },
    ],
    filter: {
      _id: {
        $in: ["a1b2c3d4-e5f6-7a8b-9c0d-e1f2a3b4c5d6"],
      },
    },
  });
  return response;
}

/* Promise resolves to:
 * {
 *   "inventoryItems": [],
 *   "pagingMetadata": {
 *     "count": 0
 *   }
 * }
 */

```

### queryInventoryItems (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 { inventoryItemsV3 } from '@wix/stores';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

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


async function queryInventoryItems(query) {
  const response = await myWixClient.inventoryItemsV3.queryInventoryItems(query);
};
```

---