Search...
createCategory( )
Creates a category.
Admin Method
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function createCategory(category: Category): Promise<Category>
createCategory Parameters
NAME
TYPE
DESCRIPTION
category
Category
Category to create.
Returns
Created category.
Return Type:
Promise<
Category
>NAME
TYPE
DESCRIPTION
_createdDate
Date
Category creation timestamp.
_id
string
Category ID.
assignedEventsCount
number
Total number of published events assigned to the category. Deleted events are excluded.
counts
CategoryCounts
The total number of draft and published events assigned to the category.
name
string
Category name.
states
Array<
string
>Category state. Possible values:
MANUAL
: Category is created manually by the user.AUTO
: Category is created automatically.RECURRING_EVENT
: Category is created automatically when publishing recurring events.HIDDEN
: Category can't be seen.
Default: MANUAL
.
Note: The WIX_EVENTS.MANAGE_AUTO_CATEGORIES permission is required to use other states than MANUAL
.
Was this helpful?
createCategory example
Copy Code
1import { categories } from 'wix-events.v2';23 async function createCategory(category) {4 try {5 const result = await categories.createCategory(category);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13