Search.../

createReward( )

Developer Preview

Creates a reward that can be redeemed with loyalty points.

Description

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.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function createReward(reward: Reward): Promise<CreateRewardResponse>

createReward Parameters

NAME
TYPE
DESCRIPTION
reward
Reward

Reward to create.

Returns

Return Type:

Promise<
CreateRewardResponse
>
NAME
TYPE
DESCRIPTION
reward
Reward

Created reward.

Was this helpful?

createReward example

Copy Code
1import { rewards } from 'wix-loyalty.v2';
2
3 async function createReward(reward) {
4 try {
5 const result = await rewards.createReward(reward);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13