> 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 # GetCurrentMemberAccount # Package: accounts # Namespace: LoyaltyAccounts # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/accounts/accounts/get-current-member-account.md ## Permission Scopes: Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY ## Introduction Retrieves the current member's loyalty account. --- ## REST API ### Schema ``` Method: getCurrentMemberAccount Description: Retrieves the current member's loyalty account. URL: https://www.wixapis.com/v1/accounts/my-account Method: GET Return type: GetCurrentMemberAccountResponse - name: account | type: LoyaltyAccount | description: Loyalty account. - name: id | type: string | description: Account GUID. - name: contactId | type: string | description: Account owner's contact GUID. See the Contacts API to learn more about a site's contacts. - name: memberId | type: string | description: Member GUID of the account owner. See the Members API to learn more about a site's members. - name: points | type: Points | description: Details of the account's point totals. - name: balance | type: integer | description: Current points balance. Equal to the sum of `earned` and `adjusted` points, minus `redeemed` points. - name: earned | type: integer | description: Total earned points. - name: adjusted | type: integer | description: Total adjusted points. - name: redeemed | type: integer | description: Total redeemed points. - name: expired | type: integer | description: Total expired points. - name: rewardAvailable | type: boolean | description: Whether the account has enough points in `points.balance` to redeem for a reward. - name: createdDate | type: string | description: Date and time the account was created. - name: updatedDate | type: string | description: Date and time the account was last updated. - name: lastActivityDate | type: string | description: Date and time of the account's last activity. - name: revision | type: number | description: Revision number, which increments by 1 each time the loyalty account is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty account. Ignored when creating an account. - name: tier | type: Tier | description: Tier information. See the Tiers API for more information. - name: id | type: string | description: Tier GUID. This field will not be returned if the account belongs to the base tier. - name: updatedDate | type: string | description: Date and time the tier information was last recalculated. - name: points | type: integer | description: Points earned and adjusted over the tier's current rolling window. - name: contact | type: Contact | description: Contact information. - name: id | type: string | description: Contact GUID. - name: name | type: string | description: Contact's first and last name. - name: picture | type: Image | description: Contact's profile picture. - 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: email | type: string | description: Contact's email address. - name: displayName | type: string | description: Contact's first and last name. If no name is provided, uses contact's email. - name: pointsExpiration | type: PointsExpiration | description: Points expiration information. - name: expirationDate | type: string | description: Date and time at which points are expiring. - name: expiringPointsAmount | type: integer | description: Amount of points that are going to expire at that date. ``` ### Examples ### Get currently logged-in member account ```curl curl -X GET \ 'https://www.wixapis.com/loyalty-accounts/v1/accounts/my-account' \ -H 'Authorization: ' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.accounts.LoyaltyAccounts.getCurrentMemberAccount() Description: Retrieves the current member's loyalty account. Return type: PROMISE - name: account | type: LoyaltyAccount | description: Loyalty account. - name: _id | type: string | description: Account GUID. - name: contactId | type: string | description: Account owner's contact GUID. See the Contacts API to learn more about a site's contacts. - name: memberId | type: string | description: Member GUID of the account owner. See the Members API to learn more about a site's members. - name: points | type: Points | description: Details of the account's point totals. - name: balance | type: integer | description: Current points balance. Equal to the sum of `earned` and `adjusted` points, minus `redeemed` points. - name: earned | type: integer | description: Total earned points. - name: adjusted | type: integer | description: Total adjusted points. - name: redeemed | type: integer | description: Total redeemed points. - name: expired | type: integer | description: Total expired points. - name: rewardAvailable | type: boolean | description: Whether the account has enough points in `points.balance` to redeem for a reward. - name: _createdDate | type: Date | description: Date and time the account was created. - name: _updatedDate | type: Date | description: Date and time the account was last updated. - name: lastActivityDate | type: Date | description: Date and time of the account's last activity. - name: revision | type: number | description: Revision number, which increments by 1 each time the loyalty account is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty account. Ignored when creating an account. - name: tier | type: Tier | description: Tier information. See the Tiers API for more information. - name: _id | type: string | description: Tier GUID. This field will not be returned if the account belongs to the base tier. - name: _updatedDate | type: Date | description: Date and time the tier information was last recalculated. - name: points | type: integer | description: Points earned and adjusted over the tier's current rolling window. - name: contact | type: Contact | description: Contact information. - name: _id | type: string | description: Contact GUID. - name: name | type: string | description: Contact's first and last name. - name: picture | type: Image | description: Contact's profile picture. - 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: email | type: string | description: Contact's email address. - name: displayName | type: string | description: Contact's first and last name. If no name is provided, uses contact's email. - name: pointsExpiration | type: PointsExpiration | description: Points expiration information. - name: expirationDate | type: Date | description: Date and time at which points are expiring. - name: expiringPointsAmount | type: integer | description: Amount of points that are going to expire at that date. ``` ### Examples ### Get current member account ```javascript import { accounts } from "@wix/loyalty"; async function getCurrentMemberAccount() { try { const result = await accounts.getCurrentMemberAccount(); return result; } catch (error) { console.error(error); // Handle the error } } /* * Promise resolves to: * * { * "account": { * "_createdDate": "2024-06-06T12:46:55.496Z", * "_id": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303", * "_updatedDate": "2024-06-10T15:27:33.039Z", * "contact": { * "name": "Elena Rodriguez", * "picture": { * "url": "https://lh3.googleusercontent.com/a/ACg8ocIYi6J3Jd-V88AyFM27n-LU_-WZmmZy04kU_UfYODaSDwipBgQ%3Ds96-c", * "height": 0, * "width": 0, * "_id": "" * }, * "email": "elena.rodriguez@example.com", * "displayName": "Elena Rodriguez", * "_id": "6ef3fe0f-9e33-42d3-8abe-61d5560338b2" * }, * "contactId": "6ef3fe0f-9e33-42d3-8abe-61d5560338b2", * "lastActivityDate": "2024-06-10T15:27:30.954Z", * "memberId": "7d368843-6f0c-4037-8d0e-b7e36a8a0c32", * "points": { * "balance": 50, * "earned": 0, * "adjusted": 70, * "redeemed": 20, * "expired": 0 * }, * "pointsExpiration": { * "expirationDate": "2024-09-10T15:27:31.268Z", * "expiringPointsAmount": 50 * }, * "revision": "21", * "rewardAvailable": true, * "tier": { * "points": 70, * "_updatedDate": "2024-06-10T15:27:31.041Z" * } * } * } */ ``` ### getCurrentMemberAccount (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 { accounts } from '@wix/loyalty'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { accounts }, // Include the auth strategy and host as relevant }); async function getCurrentMemberAccount() { const response = await myWixClient.accounts.getCurrentMemberAccount(); }; ``` ---