> ## Documentation Index
> Fetch the complete documentation index at: https://developers.mageloyalty.com/llms.txt
> Use this file to discover all available pages before exploring further.

# redeemRewardToSubscription

> Redeem a fixed or percentage reward and apply the discount to a subscription.

Redeem a fixed or percentage reward and apply the discount to one of the customer's subscriptions, instead of returning a code for checkout. The cost is the reward's `pointsCost`. The reward's purchase type must be **Subscription** or **Both**.

Store-credit shops redeem through [`redeemFlexibleToSubscription`](/js-sdk/subscriptions/redeem-flexible-to-subscription) instead.

## Usage

```javascript theme={null}
MageSDK.redeemRewardToSubscription('reward_abc', '7d993128-2570-4386-97a8-a04e074fc7ff')
  .then(function(resp) {
    if (resp.success) {
      console.log('Applied:', resp.data.customerReward.discountCode);
    } else {
      console.log('Error:', resp.error);
    }
  });
```

## Parameters

**rewardId** `string` *required*

The ID of a fixed or percentage reward. Get reward IDs from [`getShopRewards`](/js-sdk/rewards/get-shop-rewards).

**subscriptionId** `string` *required*

The `id` of one of the customer's subscriptions, from [`getSubscriptions`](/js-sdk/subscriptions/get-subscriptions).

## Response

**success** `boolean`

Whether the discount was applied.

**data.customerReward** `object`

The created reward record, with `id` and `discountCode`.

**data.pointsRedeemed** `number`

The amount deducted from the customer's balance.

**data.updatedPoints** `number`

The customer's remaining balance.

**data.subscriptionId** `string`

The subscription the discount was applied to.

> [!NOTE]
>
> How many orders the discount applies to follows the reward's own settings. If applying fails, the customer's balance is not charged.

## Errors

| Error | Cause |
| - | - |
| `"Customer not found"` | Customer is not logged in or not enrolled |
| `"Insufficient points"` | Customer does not have enough balance |
| `"This reward cannot be applied to subscriptions"` | The reward's purchase type is One-time |
| `"Free shipping rewards cannot be applied to Skio subscriptions"` | Skio does not support free shipping on subscriptions |
| `"That subscription is no longer active."` | The subscription is paused or cancelled |
| `"That subscription is not available for this account."` | The subscription belongs to another customer |
| `"No subscription integration is connected for this shop"` | No subscription app is connected in Mage |

## Sample response

```json theme={null}
{
  "success": true,
  "data": {
    "customerReward": { "id": "cr_abc123", "discountCode": "MAGE-XYZ789" },
    "pointsRedeemed": 500,
    "updatedPoints": 250,
    "subscriptionId": "7d993128-2570-4386-97a8-a04e074fc7ff",
    "provider": "skio"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.