Setup

To use the Accounts 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 { accounts } from @wix/loyalty:

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

adjustPoints( )

Developer Preview

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 transaction type 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:
Manage Loyalty
Learn more about permission scopes.
Copy
function adjustPoints(accountId: string, options: AdjustPointsOptions): Promise<AdjustPointsResponse>
Method Parameters
accountIdstringRequired
Loyalty account ID.

optionsAdjustPointsOptions
Options to use when adjusting points.
Returns
Return Type:Promise<AdjustPointsResponse>
Was this helpful?
Yes
No

createAccount( )

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 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:
Manage Loyalty
Learn more about permission scopes.
Copy
function createAccount(contactId: string): Promise<CreateAccountResponse>
Method Parameters
contactIdstringRequired
Contact ID for a Wix site contact. See the Contacts API to learn more.
Returns
Return Type:Promise<CreateAccountResponse>
Was this helpful?
Yes
No

earnPoints( )

Developer Preview

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:
Manage Loyalty
Learn more about permission scopes.
Copy
function earnPoints(accountId: string, options: EarnPointsOptions): Promise<EarnPointsResponse>
Method Parameters
accountIdstringRequired
Loyalty account ID.

optionsEarnPointsOptions
Earn points info.
Returns
Return Type:Promise<EarnPointsResponse>
Was this helpful?
Yes
No

getAccount( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function getAccount(_id: string): Promise<LoyaltyAccount>
Method Parameters
_idstringRequired
ID of the account to retrieve.
Returns
Return Type:Promise<LoyaltyAccount>
Was this helpful?
Yes
No

getAccountBySecondaryId( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function getAccountBySecondaryId(options: GetAccountBySecondaryIdOptions): Promise<GetAccountBySecondaryIdResponse>
Method Parameters
optionsGetAccountBySecondaryIdOptions
ID of the customer to retrieve loyalty account for.
Returns
Return Type:Promise<GetAccountBySecondaryIdResponse>
Was this helpful?
Yes
No

getProgramTotals( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function getProgramTotals(): Promise<GetProgramTotalsResponse>
Request
This method does not take any parameters
Returns
Return Type:Promise<GetProgramTotalsResponse>
Was this helpful?
Yes
No

getTransaction( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function getTransaction(_id: string): Promise<GetTransactionResponse>
Method Parameters
_idstringRequired
Transaction ID.
Returns
Return Type:Promise<GetTransactionResponse>
Was this helpful?
Yes
No

listAccounts( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function listAccounts(options: ListAccountsOptions): Promise<ListAccountsResponse>
Method Parameters
optionsListAccountsOptions
Options to use when retrieving a list of loyalty accounts.
Returns
Return Type:Promise<ListAccountsResponse>
Was this helpful?
Yes
No

listTransactions( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function listTransactions(accountId: string, options: ListTransactionsOptions): Promise<ListTransactionsResponse>
Method Parameters
accountIdstringRequired
Loyalty account ID.

optionsListTransactionsOptions
Options to use when retrieving a list of loyalty transactions.
Returns
Return Type:Promise<ListTransactionsResponse>
Was this helpful?
Yes
No

searchAccounts( )

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 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:
Read Loyalty
Manage Loyalty
Learn more about permission scopes.
Copy
function searchAccounts(options: SearchAccountsOptions): Promise<SearchAccountsResponse>
Method Parameters
optionsSearchAccountsOptions
Returns
Return Type:Promise<SearchAccountsResponse>
Was this helpful?
Yes
No