> 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 # BulkCreateItems # Package: benefitPrograms # Namespace: ItemService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/items/bulk-create-items.md ## Permission Scopes: Manage benefit programs: SCOPE.BENEFIT_PROGRAMS.MANAGE ## Introduction Creates benefit items. --- ## REST API ### Schema ``` Method: bulkCreateItems Description: Creates benefit items. URL: https://www.wixapis.com/benefit-programs/v1/bulk/items/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: items, items.itemSetId, items.externalId, items.providerAppId, items.namespace Method parameters: param name: items | type: array | description: Items to create. | required: true - name: externalId | type: string | description: GUID of the item in the app providing it. For example, if the item is a product provided by Wix Stores, the `externalId` would be the Wix Stores `product Id`. | required: true - name: itemSetId | type: string | description: Item set GUID of the benefit that this benefit item is a part of. | required: true - name: displayName | type: string | description: Benefit item display name. - name: providerAppId | type: string | description: GUID of the [app](https://dev.wix.com/docs/rest/articles/getting-started/apps-created-by-wix.md) that defines and provides the item. For example, if the item is a Wix Stores product, this field's value is `215238eb-22a5-4c36-9e7b-e7c08025e04e`. | required: true - name: extendedFields | type: ExtendedFields | description: Custom field data for the benefit 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). - name: namespace | type: string | description: Namespace for your app or site's benefit programs. Namespaces allow you to distinguish between entities that you created and entities that other apps created. | required: true param name: returnEntity | type: returnEntity | description: Whether to return the full item entities. Default: `false` Return type: BulkCreateItemsResponse - name: results | type: array | description: List of created items and associated metadata. - name: itemMetadata | type: ItemMetadata | description: Item 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: Item | description: Item. - name: id | type: string | description: Benefit item GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the benefit item is updated. To prevent conflicting changes, the current revision must be passed when updating the benefit item. Ignored when creating a benefit item. - name: createdDate | type: string | description: Date and time the item was created. - name: updatedDate | type: string | description: Date and time the item was updated. - name: externalId | type: string | description: GUID of the item in the app providing it. For example, if the item is a product provided by Wix Stores, the `externalId` would be the Wix Stores `product Id`. - name: category | type: string | description: Benefit item category. - name: itemSetId | type: string | description: Item set GUID of the benefit that this benefit item is a part of. - name: displayName | type: string | description: Benefit item display name. - name: providerAppId | type: string | description: GUID of the [app](https://dev.wix.com/docs/rest/articles/getting-started/apps-created-by-wix.md) that defines and provides the item. For example, if the item is a Wix Stores product, this field's value is `215238eb-22a5-4c36-9e7b-e7c08025e04e`. - name: extendedFields | type: ExtendedFields | description: Custom field data for the benefit 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). - name: namespace | type: string | description: Namespace for your app or site's benefit programs. Namespaces allow you to distinguish between entities that you created and entities that other apps created. - 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. ``` ### Examples ### BulkCreateItems ```curl ~~~cURL curl -X POST \ "https://www.wixapis.com/benefit-programs/v1/bulk/items" -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "items": [ { "item_set_id": "201db180-5043-45cf-a501-bd9c06df5ae5", "namespace": "benefit_programs_app", "provider_app_id": "215238eb-22a5-4c36-9e7b-e7c08025e04e", "external_id": "3f9a7c91-4e2b-4d5e-b6f8-0c2e5a9d4f34" }, { "item_set_id": "4febfe37-2fec-40da-b41f-0aad7279ba5c", "namespace": "benefit_programs_app", "provider_app_id": "215238eb-22a5-4c36-9e7b-e7c08025e04e", "external_id": "3f9a7c91-4e2b-4d5e-b6f8-0c2e5a9d4f36" } ] }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.benefitPrograms.ItemService.bulkCreateItems(items, options) Description: Creates benefit items. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: items, items.itemSetId, items.externalId, items.providerAppId, items.namespace Method parameters: param name: items | type: array | description: Items to create. | required: true - name: externalId | type: string | description: GUID of the item in the app providing it. For example, if the item is a product provided by Wix Stores, the `externalId` would be the Wix Stores `product Id`. | required: true - name: itemSetId | type: string | description: Item set GUID of the benefit that this benefit item is a part of. | required: true - name: displayName | type: string | description: Benefit item display name. - name: providerAppId | type: string | description: GUID of the [app](https://dev.wix.com/docs/rest/articles/getting-started/apps-created-by-wix.md) that defines and provides the item. For example, if the item is a Wix Stores product, this field's value is `215238eb-22a5-4c36-9e7b-e7c08025e04e`. | required: true - name: extendedFields | type: ExtendedFields | description: Custom field data for the benefit 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). - name: namespace | type: string | description: Namespace for your app or site's benefit programs. Namespaces allow you to distinguish between entities that you created and entities that other apps created. | required: true param name: options | type: BulkCreateItemsOptions none - name: returnEntity | type: boolean | description: Whether to return the full item entities. Default: `false` Return type: PROMISE - name: results | type: array | description: List of created items and associated metadata. - name: itemMetadata | type: ItemMetadata | description: Item 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: Item | description: Item. - name: _id | type: string | description: Benefit item GUID. - name: revision | type: string | description: Revision number, which increments by 1 each time the benefit item is updated. To prevent conflicting changes, the current revision must be passed when updating the benefit item. Ignored when creating a benefit item. - name: _createdDate | type: Date | description: Date and time the item was created. - name: _updatedDate | type: Date | description: Date and time the item was updated. - name: externalId | type: string | description: GUID of the item in the app providing it. For example, if the item is a product provided by Wix Stores, the `externalId` would be the Wix Stores `product Id`. - name: category | type: string | description: Benefit item category. - name: itemSetId | type: string | description: Item set GUID of the benefit that this benefit item is a part of. - name: displayName | type: string | description: Benefit item display name. - name: providerAppId | type: string | description: GUID of the [app](https://dev.wix.com/docs/rest/articles/getting-started/apps-created-by-wix.md) that defines and provides the item. For example, if the item is a Wix Stores product, this field's value is `215238eb-22a5-4c36-9e7b-e7c08025e04e`. - name: extendedFields | type: ExtendedFields | description: Custom field data for the benefit 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). - name: namespace | type: string | description: Namespace for your app or site's benefit programs. Namespaces allow you to distinguish between entities that you created and entities that other apps created. - 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. ``` ### Examples ### bulkCreateItems ```javascript import { items } from '@wix/benefit-programs'; async function bulkCreateItems(items,options) { const response = await items.bulkCreateItems(items,options); }; ``` ### bulkCreateItems (with elevated permissions) ```javascript import { items } from '@wix/benefit-programs'; import { auth } from '@wix/essentials'; async function myBulkCreateItemsMethod(items,options) { const elevatedBulkCreateItems = auth.elevate(items.bulkCreateItems); const response = await elevatedBulkCreateItems(items,options); } ``` ### bulkCreateItems (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 { items } from '@wix/benefit-programs'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { items }, // Include the auth strategy and host as relevant }); async function bulkCreateItems(items,options) { const response = await myWixClient.items.bulkCreateItems(items,options); }; ``` ---