> 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

# CancelRedemption

# Package: benefitPrograms

# Namespace: PoolService

# Method link: https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/cancel-redemption.md

## Permission Scopes:
Manage benefit programs: SCOPE.BENEFIT_PROGRAMS.MANAGE

## Introduction

Cancels a redemption and credits the redeemed amount back to the pool's balance.

The credited amount is the amount of the original redemption, even if the redemption was reallocated since.
The cancellation is recorded as a new transaction that supersedes the specified transaction. After a redemption is canceled, it can't be reallocated or canceled again.

Specify the ID of the latest transaction for the redemption. This is the transaction ID returned by [Redeem Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/redeem-benefit.md) or, if the redemption was reallocated, by the last call to [Reallocate Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/reallocate-benefit.md) for this redemption.
If you specify an older transaction, the method fails with a `NOT_LATEST_TRANSACTION` error whose details include the latest transaction ID, so you can retry with it.

---

## REST API

### Schema

```
 Method: cancelRedemption
 Description: Cancels a redemption and credits the redeemed amount back to the pool's balance.  The credited amount is the amount of the original redemption, even if the redemption was reallocated since. The cancellation is recorded as a new transaction that supersedes the specified transaction. After a redemption is canceled, it can't be reallocated or canceled again.  Specify the GUID of the latest transaction for the redemption. This is the transaction GUID returned by [Redeem Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/redeem-benefit.md) or, if the redemption was reallocated, by the last call to [Reallocate Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/reallocate-benefit.md) for this redemption. If you specify an older transaction, the method fails with a `NOT_LATEST_TRANSACTION` error whose details include the latest transaction GUID, so you can retry with it.
 URL: https://www.wixapis.com/benefit-programs/v1/benefits/cancel-redemption
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  transactionId, idempotencyKey
 Method parameters: 
   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: transactionId | type: transactionId | description: GUID of the latest transaction for the redemption to cancel. This is the transaction GUID returned by Redeem Benefit or, if the redemption was reallocated, by the last call to Reallocate Benefit. | required: true | validation: format GUID
 Return type: CancelRedemptionResponse
  - name: transactionId | type: string | description: GUID of the cancellation transaction.  | validation: format GUID

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Couldn't find the transaction.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ALREADY_EXECUTED | Description: Redemption was already canceled with the specified `idempotencyKey`. This is likely a duplicate call.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHAIN_OPERATION_IN_PROGRESS | Description: Another operation on this redemption is still in progress. Retry later with the same `idempotencyKey`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: TRANSACTION_NOT_CANCELABLE | Description: The specified transaction isn't a redemption or a reallocation, so it can't be canceled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: REDEMPTION_ALREADY_CANCELED | Description: Redemption was already canceled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_LATEST_TRANSACTION | Description: The specified transaction isn't the latest transaction for the redemption. Retry with the `latestTransactionId` returned in the error details.


```

### Examples

### Cancel a redemption
Cancels a redemption and credits the redeemed amount back to the pool's balance.

```curl
curl -X POST \
'https://www.wixapis.com/benefit-programs/v1/benefits/cancel-redemption' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "transactionId": "e4b91c27-6f3d-4a58-9c02-b7d5e18a3f60",
  "idempotencyKey": "3f7a0d52-c8e1-4b96-a2d4-6e19b85c07fa"
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.benefitPrograms.pools.cancelRedemption(transactionId, options)
 Description: Cancels a redemption and credits the redeemed amount back to the pool's balance.  The credited amount is the amount of the original redemption, even if the redemption was reallocated since. The cancellation is recorded as a new transaction that supersedes the specified transaction. After a redemption is canceled, it can't be reallocated or canceled again.  Specify the GUID of the latest transaction for the redemption. This is the transaction GUID returned by [Redeem Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/redeem-benefit.md) or, if the redemption was reallocated, by the last call to [Reallocate Benefit](https://dev.wix.com/docs/api-reference/business-solutions/benefit-programs/pools/reallocate-benefit.md) for this redemption. If you specify an older transaction, the method fails with a `NOT_LATEST_TRANSACTION` error whose details include the latest transaction GUID, so you can retry with it.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  transactionId, options.idempotencyKey, options
 Method parameters: 
   param name: transactionId | type: string | description: GUID of the latest transaction for the redemption to cancel. This is the transaction GUID returned by Redeem Benefit or, if the redemption was reallocated, by the last call to Reallocate Benefit. | required: true | validation: format GUID
   param name: options | type: CancelRedemptionOptions  none | required: true 
        - 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
 Return type: PROMISE<CancelRedemptionResponse>
  - name: transactionId | type: string | description: GUID of the cancellation transaction.  | validation: format GUID

 Possible Errors:
   HTTP Code: 404 | Status Code: NOT_FOUND | Application Code: TRANSACTION_NOT_FOUND | Description: Couldn't find the transaction.
   HTTP Code: 409 | Status Code: ALREADY_EXISTS | Application Code: ALREADY_EXECUTED | Description: Redemption was already canceled with the specified `idempotencyKey`. This is likely a duplicate call.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: CHAIN_OPERATION_IN_PROGRESS | Description: Another operation on this redemption is still in progress. Retry later with the same `idempotencyKey`.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: TRANSACTION_NOT_CANCELABLE | Description: The specified transaction isn't a redemption or a reallocation, so it can't be canceled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: REDEMPTION_ALREADY_CANCELED | Description: Redemption was already canceled.
   HTTP Code: 428 | Status Code: FAILED_PRECONDITION | Application Code: NOT_LATEST_TRANSACTION | Description: The specified transaction isn't the latest transaction for the redemption. Retry with the `latestTransactionId` returned in the error details.


```

### Examples

### Cancel a redemption
Cancels a redemption and credits the redeemed amount back to the pool's balance.

```javascript
import { pools } from "@wix/benefit-programs";

async function cancelRedemption() {
  const response = await pools.cancelRedemption(
    "e4b91c27-6f3d-4a58-9c02-b7d5e18a3f60",
    {
      idempotencyKey: "3f7a0d52-c8e1-4b96-a2d4-6e19b85c07fa",
    },
  );
}

/* Promise resolves to:
 * {
 *   "transactionId": "9c26e8b3-1d47-4f0a-b5e9-d83a72f61c05"
 * }
 */

```

### cancelRedemption (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 cancelRedemption(transactionId,options) {
  const response = await myWixClient.pools.cancelRedemption(transactionId,options);
};
```

---