Setup
To use the Accounts API, install the @wix/loyalty
package using npm or Yarn:
1npm install @wix/loyalty
or
1yarn add @wix/loyalty
Then import { accounts }
from @wix/loyalty
:
1import { accounts } from '@wix/loyalty'
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Adjusts the point balance of a loyalty account.
The adjustPoints()
function returns a Promise that resolves to the updated loyalty account.
To adjust the points balance of an account you must include an accountId
, a revision
number, and the adjustment to make. You can also leave a description to explain the reason for the points adjustment.
There are two ways to adjust the points of a loyalty account:
balance
allows you to set the total points balance to this new amount. The transactiontype
will return as"ADJUST"
.amount
allows you to alter the points balance by this amount. This amount can be a positive number to increase the points balance or a negative number to decrease the balance. The transaction type will return as"GIVE"
.
An account may not be adjusted to a negative balance. If you pass values in both the balance
and the amount
parameters then the balance
adjustment takes effect and the amount
adjustment is ignored.
Note: Only visitors with Manage Loyalty permissions can manually adjust points in a loyalty account.
Permission Scopes
For app development, you must have one of the following permission scopes:function adjustPoints(accountId: string, options: AdjustPointsOptions): Promise<AdjustPointsResponse>
Loyalty account ID.
Options to use when adjusting points.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Creates a loyalty account for one of a site's contacts.
The createAccount()
function returns a Promise that resolves to the new loyalty account when it is created.
To create a new loyalty account, the customer must first be a site contact with a contact ID. See contacts to learn more about a site's contacts. The site must also have an active loyalty program before loyalty accounts can be created. See the activateLoyaltyProgram()
function to activate a site's loyalty program.
Note: Only visitors with Manage Loyalty permissions can create a loyalty account.
Permission Scopes
For app development, you must have one of the following permission scopes:function createAccount(contactId: string): Promise<CreateAccountResponse>
Contact ID for a Wix site contact. See the Contacts API to learn more.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Adds points to a loyalty account.
The earnPoints()
function returns a Promise that resolves to the updated loyalty account.
Only a positive amount can be added using the earnPoints()
function, to manually adjust an account's balance for a negative amount, use adjustPoints()
.
The earnPoints()
function allows customers to manually earn points to their loyalty accounts. To use this function you must include an appId
and an idempotencyKey
. Any string can be set as the appId
or idempotencyKey
. In contrast to when an account earns points through an action taken on your site, the appId
automatically sets to the source app that generates the points. The transaction type
is "EARN"
for points earned this way.
Note: Only visitors with Manage Loyalty permissions can earn loyalty points.
Permission Scopes
For app development, you must have one of the following permission scopes:function earnPoints(accountId: string, options: EarnPointsOptions): Promise<EarnPointsResponse>
Loyalty account ID.
Earn points info.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves an account using the loyalty account ID.
The getAccount()
function returns a Promise that resolves to the specified loyalty account when it is retrieved.
You can also get an account using a secondary ID, such as a contact ID or a member ID with the getAccountBySecondaryId()
function.
Note: Only visitors with Manage Loyalty permissions can retrieve a loyalty account.
Permission Scopes
For app development, you must have one of the following permission scopes:function getAccount(_id: string): Promise<LoyaltyAccount>
ID of the account to retrieve.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves the loyalty account of the specified site contact or member.
The getAccountBySecondaryId()
function returns a Promise that resolves to the specified loyalty account when it is retrieved.
This function gets a loyalty account using either a customer's contact ID or member ID. You can also get an account using the loyalty account ID with the getAccount()
function.
Note: Only visitors with Manage Loyalty permissions can retrieve a loyalty account.
Permission Scopes
For app development, you must have one of the following permission scopes:function getAccountBySecondaryId(options: GetAccountBySecondaryIdOptions): Promise<GetAccountBySecondaryIdResponse>
ID of the customer to retrieve loyalty account for.
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves the total amount of points earned, redeemed, and adjusted for the entire loyalty program.
The getProgramTotals()
function returns a Promise that resolves to the combined total points for all loyalty accounts in the program.
The balance
is the current total of points outstanding, while the earned
, adjusted
, and redeemed
amounts are the all-time accumulated amounts. The totals include the amounts for all loyalty accounts.
Note: Only visitors with Manage Loyalty permissions can retrieve the loyalty program totals.
Permission Scopes
For app development, you must have one of the following permission scopes:function getProgramTotals(): Promise<GetProgramTotalsResponse>
This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a transaction using the transaction ID.
The getTransaction()
function returns a Promise that resolves to a loyalty transaction.
A loyalty transaction includes any activity that changes a loyalty account point balance, such as adjusting, earning, or redeeming loyalty points. If you want to retrieve many, or all, of the transactions for a specific loyalty account, use the listTransactions()
function.
Note: Only visitors with Manage Loyalty permissions can retrieve a loyalty transaction.
Permission Scopes
For app development, you must have one of the following permission scopes:function getTransaction(_id: string): Promise<GetTransactionResponse>
Transaction ID.
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 loyalty accounts, given the provided filters.
The listAccounts()
function returns a Promise that resolves to a list of loyalty accounts.
You can retrieve selected loyalty accounts with an array of contactIds
or retrieve a list of all of a site's loyalty accounts
with an empty request parameter. Use the cursorPaging
parameters to limit how many items load at a time.
Note: Only visitors with Manage Loyalty permissions can retrieve loyalty accounts.
Permission Scopes
For app development, you must have one of the following permission scopes:function listAccounts(options: ListAccountsOptions): Promise<ListAccountsResponse>
Options to use when retrieving a list of loyalty accounts.
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 transactions for a specified loyalty account.
The listTransactions()
function returns a Promise that resolves to a list of loyalty transactions for the loyalty account specified by the account ID.
Loyalty transactions include activities that change a loyalty account point balance, such as adjusting, earning, or redeeming loyalty points. If you want to get a specific transaction use that transaction's ID and the getTransaction()
function.
Permission Scopes
For app development, you must have one of the following permission scopes:function listTransactions(accountId: string, options: ListTransactionsOptions): Promise<ListTransactionsResponse>
Loyalty account ID.
Options to use when retrieving a list of loyalty transactions.
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 accounts, given the provided filters and search capabilities. Search is executed on the account's name and email values.
Permission Scopes
For app development, you must have one of the following permission scopes:function searchAccounts(options: SearchAccountsOptions): Promise<SearchAccountsResponse>