> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # BulkCreateVariants # Package: items # Namespace: VariantsService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/restaurants/menus/items/item-variants/bulk-create-variants.md ## Permission Scopes: Manage Restaurants - all permissions: SCOPE.RESTAURANTS.MEGA-SCOPES ## Introduction > **Note:** The Item Variants API only works with the Wix Restaurants Menus app. Make sure you have installed this app from the [Wix App Market](https://www.wix.com/app-market/wix-restaurants-menus-new). Creates multiple item variants. --- ## REST API ### Schema ``` Method: bulkCreateVariants Description: > **Note:** The Item Variants API only works with the Wix Restaurants Menus app. Make sure you have installed this app from the [Wix App Market](https://www.wix.com/app-market/wix-restaurants-menus-new). Creates multiple item variants. URL: https://www.wixapis.com/restaurants/menus/v1/bulk/variants/create Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: variants Method parameters: param name: returnEntity | type: returnEntity | description: Whether to receive the created item variants in the response. param name: variants | type: array | description: Item variants details. | required: true - name: name | type: string | description: Item variant name. - name: extendedFields | type: ExtendedFields | description: Extended fields. - 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). Return type: BulkCreateVariantsResponse - name: results | type: array | description: Information about the created item variants. - name: itemMetadata | type: ItemMetadata | description: Metadata for creation of item variants. - 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: variant | type: Variant | description: Created item variants. Only returned if the `returnEntity` value is `true`. - name: id | type: string | description: Item variant GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the item variant is updated. To prevent conflicting changes, the current revision must be passed when updating the item variant. Ignored when creating an item variant. - name: createdDate | type: string | description: Date and time the item variant was created. - name: updatedDate | type: string | description: Date and time the item variant was updated. - name: name | type: string | description: Item variant name. - name: extendedFields | type: ExtendedFields | description: Extended fields. - 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). - name: businessLocationIds | type: array | description: IDs of the business locations ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) where these item variants are available. - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata for the API call. - 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 ### Create multiple variants ```curl curl -X POST https://www.wixapis.com/restaurants/item-variants/v1/bulk/variants/create \ -H 'Authorization: ' --data-binary '{ "variants": [ { "name": "Small" }, { "name": "Medium" }, { "name": "Large" } ], "returnEntity": false }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.items.VariantsService.bulkCreateVariants(variants, options) Description: > **Note:** The Item Variants API only works with the Wix Restaurants Menus app. Make sure you have installed this app from the [Wix App Market](https://www.wix.com/app-market/wix-restaurants-menus-new). Creates multiple item variants. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: variants Method parameters: param name: options | type: BulkCreateVariantsOptions none - name: returnEntity | type: boolean | description: Whether to receive the created item variants in the response. param name: variants | type: array | description: Item variants details. | required: true - name: name | type: string | description: Item variant name. - name: extendedFields | type: ExtendedFields | description: Extended fields. - 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). Return type: PROMISE - name: results | type: array | description: Information about the created item variants. - name: itemMetadata | type: ItemMetadata | description: Metadata for creation of item variants. - 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: variant | type: Variant | description: Created item variants. Only returned if the `returnEntity` value is `true`. - name: _id | type: string | description: Item variant GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the item variant is updated. To prevent conflicting changes, the current revision must be passed when updating the item variant. Ignored when creating an item variant. - name: _createdDate | type: Date | description: Date and time the item variant was created. - name: _updatedDate | type: Date | description: Date and time the item variant was updated. - name: name | type: string | description: Item variant name. - name: extendedFields | type: ExtendedFields | description: Extended fields. - 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). - name: businessLocationIds | type: array | description: IDs of the business locations ([SDK](https://dev.wix.com/docs/sdk/backend-modules/restaurants/wix-restaurants-new/about-business-locations.md) | [REST](https://dev.wix.com/docs/rest/business-solutions/restaurants/wix-restaurants-new/about-business-locations.md)) where these item variants are available. - name: bulkActionMetadata | type: BulkActionMetadata | description: Metadata for the API call. - 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 ### Create multiple variants ```javascript import { itemVariants } from "@wix/restaurants"; const variants = [ { name: "Small" }, { name: "Medium" }, { name: "Large" } ]; const options = { returnEntity: false }; async function bulkCreateVariants() { const response = await itemVariants.bulkCreateVariants(variants, options); } /* Promise resolves to: * { * "results": [ * { * "itemMetadata": { * "_id": "ea763e57-ae9a-4da8-97e5-1001a8cd185a", * "originalIndex": 0, * "success": true * }, * "variant": { * "_id": "ea763e57-ae9a-4da8-97e5-1001a8cd185a", * "revision": "1", * "name": "Small" * } * }, * { * "itemMetadata": { * "_id": "2a5a5ca9-1e96-4079-9d23-865a0c263eee", * "originalIndex": 1, * "success": true * }, * "variant": { * "_id": "2a5a5ca9-1e96-4079-9d23-865a0c263eee", * "revision": "1", * "name": "Medium" * } * } * ], * "bulkActionMetadata": { * "totalSuccesses": 3, * "totalFailures": 0 * } * } */ ``` ### bulkCreateVariants (self-hosted) Self-hosted 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 { itemVariants } from '@wix/restaurants'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { itemVariants }, // Include the auth strategy and host as relevant }); async function bulkCreateVariants(variants,options) { const response = await myWixClient.itemVariants.bulkCreateVariants(variants,options); }; ``` ---