> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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.  | validation: format GUID
     - name: memberId | type: string | description: GUID of a site member.  | validation: format GUID
     - name: wixUserId | type: string | description: GUID of a Wix user.  | validation: format GUID
   param name: benefitKey | type: benefitKey | description: Key of the benefit to redeem. | required: true | validation: maxLength 64
   param name: count | type: count | description: Amount of items to redeem.  | validation: minimum 1
   param name: idempotencyKey | type: idempotencyKey | description: Unique identifier, generated by the client. Used to recognize repeated attempts to make the same request. | required: true | validation: maxLength 200
   param name: itemReference | type: ItemReference   | required: true 
        - name: externalId | type: string | description: External GUID of the item. | required: true | validation: format GUID
        - name: category | type: string | description: Item category.  | validation: maxLength 20
        - name: providerAppId | type: string | description: GUID of the app providing the item. | required: true | validation: format GUID
   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 | validation: minLength 1, maxLength 20
   param name: poolId | type: poolId | description: GUID of the pool that contains the benefit to redeem. | required: true | validation: format GUID
   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.  | validation: format date-time
 Return type: RedeemBenefitResponse
  - name: transactionId | type: string | description: GUID of the transaction recording the associated change in balance.  | validation: format GUID

 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

### Redeem a benefit
```curl
curl --request POST https://www.wixapis.com/benefit-programs/v1/benefits/redeem \
  -H "Authorization: <AUTH>" \
  -H "Content-Type: application/json" \
  --data '{
    "itemReference": {
      "externalId": "57273802-b873-495c-8eba-b8f054452e6c",
      "providerAppId": "00000000-0000-0000-0000-000000000000"
    },
    "count": 3,
    "beneficiary": {
      "memberId": "00000000-0000-0000-0000-000000000000"
    },
    "namespace": "benefit_programs_app",
    "poolId": "4a4de95d-867a-4089-98a8-83af77e38eca",
    "idempotencyKey": "fd5e2341-80fa-4021-844d-c34874139759",
    "benefitKey": "monthly-access"
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.benefitPrograms.pools.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: poolId | type: string | description: GUID of the pool that contains the benefit to redeem. | required: true | validation: format GUID
   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 | validation: format GUID
           - name: category | type: string | description: Item category.  | validation: maxLength 20
           - name: providerAppId | type: string | description: GUID of the app providing the item. | required: true | validation: format GUID
        - name: benefitKey | type: string | description: Key of the benefit to redeem. | required: true | validation: maxLength 64
        - name: count | type: integer | description: Amount of items to redeem.  | validation: minimum 1
        - 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 | validation: maxLength 200
        - 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.  | validation: format GUID
              - name: memberId | type: string | description: GUID of a site member.  | validation: format GUID
              - name: wixUserId | type: string | description: GUID of a Wix user.  | validation: format GUID
        - 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 | validation: minLength 1, maxLength 20
 Return type: PROMISE<RedeemBenefitResponse>
  - name: transactionId | type: string | description: GUID of the transaction recording the associated change in balance.  | validation: format GUID

 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-managed)
Self-managed 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);
};
```

---