> 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 # RedeemBenefit # Package: benefitPrograms # Namespace: PoolService # Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/redeem-benefit.md ## Permission Scopes: Manage benefit programs: SCOPE.BENEFIT_PROGRAMS.MANAGE ## Introduction Redeems a specified benefit. Calling this method records redemption of the benefit and adjusts the pool's associated balance. You still need to handle providing the beneficiary with the item. --- ## REST API ### Schema ``` Method: redeemBenefit Description: Redeems a specified benefit. Calling this method records redemption of the benefit and adjusts the pool's associated balance. You still need to handle providing the beneficiary with the item. URL: https://www.wixapis.com/benefit-programs/v1/benefits/redeem Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: poolId, itemReference, benefitKey, itemReference.externalId, itemReference.providerAppId, idempotencyKey, namespace Method parameters: param name: additionalData | type: additionalData | description: Additional information. param name: beneficiary | type: IdentificationData - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that hasn't logged in to the site. - name: memberId | type: string | description: GUID of a site member. - name: wixUserId | type: string | description: GUID of a Wix user. param name: benefitKey | type: benefitKey | description: Key of the benefit to redeem. | required: true param name: count | type: count | description: Amount of items to redeem. param name: idempotencyKey | type: idempotencyKey | description: Unique identifier, generated by the client. Used to recognize repeated attempts to make the same request. | required: true param name: itemReference | type: ItemReference | required: true - name: externalId | type: string | description: External GUID of the item. | required: true - name: category | type: string | description: Item category. - name: providerAppId | type: string | description: GUID of the app providing the item. | required: true param name: namespace | type: namespace | 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: poolId | type: poolId | description: GUID of the pool that contains the benefit to redeem. | required: true param name: targetDate | type: targetDate | description: Date that the item will be provided to the beneficiary. The pool's associated balance will update immediately. This parameter should be used to manage the logistics of providing the item. Return type: RedeemBenefitResponse - name: transactionId | type: string | description: GUID of the transaction recording the associated change in balance. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: BENEFIT_NOT_FOUND | Description: There is no benefit with the specified data. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: POOL_NOT_FOUND | Description: Couldn't find the pool. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: BENEFIT_ALREADY_REDEEMED | Description: Benefit was already redeemed with the specified idempotency key. This is likely a duplicate call. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POOL_NOT_ACTIVE | Description: Benefit's pool isn't active. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POLICY_EXPRESSION_EVALUATED_TO_FALSE | Description: Policy expression is false. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_BALANCE | Description: Pool's balance has insufficient credits to redeem the benefit. ``` ### Examples ### RedeemBenefit ```curl ~~~cURL curl --request POST https://www.wixapis.com/benefit-programs/v1/benefits/redeem \ -H "Authorization: " \ -H "Content-Type: application/json" \ --data '{ "item_reference": { "external_id": "57273802-b873-495c-8eba-b8f054452e6c", "provider_app_id": "00000000-0000-0000-0000-000000000000" }, "count": 3, "beneficiary": { "identity_type": "MEMBER", "member_id": "00000000-0000-0000-0000-000000000000" }, "namespace": "benefit_programs_app", "pool_id": "4a4de95d-867a-4089-98a8-83af77e38eca", "idempotency_key": "fd5e2341-80fa-4021-844d-c34874139759" }' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.benefitPrograms.PoolService.redeemBenefit(poolId, options) Description: Redeems a specified benefit. Calling this method records redemption of the benefit and adjusts the pool's associated balance. You still need to handle providing the beneficiary with the item. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: poolId, options.itemReference, options.benefitKey, options.itemReference.externalId, options.itemReference.providerAppId, optionsempotencyKey, options.namespace, options Method parameters: param name: options | type: RedeemBenefitOptions none | required: true - name: itemReference | type: ItemReference | description: Information about the item to redeem. | required: true - name: externalId | type: string | description: External GUID of the item. | required: true - name: category | type: string | description: Item category. - name: providerAppId | type: string | description: GUID of the app providing the item. | required: true - name: benefitKey | type: string | description: Key of the benefit to redeem. | required: true - name: count | type: integer | description: Amount of items to redeem. - name: targetDate | type: Date | description: Date that the item will be provided to the beneficiary. The pool's associated balance will update immediately. This parameter should be used to manage the logistics of providing the item. - name: idempotencyKey | type: string | description: Unique identifier, generated by the client. Used to recognize repeated attempts to make the same request. | required: true - name: additionalData | type: object | description: Additional information. - name: beneficiary | type: IdentificationData | description: Beneficiary of the pool containing the benefit to redeem. - ONE-OF: - name: anonymousVisitorId | type: string | description: GUID of a site visitor that hasn't logged in to the site. - name: memberId | type: string | description: GUID of a site member. - name: wixUserId | type: string | description: GUID of a Wix user. - 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: poolId | type: string | description: GUID of the pool that contains the benefit to redeem. | required: true Return type: PROMISE - name: transactionId | type: string | description: GUID of the transaction recording the associated change in balance. Possible Errors: HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: BENEFIT_NOT_FOUND | Description: There is no benefit with the specified data. HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: POOL_NOT_FOUND | Description: Couldn't find the pool. HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: BENEFIT_ALREADY_REDEEMED | Description: Benefit was already redeemed with the specified idempotency key. This is likely a duplicate call. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POOL_NOT_ACTIVE | Description: Benefit's pool isn't active. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: POLICY_EXPRESSION_EVALUATED_TO_FALSE | Description: Policy expression is false. HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_ENOUGH_BALANCE | Description: Pool's balance has insufficient credits to redeem the benefit. ``` ### Examples ### redeemBenefit ```javascript import { pools } from '@wix/benefit-programs'; async function redeemBenefit(poolId,options) { const response = await pools.redeemBenefit(poolId,options); }; ``` ### redeemBenefit (with elevated permissions) ```javascript import { pools } from '@wix/benefit-programs'; import { auth } from '@wix/essentials'; async function myRedeemBenefitMethod(poolId,options) { const elevatedRedeemBenefit = auth.elevate(pools.redeemBenefit); const response = await elevatedRedeemBenefit(poolId,options); } ``` ### redeemBenefit (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 { pools } from '@wix/benefit-programs'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { pools }, // Include the auth strategy and host as relevant }); async function redeemBenefit(poolId,options) { const response = await myWixClient.pools.redeemBenefit(poolId,options); }; ``` ---