listAccounts( )


Deprecated

This method has been replaced with Query Loyalty Accounts, and will be removed on June 30, 2025.

Deprecation Notice

This method has been replaced with Query Loyalty Accounts and will be removed on June 30, 2025. If your app uses this method, we recommend updating your code as soon as possible.

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.

Authentication
  • When developing websites or building an app with Blocks, this method may require elevated permissions, depending on the identity of the user calling it and the calling user’s permissions.
  • When building apps without Blocks or for headless projects, you can only call this method directly when authenticated as a Wix app or Wix user identity. When authenticated as a different identity, you can call this method using elevation.
  • Elevation permits users to call methods they typically cannot access. Therefore, you should only use it intentionally and securely.
Permissions
Manage Loyalty
Read Loyalty
Learn more about app permissions.
Method Declaration
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>
JavaScript
import { accounts } from "@wix/loyalty"; /* Sample options value: * { * 'cursorPaging': { * 'limit': 3 * } * } */ const options = { cursorPaging: { limit: 3, }, }; export async function myListLoyaltyAccountsFunction() { try { const accountsList = await accounts.listAccounts(options); const firstAccountId = accountsList.accounts[0]._id; const firstAccountBalance = accountsList.accounts[0].points.balance; console.log( "Success! The ID and point balance for the first account in your list is: ", firstAccountId, " and ", firstAccountBalance, ); return accountsList; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "accounts": [ * { * "_id": "dd0020ca-eef0-4ff1-a615-63ecdcdfcd28", * "contactId": "8a71f711-f77b-43fe-9e3d-5c243f94b2bc", * "points": { * "balance": 700, * "earned": 135, * "adjusted": 565, * "redeemed": 0 * }, * "rewardAvailable": true, * "_createdDate": "2022-11-08T22:52:44.758Z", * "_updatedDate": "2022-11-09T11:18:45.037Z", * "revision": "6", * "tier": { * "_updatedDate": "2022-11-09T11:18:45.037Z", * "points": 700 * } * }, * { * "_id": "7b801cdf-e74c-42b7-ba57-a068a78ea6b5", * "contactId": "6f158e70-26f6-4fce-80a8-1d57e6791c34", * "points": { * "balance": 125, * "earned": 125, * "adjusted": 0, * "redeemed": 0 * }, * "rewardAvailable": true, * "_createdDate": "2022-11-07T15:49:11.763Z", * "_updatedDate": "2022-11-09T06:41:48.879Z", * "revision": "3", * "tier": { * "_updatedDate": "2022-11-09T06:41:48.616Z", * "points": 125 * } * }, * { * "_id": "f0411f1a-ad5a-4b80-94c2-34350cbf1af7", * "contactId": "8a71f711-f77b-43fe-9e3d-5c243f94b2cd", * "points": { * "balance": 0, * "earned": 0, * "adjusted": 0, * "redeemed": 0 * }, * "rewardAvailable": false, * "_createdDate": "2022-11-09T06:44:48.159Z", * "_updatedDate": "2022-11-09T06:44:48.159Z", * "revision": "1" * } * ], * "pagingMetadata": { * "count": 3, * "total": 4, * "cursors": { * "next": "4cdca1370d1419d1874c0eb639ef64804fa6d5de.Gh0KDnBvaW50cy5iYWxhbmNlEAEaCREAAAAAAAAAABorCgxfdXBkYXRlZERhdGUaGyoZChcKCiR0aW1lc3RhbXASCREA8HklskV4QiIkZjA0MTFmMWEtYWQ1YS00YjgwLTk0YzItMzQzNTBjYmYxYWY3" * } * } * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?