> 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 # Method name: createAccount(contactId: string) # Method package: wixLoyaltyV2 # Method menu location: wixLoyaltyV2 --> accounts --> createAccount # Method Link: https://dev.wix.com/docs/velo/apis/wix-loyalty-v2/accounts/create-account.md # Method Description: Creates a loyalty account for a site contact. To create a new loyalty account, a customer must first be a site contact with a contact ID, see the Contacts API. The site must also have an [active loyalty program](https://dev.wix.com/docs/rest/crm/loyalty-program/program/activate-loyalty-program.md) before loyalty accounts can be created. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a loyalty account for a site contact (dashboard page code) ```javascript import { accounts } from 'wix-loyalty.v2'; // Sample contactId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28' export async function myCreateAccountFunction() { try { const newLoyaltyAccount = await accounts.createAccount(contactId); const accountId = newLoyaltyAccount.account._id; console.log('Success! The account ID for this new loyalty account is: ', accountId); return newLoyaltyAccount; } catch (error) { console.error(error); } } /* Promise resolves to: * { * "account": { * "_id": "1e3f99cf-1e7f-4cba-8777-f081549f49cd", * "contactId": "ff61204b-b19a-5cc8-823b-7eed8ae5fc28", * "points": { * "balance": 0, * "earned": 0, * "adjusted": 0, * "redeemed": 0 * }, * "rewardAvailable": false, * "_createdDate": "2022-11-09T12:49:25.408Z", * "_updatedDate": "2022-11-09T12:49:25.408Z", * "revision": "1" * } * } */ ``` ## Create a loyalty account for a site contact (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { accounts } from 'wix-loyalty.v2'; // Sample contactId value: 'ff61204b-b19a-5cc8-823b-7eed8ae5fc28' export const myCreateAccountFunction = webMethod( Permissions.Anyone, async () => { try { const newLoyaltyAccount = await accounts.createAccount(contactId); const accountId = newLoyaltyAccount.account._id; console.log('Success! The account ID for this new loyalty account is: ', accountId); return newLoyaltyAccount; } catch (error) { console.error(error); } }); /* Promise resolves to: * { * "account": { * "_id": "1e3f99cf-1e7f-4cba-8777-f081549f49cd", * "contactId": "ff61204b-b19a-5cc8-823b-7eed8ae5fc28", * "points": { * "balance": 0, * "earned": 0, * "adjusted": 0, * "redeemed": 0 * }, * "rewardAvailable": false, * "_createdDate": "2022-11-09T12:49:25.408Z", * "_updatedDate": "2022-11-09T12:49:25.408Z", * "revision": "1" * } * } */ ``` ---