> 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

# BulkAddItemToCategories

# Package: catalogV3

# Namespace: CategoriesService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/categories/bulk-add-item-to-categories.md

## Permission Scopes:
Category item write: SCOPE.CATEGORIES.CATEGORY_ITEM_WRITE

## Introduction

Adds a single item to multiple categories.

---

## REST API

### Schema

```
 Method: bulkAddItemToCategories
 Description: Adds a single item to multiple categories.
 URL: https://www.wixapis.com/categories/v1/bulk/categories/add-item
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  item, item.catalogItemId, item.appId, categoryIds, treeReference, treeReference.appNamespace
 Method parameters: 
   param name: categoryIds | type: array<categoryIds> | description: IDs of categories to which to add the item. | required: true | validation: minItems 1, maxItems 100, format GUID
   param name: item | type: ItemReference   | required: true 
        - name: catalogItemId | type: string | description: GUID of the item within the catalog.  For Wix Stores, this is the product GUID from the [Catalog V3 Products API](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/products-v3/introduction.md). | required: true | validation: minLength 1, maxLength 36
        - name: appId | type: string | description: GUID of the Wix app providing the catalog.  Currently, only Wix Stores is supported. Use `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` for all Wix Stores products. | required: true | validation: minLength 1, maxLength 36
   param name: treeReference | type: TreeReference   | required: true 
        - name: appNamespace | type: string | description: Namespace of the app whose catalog this category tree belongs to.  Currently, only `"@wix/stores"` is supported. | required: true | validation: minLength 4, maxLength 150
        - name: treeKey | type: string | description: Key to differentiate between multiple trees managed by the same app.  For Wix Stores, pass `null` or omit this field, as each store has only one category tree.  | validation: minLength 1, maxLength 44
 Return type: BulkAddItemToCategoriesResponse
  - name: results | type: array<BulkItemToCategoriesResult> | description: Items added by bulk action.  | validation: minItems 1, maxItems 100
     - name: itemMetadata | type: ItemMetadata | description: Bulk action metadata for category.  
        - name: id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  | validation: format GUID
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  
        - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated.  
        - name: error | type: ApplicationError | description: Details about the error in case of failure.  
           - name: code | type: string | description: Error code.  
           - name: description | type: string | description: Description of the error.  
           - name: data | type: object | description: Data related to the error.  
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: MANAGED_CATEGORY_OPERATION_NOT_ALLOWED | Description: One or more categories are managed by a specific app. Only that app can modify items in those categories.


```

### Examples

### Bulk add item to categories
Adds 1 item to 2 categories. Response includes 1 successful and 1 failed action.

```curl
curl -X POST \
  'https://www.wixapis.com/categories/v1/bulk/categories/add-item' \
  -H 'Content-Type: application/json' \
  -H 'Authorization: <AUTH>' \
  -d '{
       "item": {
         "catalogItemId": "0318a3d8-f31c-4ba3-98c7-387571a2eac4",
         "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e"
       },
       "categoryIds": ["b13e1166-fdf2-425a-a35c-d698edcbafa7", "b12487f7-cc4a-46ae-9c4f-48369f76c226"],
       "treeReference": {
         "appNamespace": "@wix/stores",
         "treeKey": null
       }
     }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.categories.categories.bulkAddItemToCategories(item, options)
 Description: Adds a single item to multiple categories.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  item, item.catalogItemId, item.appId, options.categoryIds, options.treeReference, options.treeReference.appNamespace, options
 Method parameters: 
   param name: item | type: ItemReference   | required: true 
        - name: catalogItemId | type: string | description: GUID of the item within the catalog.  For Wix Stores, this is the product GUID from the [Catalog V3 Products API](https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v3/products-v3/introduction.md). | required: true | validation: minLength 1, maxLength 36
        - name: appId | type: string | description: GUID of the Wix app providing the catalog.  Currently, only Wix Stores is supported. Use `"215238eb-22a5-4c36-9e7b-e7c08025e04e"` for all Wix Stores products. | required: true | validation: minLength 1, maxLength 36
   param name: options | type: BulkAddItemToCategoriesOptions  none | required: true 
        - name: categoryIds | type: array<string> | description: IDs of categories to which to add the item. | required: true | validation: minItems 1, maxItems 100, format GUID
        - name: treeReference | type: TreeReference | description: Category tree reference details. | required: true 
           - name: appNamespace | type: string | description: Namespace of the app whose catalog this category tree belongs to.  Currently, only `"@wix/stores"` is supported. | required: true | validation: minLength 4, maxLength 150
           - name: treeKey | type: string | description: Key to differentiate between multiple trees managed by the same app.  For Wix Stores, pass `null` or omit this field, as each store has only one category tree.  | validation: minLength 1, maxLength 44
 Return type: PROMISE<BulkAddItemToCategoriesResponse>
  - name: results | type: array<BulkItemToCategoriesResult> | description: Items added by bulk action.  | validation: minItems 1, maxItems 100
     - name: itemMetadata | type: ItemMetadata | description: Bulk action metadata for category.  
        - name: _id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  | validation: format GUID
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  
        - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated.  
        - name: error | type: ApplicationError | description: Details about the error in case of failure.  
           - name: code | type: string | description: Error code.  
           - name: description | type: string | description: Description of the error.  
           - name: data | type: object | description: Data related to the error.  
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Bulk action metadata.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  

 Possible Errors:
   HTTP Code: 403 | Status Code: PERMISSION_DENIED | Application Code: MANAGED_CATEGORY_OPERATION_NOT_ALLOWED | Description: One or more categories are managed by a specific app. Only that app can modify items in those categories.


```

### Examples

### bulkAddItemToCategories
```javascript
import { categories } from '@wix/categories';

async function bulkAddItemToCategories(item,options) {
  const response = await categories.bulkAddItemToCategories(item,options);
};
```

### bulkAddItemToCategories (with elevated permissions)
```javascript
import { categories } from '@wix/categories';
import { auth } from '@wix/essentials';

async function myBulkAddItemToCategoriesMethod(item,options) {
  const elevatedBulkAddItemToCategories = auth.elevate(categories.bulkAddItemToCategories);
  const response = await elevatedBulkAddItemToCategories(item,options);
}
```

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

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


async function bulkAddItemToCategories(item,options) {
  const response = await myWixClient.categories.bulkAddItemToCategories(item,options);
};
```

---