Setup

To use the Rewards API, install the @wix/loyalty package using npm or Yarn:

Copy
1
npm install @wix/loyalty

or

Copy
1
yarn add @wix/loyalty

Then import { rewards } from @wix/loyalty:

Copy
1
import { rewards } from '@wix/loyalty'
Was this helpful?
Yes
No

createReward( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Creates a reward that can be redeemed with loyalty points.

When a customer redeems a reward, a loyalty coupon is created based on the specifications detailed in either the discountAmount or couponReward fields. This coupon can then be used by the customer to receive the discount. Note that while the Rewards API uses coupon scopes and specifications, no coupon is actually created until a reward is redeemed with points. See the Coupons API for more information about coupons.

A reward's active status defaults to false. To make the reward available to customers, either set the active field to true during creation or call updateReward() to change the status.

To customize a reward for each loyalty tier, use the configsByTier parameter. This allows you to specify the amount of the earned discount, the cost in loyalty points to redeem the reward, and the tier to which this configuration applies. Each tier requires its own configsByTier configuration. To create a reward that is available to loyalty accounts in the base tier, leave the tierId field empty. See the Loyalty Tiers API for more information on tiers.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Loyalty
Learn more about permission scopes.
Copy
function createReward(reward: Reward): Promise<Reward>
Method Parameters
rewardRewardRequired

Reward to create.

Returns
Return Type:Promise<Reward>
Was this helpful?
Yes
No

deleteReward( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Deletes a reward.

Note: This endpoint requires visitor or member authentication.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Loyalty
Learn more about permission scopes.
Copy
function deleteReward(_id: string, revision: string): Promise<void>
Method Parameters
_idstringRequired

ID of the reward to delete.


revisionstringRequired

Revision number, which increments by "1" each time the reward is updated.

To prevent conflicting changes, the current revision must be passed when deleting the reward.

Was this helpful?
Yes
No

getReward( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a reward.

Note: This endpoint requires visitor or member authentication.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function getReward(_id: string): Promise<Reward>
Method Parameters
_idstringRequired

ID of the reward to retrieve.

Returns
Return Type:Promise<Reward>
Was this helpful?
Yes
No

listRewards( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Retrieves a list of rewards.

The list includes rewards that are currently nonredeemable due to insufficient points held by any customers.

Note: This endpoint requires visitor or member authentication.

Permission Scopes

For app development, you must have one of the following permission scopes:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function listRewards(options: ListRewardsOptions): Promise<ListRewardsResponse>
Method Parameters
optionsListRewardsOptions

List options.

Returns
Return Type:Promise<ListRewardsResponse>
Was this helpful?
Yes
No

updateReward( )

Developer Preview

This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.

Updates a loyalty reward.

Use this endpoint to update details of a reward, such as the name, whether or not a reward is active, or the amount of points it costs to redeem. Also use this endpoint to add new tiers that are eligible to redeem a reward.

You may not change the type of a reward. That is set upon creation and cannot be updated.

Note: This endpoint requires visitor or member authentication.

Permission Scopes

For app development, you must have one of the following permission scopes:
Manage Loyalty
Learn more about permission scopes.
Copy
function updateReward(_id: string, reward: UpdateReward): Promise<UpdateRewardResponse>
Method Parameters
_idstringRequired

Reward ID.


rewardUpdateRewardRequired

Reward info to update.

Returns
Return Type:Promise<UpdateRewardResponse>
Was this helpful?
Yes
No