> 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 # AddItemsToBenefit # Package: benefitPrograms # Namespace: PoolDefinitionItemService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pool-definition-items/add-items-to-benefit.md ## Permission Scopes: Manage benefit programs: SCOPE.BENEFIT_PROGRAMS.MANAGE ## Introduction Registers items with a benefit. This is an eventually consistent operation. Items may take a short time to appear in Query Pool Definition Items results after the call returns. Uses a partial success model. Items already registered with the benefit return a per-item error in `results.itemMetadata`, while new items are added successfully. Check `bulkActionMetadata` for overall counts and results for per-item outcomes. --- ## REST API ### Schema ``` Method: addItemsToBenefit Description: Registers items with a benefit. This is an eventually consistent operation. Items may take a short time to appear in Query Pool Definition Items results after the call returns. Uses a partial success model. Items already registered with the benefit return a per-item error in `results.itemMetadata`, while new items are added successfully. Check `bulkActionMetadata` for overall counts and results for per-item outcomes. URL: https://www.wixapis.com/benefit-programs/v1/pool-definition-items/add-items-to-benefit Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: itemReferences, itemReferences.externalId, poolDefinitionId, benefitKey Method parameters: param name: benefitKey | type: benefitKey | description: Key identifying the benefit in the pool definition. | required: true param name: itemReferences | type: array | description: Items to add to the benefit's item set. | required: true - name: externalId | type: string | description: External item GUID assigned by the provider. | required: true - name: category | type: string | description: Item category. param name: poolDefinitionId | type: poolDefinitionId | description: GUID of the pool definition associated with the benefit. | required: true Return type: AddItemsToBenefitResponse - name: results | type: array | description: Per-item results. `itemMetadata.originalIndex` corresponds to the order of `itemReferences` in the request. - name: itemMetadata | type: ItemMetadata | description: Outcome metadata for the catalog item created in the underlying item service. The item GUID here is the Item entity GUID. The service creates PoolDefinitionItem records asynchronously and doesn't include their GUIDs in this response. - 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: bulkActionMetadata | type: BulkActionMetadata | description: Aggregate counts for the bulk operation, including successes and failures. - 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: 404 | Status Code: NOT_FOUND | Application Code: POOL_DEFINITION_BENEFIT_NOT_FOUND | Description: No benefit is configured for the given `poolDefinitionId` and `benefitKey` pair. ``` ### Examples ### AddItemsToBenefit ```curl ~~~cURL curl -X POST "https://www.wixapis.com/benefit-programs/v1/pool-definition-items/add-items-to-benefit" \ -H 'Content-type: application/json' \ -H 'Authorization: ' \ -d '{ "item_references": [ { "external_id": "00000000-6666-6666-0000-000000000001", "category": "class" }, { "external_id": "00000000-6666-6666-0000-000000000002", "category": "class" } ], "pool_definition_id": "201db180-5043-45cf-a501-bd9c06df5ae5", "benefit_key": "unlimited-classes" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.benefitPrograms.PoolDefinitionItemService.addItemsToBenefit(itemReferences, options) Description: Registers items with a benefit. This is an eventually consistent operation. Items may take a short time to appear in Query Pool Definition Items results after the call returns. Uses a partial success model. Items already registered with the benefit return a per-item error in `results.itemMetadata`, while new items are added successfully. Check `bulkActionMetadata` for overall counts and results for per-item outcomes. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: itemReferences, itemReferences.externalId, options.poolDefinitionId, options.benefitKey, options Method parameters: param name: itemReferences | type: array | description: Items to add to the benefit's item set. | required: true - name: externalId | type: string | description: External item GUID assigned by the provider. | required: true - name: category | type: string | description: Item category. param name: options | type: AddItemsToBenefitOptions none | required: true - name: poolDefinitionId | type: string | description: GUID of the pool definition associated with the benefit. | required: true - name: benefitKey | type: string | description: Key identifying the benefit in the pool definition. | required: true Return type: PROMISE - name: results | type: array | description: Per-item results. `itemMetadata.originalIndex` corresponds to the order of `itemReferences` in the request. - name: itemMetadata | type: ItemMetadata | description: Outcome metadata for the catalog item created in the underlying item service. The item GUID here is the Item entity GUID. The service creates PoolDefinitionItem records asynchronously and doesn't include their GUIDs in this response. - 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: bulkActionMetadata | type: BulkActionMetadata | description: Aggregate counts for the bulk operation, including successes and failures. - 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: 404 | Status Code: NOT_FOUND | Application Code: POOL_DEFINITION_BENEFIT_NOT_FOUND | Description: No benefit is configured for the given `poolDefinitionId` and `benefitKey` pair. ``` ### Examples ### addItemsToBenefit ```javascript import { poolDefinitionItems } from '@wix/benefit-programs'; async function addItemsToBenefit(itemReferences,options) { const response = await poolDefinitionItems.addItemsToBenefit(itemReferences,options); }; ``` ### addItemsToBenefit (with elevated permissions) ```javascript import { poolDefinitionItems } from '@wix/benefit-programs'; import { auth } from '@wix/essentials'; async function myAddItemsToBenefitMethod(itemReferences,options) { const elevatedAddItemsToBenefit = auth.elevate(poolDefinitionItems.addItemsToBenefit); const response = await elevatedAddItemsToBenefit(itemReferences,options); } ``` ### addItemsToBenefit (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 { poolDefinitionItems } from '@wix/benefit-programs'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { poolDefinitionItems }, // Include the auth strategy and host as relevant }); async function addItemsToBenefit(itemReferences,options) { const response = await myWixClient.poolDefinitionItems.addItemsToBenefit(itemReferences,options); }; ``` ---