> 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

# BulkAssignEvents

# Package: eventManagement

# Namespace: CategoryManagement

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/events/event-management/categories/bulk-assign-events.md

## Permission Scopes:
Manage Events - all permissions: SCOPE.DC-EVENTS-MEGA.MANAGE-EVENTS

## Introduction

Assigns events to multiple categories at once.

---

## REST API

### Schema

```
 Method: bulkAssignEvents
 Description: Assigns events to multiple categories at once.
 URL: https://www.wixapis.com/events/v1/bulk/categories/events
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  categoryId, eventId
 Method parameters: 
   param name: categoryId | type: array<categoryId> | description: A list of category GUIDs to which events should be assigned. | required: true | validation: minItems 1, maxItems 10, format GUID
   param name: eventId | type: array<eventId> | description: A list of events GUIDs. | required: true | validation: minItems 1, maxItems 1, format GUID
 Return type: BulkAssignEventsResponse
  - name: results | type: array<BulkCategoryResult> | description: Bulk assign results.  
     - name: itemMetadata | type: ItemMetadata | description: Metadata.  
        - name: id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  
        - 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: item | type: Category | description: Category.  
        - name: id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
        - name: name | type: string | description: Category name.  | validation: minLength 1, maxLength 30
        - name: createdDate | type: string | description: Date and time when category was created.  | read-only: true | validation: format date-time
        - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category.  | read-only: true 
           - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category.  | validation: format int32
           - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded.  | validation: format int32
        - name: states | type: array<State> | description: Category state.  Default: `MANUAL`.  **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`.  | validation: maxItems 3
             - enum:
             -     MANUAL: Categoty is created manually by the user.
             -     AUTO: Category is created automatically.
             -     RECURRING_EVENT: Category is created automatically when publishing recurring events.
             -     HIDDEN: Category is hidden.
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata of results.  
     - 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.  


```

### Examples

### BulkAssignEvents
```curl
~~~cURL
curl -X POST 'https://www.wixapis.com/events/v1/bulk/categories/events' \
-H 'Content-Type: application/json' \
-H 'Authorization: <AUTH TOKEN>' \
-d '{
  "categoryId": [
    "e9779de3-a085-4255-b3a6-9559990d4436",
    "027ac25d-cc64-4eb1-8666-4ea53cf7f134"
   ],
  "eventId": [
    "539a564e-48d2-4eac-8e14-d7a91be6b1c2"
  ]
}'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.events.categories.bulkAssignEvents(categoryId, options)
 Description: Assigns events to multiple categories at once.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  categoryId, options.eventId, options
 Method parameters: 
   param name: categoryId | type: array<string> | description: A list of category GUIDs to which events should be assigned. | required: true | validation: minItems 1, maxItems 10, format GUID
   param name: options | type: BulkAssignEventsOptions  none | required: true 
        - name: eventId | type: array<string> | description: A list of events GUIDs. | required: true | validation: minItems 1, maxItems 1, format GUID
 Return type: PROMISE<BulkAssignEventsResponse>
  - name: results | type: array<BulkCategoryResult> | description: Bulk assign results.  
     - name: itemMetadata | type: ItemMetadata | description: Metadata.  
        - name: _id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  
        - 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: item | type: Category | description: Category.  
        - name: _id | type: string | description: Category GUID.  | read-only: true | validation: format GUID
        - name: name | type: string | description: Category name.  | validation: minLength 1, maxLength 30
        - name: _createdDate | type: Date | description: Date and time when category was created.  | read-only: true 
        - name: counts | type: CategoryCounts | description: The total number of draft and published events assigned to the category.  | read-only: true 
           - name: assignedEventsCount | type: integer | description: Total number of draft events assigned to the category.  | validation: format int32
           - name: assignedDraftEventsCount | type: integer | description: Total number of published events assigned to the category. Deleted events are excluded.  | validation: format int32
        - name: states | type: array<State> | description: Category state.  Default: `MANUAL`.  **Note:** The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission scope is required to use states other than `MANUAL`.  | validation: maxItems 3
             - enum:
             -     MANUAL: Categoty is created manually by the user.
             -     AUTO: Category is created automatically.
             -     RECURRING_EVENT: Category is created automatically when publishing recurring events.
             -     HIDDEN: Category is hidden.
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata of results.  
     - 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.  


```

### Examples

### Bulks assign events to multiple categories (with elevated permissions)
```javascript
import { categories } from '@wix/events';
import { auth } from '@wix/essentials';

const elevatedBulkAssignEvents = auth.elevate(categories.bulkAssignEvents);

/* 
 * Sample categoryId value: ["89d3e8d4-45bc-4439-9e74-7e21b3418c88", "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"]
 * Sample options value: 
 * {
 *  "eventId": ["4e5e4adb-9778-4171-a9bb-44e27834ac89"]
 * }
 */

