> 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`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # UpdateLoyaltyProgram # Package: loyaltyProgramManagement # Namespace: LoyaltyPrograms # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/loyalty-program-management/program/update-loyalty-program.md ## Permission Scopes: Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY ## Introduction Updates a site's loyalty program. This method updates the name of the loyalty program and the details of the collectible points unit. To activate the loyalty program, call Activate Loyalty Program. --- ## REST API ### Schema ``` Method: updateLoyaltyProgram Description: Updates a site's loyalty program. This method updates the name of the loyalty program and the details of the collectible points unit. To activate the loyalty program, call Activate Loyalty Program. URL: https://www.wixapis.com/v1/program Method: PATCH # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: loyaltyProgram Method parameters: param name: loyaltyProgram | type: LoyaltyProgram | description: A loyalty program allows sites to maintain customer reward accounts. Wix users can create a loyalty program to increase customer retention. Read more about the [loyalty program](https://support.wix.com/en/article/wix-loyalty-program-an-overview). | required: true - name: name | type: string | description: Program name. - name: pointDefinition | type: PointDefinition | description: Details about the program's collectible unit. - name: customName | type: string | description: Display name for the program's collectible unit. It's recommended to use a plural, for example `"Stars"`. In contrast to a custom name, the default `"Points"` name is translated and adjusted to singular based on circumstances. Default: `"Points"`. - name: icon | type: Image | description: Details about the points icon. - name: id | type: string | description: WixMedia image GUID. - name: url | type: string | description: Image URL. - name: altText | type: string | description: Image alt text. - name: pointsExpiration | type: PointsExpiration | description: Configuration for the points expiration feature. - name: monthsOfInactivity | type: integer | description: How many months a member should be inactive to lose the collected points. - name: expiringPointsPercentage | type: integer | description: Percentage of points that a member loses after being inactive. Return type: UpdateLoyaltyProgramResponse - name: loyaltyProgram | type: LoyaltyProgram | description: Updated loyalty program. - name: name | type: string | description: Program name. - name: pointDefinition | type: PointDefinition | description: Details about the program's collectible unit. - name: customName | type: string | description: Display name for the program's collectible unit. It's recommended to use a plural, for example `"Stars"`. In contrast to a custom name, the default `"Points"` name is translated and adjusted to singular based on circumstances. Default: `"Points"`. - name: icon | type: Image | description: Details about the points icon. - name: id | type: string | description: WixMedia image GUID. - name: url | type: string | description: Image URL. - name: height | type: integer | description: Original image height. - name: width | type: integer | description: Original image width. - name: altText | type: string | description: Image alt text. - name: filename | type: string | description: Image filename. - name: status | type: ProgramStatus | description: Program status. Customers can only earn or redeem points while the program is `"ACTIVE"`. Default: `"DRAFT"` - enum: - UNKNOWN: Unknown program status. - DRAFT: Program is in draft mode. Customers can't earn or redeem points. - ACTIVE: Program is active. Customers can earn and redeem points. - PAUSED: Program is paused. Customers can't earn or redeem points while the program is paused. Set the program to `"ACTIVE"` to resume earning and redeeming points. - name: createdDate | type: string | description: Date and time the program was created. - name: updatedDate | type: string | description: Date and time the program was updated. - name: pointsExpiration | type: PointsExpiration | description: Configuration for the points expiration feature. - name: status | type: Status | description: Status of the points expiration feature. - enum: - DISABLED: Points expiration feature is disabled. - ENABLED: Points expiration feature is enabled. - name: monthsOfInactivity | type: integer | description: How many months a member should be inactive to lose the collected points. - name: expiringPointsPercentage | type: integer | description: Percentage of points that a member loses after being inactive. - name: premiumFeatures | type: PremiumFeatures | description: Information about the available program premium features. - name: loyaltyProgram | type: boolean | description: Whether there are any loyalty program premium features. - name: tiers | type: boolean | description: Whether this loyalty program includes tiers. - name: pointsExpiration | type: boolean | description: Whether this loyalty program includes point expiration. ``` ### Examples ### Update loyalty program ```curl curl -X PATCH \ 'https://www.wixapis.com/loyalty-programs/v1/program' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ --data-raw '{ "loyaltyProgram": { "name": "Northern Star Loyalty Program", "points": { "customName": "Northern Star" } } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.loyaltyProgramManagement.LoyaltyPrograms.updateLoyaltyProgram(loyaltyProgram) Description: Updates a site's loyalty program. This method updates the name of the loyalty program and the details of the collectible points unit. To activate the loyalty program, call Activate Loyalty Program. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: loyaltyProgram Method parameters: param name: loyaltyProgram | type: LoyaltyProgram | description: A loyalty program allows sites to maintain customer reward accounts. Wix users can create a loyalty program to increase customer retention. Read more about the [loyalty program](https://support.wix.com/en/article/wix-loyalty-program-an-overview). | required: true - name: name | type: string | description: Program name. - name: pointDefinition | type: PointDefinition | description: Details about the program's collectible unit. - name: customName | type: string | description: Display name for the program's collectible unit. It's recommended to use a plural, for example `"Stars"`. In contrast to a custom name, the default `"Points"` name is translated and adjusted to singular based on circumstances. Default: `"Points"`. - name: icon | type: string | description: Details about the points icon. - name: pointsExpiration | type: PointsExpiration | description: Configuration for the points expiration feature. - name: monthsOfInactivity | type: integer | description: How many months a member should be inactive to lose the collected points. - name: expiringPointsPercentage | type: integer | description: Percentage of points that a member loses after being inactive. Return type: PROMISE - name: loyaltyProgram | type: LoyaltyProgram | description: Updated loyalty program. - name: name | type: string | description: Program name. - name: pointDefinition | type: PointDefinition | description: Details about the program's collectible unit. - name: customName | type: string | description: Display name for the program's collectible unit. It's recommended to use a plural, for example `"Stars"`. In contrast to a custom name, the default `"Points"` name is translated and adjusted to singular based on circumstances. Default: `"Points"`. - name: icon | type: string | description: Details about the points icon. - name: status | type: ProgramStatus | description: Program status. Customers can only earn or redeem points while the program is `"ACTIVE"`. Default: `"DRAFT"` - enum: - UNKNOWN: Unknown program status. - DRAFT: Program is in draft mode. Customers can't earn or redeem points. - ACTIVE: Program is active. Customers can earn and redeem points. - PAUSED: Program is paused. Customers can't earn or redeem points while the program is paused. Set the program to `"ACTIVE"` to resume earning and redeeming points. - name: _createdDate | type: Date | description: Date and time the program was created. - name: _updatedDate | type: Date | description: Date and time the program was updated. - name: pointsExpiration | type: PointsExpiration | description: Configuration for the points expiration feature. - name: status | type: Status | description: Status of the points expiration feature. - enum: - DISABLED: Points expiration feature is disabled. - ENABLED: Points expiration feature is enabled. - name: monthsOfInactivity | type: integer | description: How many months a member should be inactive to lose the collected points. - name: expiringPointsPercentage | type: integer | description: Percentage of points that a member loses after being inactive. - name: premiumFeatures | type: PremiumFeatures | description: Information about the available program premium features. - name: loyaltyProgram | type: boolean | description: Whether there are any loyalty program premium features. - name: tiers | type: boolean | description: Whether this loyalty program includes tiers. - name: pointsExpiration | type: boolean | description: Whether this loyalty program includes point expiration. ``` ### Examples ### Update the loyalty program name and the name of its points (with elevated permissions) ```javascript import { programs } from '@wix/loyalty'; import { auth } from '@wix/essentials'; /* Sample loyaltyProgram object: * { * name: 'Flower Power Program', * pointDefinition: { * customName: 'Petals' * } * } */ export async function myUpdateLoyaltyProgramFunction(loyaltyProgram) { const elevatedUpdateProgram = auth.elevate(programs.updateLoyaltyProgram) try { const updatedLoyaltyProgram = await elevatedUpdateProgram(loyaltyProgram); const newName = updatedLoyaltyProgram.loyaltyProgram.name; const newPointsName = updatedLoyaltyProgram.loyaltyProgram.pointDefinition.customName; console.log('Success! The names of your loyalty program and its points are now: ', newName, newPointsName); return updatedLoyaltyProgram; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "loyaltyProgram": { * "name": "Flower Power Program", * "pointDefinition": { * "customName": "Petals", * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg" * }, * "status": "ACTIVE", * "_createdDate": "2022-11-07T15:26:12.798Z", * "_updatedDate": "2022-11-09T10:07:08.601Z" * } * } */ ``` ### Update the loyalty program name and the name of its points ```javascript import { programs } from '@wix/loyalty'; /* Sample loyaltyProgram object: * { * name: 'Flower Power Program', * pointDefinition: { * customName: 'Petals' * } * } */ export async function myUpdateLoyaltyProgramFunction(loyaltyProgram) { try { const updatedLoyaltyProgram = await programs.updateLoyaltyProgram(loyaltyProgram); const newName = updatedLoyaltyProgram.loyaltyProgram.name; const newPointsName = updatedLoyaltyProgram.loyaltyProgram.pointDefinition.customName; console.log('Success! The names of your loyalty program and its points are now: ', newName, newPointsName); return updatedLoyaltyProgram; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "loyaltyProgram": { * "name": "Flower Power Program", * "pointDefinition": { * "customName": "Petals", * "icon": "shapes/8de38e8fe76f4e9f937ae23e9ba1eb04.svg" * }, * "status": "ACTIVE", * "_createdDate": "2022-11-07T15:26:12.798Z", * "_updatedDate": "2022-11-09T10:07:08.601Z" * } * } */ ``` ### updateLoyaltyProgram (self-hosted) Self-hosted 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 { programs } from '@wix/loyalty'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { programs }, // Include the auth strategy and host as relevant }); async function updateLoyaltyProgram(loyaltyProgram) { const response = await myWixClient.programs.updateLoyaltyProgram(loyaltyProgram); }; ``` ---