> 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

# Package: rewards

# Namespace: rewards

# Webhook link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/rewards/rewards/reward-updated.md

# Webhook Permissions Scopes IDs:
Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY

## Introduction

Triggered when a reward is updated.

---

## REST API

### Schema

```
Webhook: Reward Updated
Description: Triggered when a reward is updated.
Event body:
 - name: id | type: string | description: Unique event ID. Allows clients to ignore duplicate events.
 - name: entityFqdn | type: string | description: Fully qualified domain name of the entity associated with the event.
 - name: slug | type: string | description: Event name.
 - name: entityId | type: string | description: ID of the entity associated with the event.
 - name: eventTime | type: string (date-time) | description: Event timestamp.
 - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application such as GDPR.
 - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event.
 - name: updatedEvent | type: object | description: Updated event details.
    - name: currentEntity | type: Reward | description: The entity after the update.
        - ONE-OF:
           - name: discountAmount | type: DiscountAmount | description: Discount details.
              - name: configsByTier | type: array<DiscountAmountConfig> | description: Discount details for each tier.
                 - name: amount | type: string | description: Discount amount. Must be a positive value.
                 - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                 - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
           - name: couponReward | type: CouponReward | description: Coupon details.
              - ONE-OF:
                 - name: fixedAmount | type: FixedAmountDiscount | description: Discount as a fixed amount.
                    - name: configsByTier | type: array<FixedAmountDiscountConfig> | description: Discount details for each tier.
                       - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                       - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
                       - name: amount | type: number | description: Discount amount.
                 - name: percentage | type: PercentageDiscount | description: Discount as a percentage.
                    - name: configsByTier | type: array<PercentageDiscountConfig> | description: Discount details for each tier.
                       - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                       - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
                       - name: percentage | type: number | description: Percentage discount.
                 - name: freeShipping | type: FreeShippingDiscount | description: Free shipping.
                    - name: configsByTier | type: array<FreeShippingDiscountConfig> | description: Discount details for each tier.
                       - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                       - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
              - ONE-OF:
                 - name: minimumSubtotal | type: number | description: Limit the coupon to carts with a subtotal greater than this number.
                 - name: scope | type: CouponScope | description: Specifies the type of line items this coupon applies to.  For more information, see [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md).
                    - name: namespace | type: string | description: Scope namespace.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid namespaces.
                    - name: group | type: Group | description: Coupon scope's applied group.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid groups.
                       - name: name | type: string | description: Name of coupon scope's group.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid groups.
                       - name: entityId | type: string | description: Entity GUID, if the coupon scope is limited to just 1 item.
              - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 item.
              - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.
              - name: discountedCycleCount | type: integer | description: Specifies the amount of discounted cycles for a subscription item.  Can only be set when `appliesToSubscriptions` is `true` and `scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.
        - name: id | type: string | description: Reward GUID.
        - name: name | type: string | description: Reward name.
        - name: active | type: boolean | description: Whether the reward is active. Default: `FALSE`
        - name: type | type: RewardType | description: Reward type.
           - enum:
           -     UNDEFINED: Undefined reward type.
           -     DISCOUNT_AMOUNT: Discount reward. Special flexible reward type used in checkout.
           -     COUPON_REWARD: Coupon reward. [Learn more about coupons](https://support.wix.com/en/article/using-coupons-as-loyalty-rewards).
        - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty reward is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty reward.
        - name: createdDate | type: string | description: Date and time the reward was created.
        - name: updatedDate | type: string | description: Date and time the reward was last updated.

```

---

## JavaScript SDK

### Schema

```
Webhook: onRewardUpdated
Description: Triggered when a reward is updated.
Payload: RewardUpdatedEnvelope
  - name: entity | type: Reward | description: none
     - ONE-OF:
        - name: discountAmount | type: DiscountAmount | description: Discount details.
           - name: configsByTier | type: array<DiscountAmountConfig> | description: Discount details for each tier.
              - name: amount | type: string | description: Discount amount. Must be a positive value.
              - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
              - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
        - name: couponReward | type: CouponReward | description: Coupon details.
           - ONE-OF:
              - name: fixedAmount | type: FixedAmountDiscount | description: Discount as a fixed amount.
                 - name: configsByTier | type: array<FixedAmountDiscountConfig> | description: Discount details for each tier.
                    - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                    - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
                    - name: amount | type: number | description: Discount amount.
              - name: percentage | type: PercentageDiscount | description: Discount as a percentage.
                 - name: configsByTier | type: array<PercentageDiscountConfig> | description: Discount details for each tier.
                    - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                    - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
                    - name: percentage | type: number | description: Percentage discount.
              - name: freeShipping | type: FreeShippingDiscount | description: Free shipping.
                 - name: configsByTier | type: array<FreeShippingDiscountConfig> | description: Discount details for each tier.
                    - name: tierId | type: string | description: Tier GUID, or empty if config applies to the base tier.
                    - name: costInPoints | type: integer | description: Amount of points required to redeem the reward.
           - ONE-OF:
              - name: minimumSubtotal | type: number | description: Limit the coupon to carts with a subtotal greater than this number.
              - name: scope | type: CouponScope | description: Specifies the type of line items this coupon applies to.  For more information, see [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md).
                 - name: namespace | type: string | description: Scope namespace.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid namespaces.
                 - name: group | type: Group | description: Coupon scope's applied group.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid groups.
                    - name: name | type: string | description: Name of coupon scope's group.  See [valid scope values](https://dev.wix.com/docs/rest/business-management/marketing/coupons/coupons/valid-scope-values.md) for valid groups.
                    - name: entityId | type: string | description: Entity GUID, if the coupon scope is limited to just 1 item.
           - name: limitedToOneItem | type: boolean | description: Whether the coupon is limited to 1 item.
           - name: appliesToSubscriptions | type: boolean | description: Whether the coupon also applies to subscriptions.
           - name: discountedCycleCount | type: integer | description: Specifies the amount of discounted cycles for a subscription item.  Can only be set when `appliesToSubscriptions` is `true` and `scope.namespace` is `pricingPlans`. If `discountedCycleCount` is empty, the coupon applies to all available cycles.
     - name: _id | type: string | description: Reward GUID.
     - name: name | type: string | description: Reward name.
     - name: active | type: boolean | description: Whether the reward is active. Default: `FALSE`
     - name: type | type: RewardType | description: Reward type.
         - enum:
         -     UNDEFINED: Undefined reward type.
         -     DISCOUNT_AMOUNT: Discount reward. Special flexible reward type used in checkout.
         -     COUPON_REWARD: Coupon reward. [Learn more about coupons](https://support.wix.com/en/article/using-coupons-as-loyalty-rewards).
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty reward is updated.  To prevent conflicting changes, the current `revision` must be passed when updating the loyalty reward.
     - name: _createdDate | type: Date | description: Date and time the reward was created.
     - name: _updatedDate | type: Date | description: Date and time the reward was last updated.
  - name: metadata | type: EventMetadata | description: none
     - name: instanceId | type: string | description: App instance GUID.
     - name: eventType | type: string | description: Event type.
     - name: identity | type: IdentificationData | description: The identification type and identity data.
        - ONE-OF:
           - name: anonymousVisitorId | type: string | description: GUID of a site visitor that has not logged in to the site.
           - name: memberId | type: string | description: GUID of a site visitor that has logged in to the site.
           - name: wixUserId | type: string | description: GUID of a Wix user (site owner, contributor, etc.).
           - name: appId | type: string | description: GUID of an app.
        - name: identityType | type: WebhookIdentityType | description: 
             - enum: UNKNOWN, ANONYMOUS_VISITOR, MEMBER, WIX_USER, APP
     - name: accountInfo | type: AccountInfo | description: Details related to the account
        - name: accountId | type: string | description: GUID of the Wix account associated with the event.
        - name: parentAccountId | type: string | description: GUID of the parent Wix account. Only included when accountId belongs to a child account.
        - name: siteId | type: string | description: GUID of the Wix site associated with the event. Only included when the event is tied to a specific site.
     - name: _id | type: string | description: Event GUID. With this GUID you can easily spot duplicated events and ignore them.
     - name: entityFqdn | type: string | description: Fully Qualified Domain Name of an entity. This is a unique identifier assigned to the API main business entities. For example, `wix.stores.catalog.product`, `wix.bookings.session`, `wix.payments.transaction`.
     - name: slug | type: string | description: Event action name, placed at the top level to make it easier for users to dispatch messages. For example: `created`/`updated`/`deleted`/`started`/`completed`/`email_opened`.
     - name: entityId | type: string | description: GUID of the entity associated with the event.
     - name: eventTime | type: Date | description: Event timestamp in [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) format and UTC time. For example, `2020-04-26T13:57:50.699Z`.
     - name: triggeredByAnonymizeRequest | type: boolean | description: Whether the event was triggered as a result of a privacy regulation application (for example, GDPR).
     - name: originatedFrom | type: string | description: If present, indicates the action that triggered the event.
     - name: entityEventSequence | type: string | description: A sequence number that indicates the order of updates to an entity. For example, if an entity was updated at `16:00` and then again at `16:01`, the second update will always have a higher sequence number. You can use this number to make sure you're handling updates in the right order. Just save the latest sequence number on your end and compare it to the one in each new message. If the new message has an older (lower) number, you can safely ignore it.

```

### Examples


```javascript
import { rewards } from '@wix/loyalty';

rewards.onRewardUpdated((event) => {
    // handle your event here
});
```


```javascript
import { createClient, AppStrategy } from '@wix/sdk';
import { rewards } from '@wix/loyalty';

const wixClient = createClient({
  auth: AppStrategy({
    appId: 'MY-APP-ID',
    publicKey: 'YOUR_APP_PUBLIC_KEY',
  }),
  modules: {
      rewards,
    },
});

wixClient.rewards.onRewardUpdated((event) => {
    // handle your event here
});
```

---