export async function myBulkAssignEventsFunction(categoryId, options) {
  try {
    const assignedEvents = await elevatedBulkAssignEvents(categoryId, options);
    console.log('Bulk assign results: ', assignedEvents);
    return assignedEvents;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "results": [
 *     {
 *       "itemMetadata": {
 *         "originalIndex": 0,
 *         "success": true,
 *         "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"
 *       },
 *       "item": {
 *         "name": "workshop",
 *         "states": [
 *           "MANUAL"
 *         ],
 *         "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a",
 *         "_createdDate": "2022-12-13T11:03:19.174Z"
 *       }
 *     },
 *     {
 *       "itemMetadata": {
 *         "originalIndex": 1,
 *         "success": true,
 *         "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88"
 *       },
 *       "item": {
 *         "name": "technology",
 *         "states": [
 *           "MANUAL"
 *         ],
 *         "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88",
 *         "_createdDate": "2023-07-12T11:07:35.776Z"
 *       }
 *     }
 *   ],
 *   "bulkActionMetadata": {
 *     "totalSuccesses": 2,
 *     "totalFailures": 0,
 *     "undetailedFailures": 0
 *   }
 * }
 */
```

### Bulks assign events to multiple categories
```javascript
import { categories } from '@wix/events';

/* 
 * Sample categoryId value: ["89d3e8d4-45bc-4439-9e74-7e21b3418c88", "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"]
 * Sample options value: 
 * {
 *  "eventId": ["4e5e4adb-9778-4171-a9bb-44e27834ac89"]
 * }
 */

export async function myBulkAssignEventsFunction(categoryId, options) {
  try {
    const assignedEvents = await categories.bulkAssignEvents(categoryId, options);
    console.log('Bulk assign results: ', assignedEvents);
    return assignedEvents;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "results": [
 *     {
 *       "itemMetadata": {
 *         "originalIndex": 0,
 *         "success": true,
 *         "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"
 *       },
 *       "item": {
 *         "name": "workshop",
 *         "states": [
 *           "MANUAL"
 *         ],
 *         "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a",
 *         "_createdDate": "2022-12-13T11:03:19.174Z"
 *       }
 *     },
 *     {
 *       "itemMetadata": {
 *         "originalIndex": 1,
 *         "success": true,
 *         "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88"
 *       },
 *       "item": {
 *         "name": "technology",
 *         "states": [
 *           "MANUAL"
 *         ],
 *         "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88",
 *         "_createdDate": "2023-07-12T11:07:35.776Z"
 *       }
 *     }
 *   ],
 *   "bulkActionMetadata": {
 *     "totalSuccesses": 2,
 *     "totalFailures": 0,
 *     "undetailedFailures": 0
 *   }
 * }
 */
```

### Bulk assign events to multiple categories (with elevated permissions)
```javascript
import { categories } from '@wix/events';
import { auth } from '@wix/essentials';

const elevatedBulkAssignEvents = auth.elevate(categories.bulkAssignEvents);

/* 
 * Sample categoryId value: ["89d3e8d4-45bc-4439-9e74-7e21b3418c88", "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"]
 * Sample options value: 
 * {
 *  "eventId": ["4e5e4adb-9778-4171-a9bb-44e27834ac89"]
 * }
 */

export async function myBulkAssignEventsFunction(categoryId, options) {
  try {
    const assignedEvents = await elevatedBulkAssignEvents(categoryId, options);
    console.log('Bulk assign results:', assignedEvents);
    return assignedEvents;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *  "results": [
 *   {
 *     "itemMetadata": {
 *       "originalIndex": 0,
 *       "success": true,
 *       "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"
 *     },
 *     "item": {
 *       "name": "workshop",
 *       "states": [
 *         "MANUAL"
 *       ],
 *       "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a",
 *       "_createdDate": "2022-12-13T11:03:19.174Z"
 *     }
 *   },
 *   {
 *     "itemMetadata": {
 *      "originalIndex": 1,
 *       "success": true,
 *       "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88"
 *     },
 *     "item": {
 *       "name": "technology",
 *       "states": [
 *         "MANUAL"
 *       ],
 *       "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88",
 *       "_createdDate": "2023-07-12T11:07:35.776Z"
 *     }
 *   }
 * ],
 * "bulkActionMetadata": {
 *   "totalSuccesses": 2,
 *   "totalFailures": 0,
 *   "undetailedFailures": 0
 * }
 * }
 */
```

### Bulk assign events to multiple categories
```javascript
import { categories } from '@wix/events';

/* 
 * Sample categoryId value: ["89d3e8d4-45bc-4439-9e74-7e21b3418c88", "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"]
 * Sample options value: 
 * {
 *  "eventId": ["4e5e4adb-9778-4171-a9bb-44e27834ac89"]
 * }
 */

export async function myBulkAssignEventsFunction(categoryId, options) {
  try {
    const assignedEvents = await categories.bulkAssignEvents(categoryId, options);
    console.log('Bulk assign results:', assignedEvents);
    return assignedEvents;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *  "results": [
 *   {
 *     "itemMetadata": {
 *       "originalIndex": 0,
 *       "success": true,
 *       "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a"
 *     },
 *     "item": {
 *       "name": "workshop",
 *       "states": [
 *         "MANUAL"
 *       ],
 *       "_id": "6ec293a8-1b47-4337-9c4e-9a6aeb35e66a",
 *       "_createdDate": "2022-12-13T11:03:19.174Z"
 *     }
 *   },
 *   {
 *     "itemMetadata": {
 *      "originalIndex": 1,
 *       "success": true,
 *       "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88"
 *     },
 *     "item": {
 *       "name": "technology",
 *       "states": [
 *         "MANUAL"
 *       ],
 *       "_id": "89d3e8d4-45bc-4439-9e74-7e21b3418c88",
 *       "_createdDate": "2023-07-12T11:07:35.776Z"
 *     }
 *   }
 * ],
 * "bulkActionMetadata": {
 *   "totalSuccesses": 2,
 *   "totalFailures": 0,
 *   "undetailedFailures": 0
 * }
 * }
 */
```

### bulkAssignEvents (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/events';
// 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 bulkAssignEvents(categoryId,options) {
  const response = await myWixClient.categories.bulkAssignEvents(categoryId,options);
};
```

---