> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# GetAccount

# Package: accounts

# Namespace: LoyaltyAccounts

# Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/accounts/accounts/get-account?apiView=SDK.md

## Permission Scopes:
Read Loyalty: SCOPE.DC-LOYALTY.READ-LOYALTY

## Introduction

Retrieves a loyalty account by ID.

You can also retrieve an account using a secondary ID, such as a contact ID or a member ID by calling
Get Account by Secondary ID.

---

## REST API

### Schema

```
 Method: getAccount
 Description: Retrieves a loyalty account by GUID.  You can also retrieve an account using a secondary GUID, such as a contact GUID or a member GUID by calling Get Account by Secondary GUID.
 URL: https://www.wixapis.com/loyalty-accounts/v1/accounts/{id}
 Method: GET
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  id
 Method parameters: 
   param name: id | type:   none | required: true 
 Return type: GetAccountResponse
  - name: account | type: LoyaltyAccount | description: Retrieved loyalty account.  
     - name: id | type: string | description: Account GUID.  | read-only: true | validation: format GUID
     - name: contactId | type: string | description: Account owner's contact GUID. See the Contacts API to learn more about a site's contacts.  | read-only: true | validation: format GUID
     - name: memberId | type: string | description: Member GUID of the account owner. See the Members API to learn more about a site's members.  | read-only: true | validation: format GUID
     - name: points | type: Points | description: Details of the account's point totals.  | read-only: true 
        - name: balance | type: integer | description: Current points balance.  Equal to the sum of `earned` and `adjusted` points, minus `redeemed` points.  | read-only: true | validation: minimum 0
        - name: earned | type: integer | description: Total earned points.  | read-only: true | validation: minimum 0
        - name: adjusted | type: integer | description: Total adjusted points.  | read-only: true | validation: minimum 0
        - name: redeemed | type: integer | description: Total redeemed points.  | read-only: true | validation: minimum 0
        - name: expired | type: integer | description: Total expired points.  | read-only: true | validation: minimum 0
     - name: rewardAvailable | type: boolean | description: Whether the account has enough points in `points.balance` to redeem for a reward.  | read-only: true 
     - name: createdDate | type: string | description: Date and time the account was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the account was last updated.  | read-only: true | validation: format date-time
     - name: lastActivityDate | type: string | description: Date and time of the account's last activity.  | read-only: true | validation: format date-time
     - 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.  | read-only: true 
        - name: id | type: string | description: Tier GUID.  This field will not be returned if the account belongs to the base tier.  | read-only: true | validation: format GUID
        - name: updatedDate | type: string | description: Date and time the tier information was last recalculated.  | read-only: true | validation: format date-time
        - name: points | type: integer | description: Points earned and adjusted over the tier's current rolling window.  | read-only: true | validation: minimum 0
     - name: contact | type: Contact | description: Contact information.  | read-only: true 
        - name: id | type: string | description: Contact GUID.  | read-only: true | validation: format GUID
        - name: name | type: string | description: Contact's first and last name.  | read-only: true 
        - name: picture | type: Image | description: Contact's profile picture.  | read-only: true 
           - name: id | type: string | description: WixMedia image GUID.  
           - name: url | type: string | description: Image URL.  
           - name: height | type: integer | description: Original image height.  | read-only: true 
           - name: width | type: integer | description: Original image width.  | read-only: true 
        - name: email | type: string | description: Contact's email address.  | read-only: true | validation: format EMAIL
        - name: displayName | type: string | description: Contact's first and last name. If no name is provided, uses contact's email.  | read-only: true 
     - name: pointsExpiration | type: PointsExpiration | description: Points expiration information.  | read-only: true 
        - name: expirationDate | type: string | description: Date and time at which points are expiring.  | read-only: true | validation: format date-time
        - name: expiringPointsAmount | type: integer | description: Amount of points that are going to expire at that date.  | read-only: true 


```

### Examples

### Get an account
```curl
curl -X GET \
  'https://www.wixapis.com/loyalty-accounts/v1/accounts/e6f39a5b-a6d0-4556-b889-0cf09d8a84f7' \
  -H 'Authorization: <AUTH>'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.accounts.getAccount(_id)
 Description: Retrieves a loyalty account by GUID.  You can also retrieve an account using a secondary GUID, such as a contact GUID or a member GUID by calling Get Account by Secondary GUID.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  _id
 Method parameters: 
   param name: _id | type: string | description: GUID of the account to retrieve. | required: true | validation: format GUID
 Return type: PROMISE<LoyaltyAccount>
  - name: _id | type: string | description: Account GUID.  | read-only: true | validation: format GUID
  - name: contactId | type: string | description: Account owner's contact GUID. See the Contacts API to learn more about a site's contacts.  | read-only: true | validation: format GUID
  - name: memberId | type: string | description: Member GUID of the account owner. See the Members API to learn more about a site's members.  | read-only: true | validation: format GUID
  - name: points | type: Points | description: Details of the account's point totals.  | read-only: true 
     - name: balance | type: integer | description: Current points balance.  Equal to the sum of `earned` and `adjusted` points, minus `redeemed` points.  | read-only: true | validation: minimum 0
     - name: earned | type: integer | description: Total earned points.  | read-only: true | validation: minimum 0
     - name: adjusted | type: integer | description: Total adjusted points.  | read-only: true | validation: minimum 0
     - name: redeemed | type: integer | description: Total redeemed points.  | read-only: true | validation: minimum 0
     - name: expired | type: integer | description: Total expired points.  | read-only: true | validation: minimum 0
  - name: rewardAvailable | type: boolean | description: Whether the account has enough points in `points.balance` to redeem for a reward.  | read-only: true 
  - name: _createdDate | type: Date | description: Date and time the account was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the account was last updated.  | read-only: true 
  - name: lastActivityDate | type: Date | description: Date and time of the account's last activity.  | read-only: true 
  - 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.  | read-only: true 
     - name: _id | type: string | description: Tier GUID.  This field will not be returned if the account belongs to the base tier.  | read-only: true | validation: format GUID
     - name: _updatedDate | type: Date | description: Date and time the tier information was last recalculated.  | read-only: true 
     - name: points | type: integer | description: Points earned and adjusted over the tier's current rolling window.  | read-only: true | validation: minimum 0
  - name: contact | type: Contact | description: Contact information.  | read-only: true 
     - name: _id | type: string | description: Contact GUID.  | read-only: true | validation: format GUID
     - name: name | type: string | description: Contact's first and last name.  | read-only: true 
     - name: picture | type: Image | description: Contact's profile picture.  | read-only: true 
        - name: _id | type: string | description: WixMedia image GUID.  
        - name: url | type: string | description: Image URL.  
        - name: height | type: integer | description: Original image height.  | read-only: true 
        - name: width | type: integer | description: Original image width.  | read-only: true 
     - name: email | type: string | description: Contact's email address.  | read-only: true | validation: format EMAIL
     - name: displayName | type: string | description: Contact's first and last name. If no name is provided, uses contact's email.  | read-only: true 
  - name: pointsExpiration | type: PointsExpiration | description: Points expiration information.  | read-only: true 
     - name: expirationDate | type: Date | description: Date and time at which points are expiring.  | read-only: true 
     - name: expiringPointsAmount | type: integer | description: Amount of points that are going to expire at that date.  | read-only: true 


```

### Examples

### Get a loyalty account (with elevated permissions)
```javascript
import { accounts } from '@wix/loyalty';
import { auth } from '@wix/essentials';


// Sample accountId value: 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7'

const elevatedGetAccount = auth.elevate(accounts.getAccount);

const accountId = 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7';

export async function myGetLoyaltyAccountFunction() {
  try {
    const loyaltyAccount = await elevatedGetAccount(accountId);

    const currentBalance = loyaltyAccount.points.balance;
    const canGetReward = loyaltyAccount.rewardAvailable;

    console.log('Success! Current points balance for this account is: ', currentBalance, ' and there is a reward available: ', canGetReward);

    return loyaltyAccount;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "account": {
 *     "_id": "e6f39a5b-a6d0-4556-b889-0cf09d8a84f7",
 *     "contactId": "88615e02-3e8a-4297-8939-5d0a432b322a",
 *     "memberId": "a517751b-a1ca-4423-8d91-aaf8f5b34215",
 *     "points":   {
 *       "balance": 15,
 *       "earned": 10,
 *       "redeemed": 0,
 *       "adjusted": 5
 *     },
 *     "rewardAvailable": true,
 *     "_createdDate": "2021-12-06T14:33:19.114Z",
 *     "_updatedDate": "2021-12-07T07:30:23.749Z",
 *     "revision": "4"
 *   }
 * } 
 */
```

### Get a loyalty account
```javascript
import { accounts } from '@wix/loyalty';

// Sample accountId value: 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7'

export async function myGetLoyaltyAccountFunction() {
  try {
    const accountId = 'e6f39a5b-a6d0-4556-b889-0cf09d8a84f7'; // Added accountId declaration
    const loyaltyAccount = await accounts.getAccount(accountId);

    const currentBalance = loyaltyAccount.points.balance;
    const canGetReward = loyaltyAccount.rewardAvailable;

    console.log('Success! Current points balance for this account is: ', currentBalance, ' and there is a reward available: ', canGetReward);

    return loyaltyAccount;
  } catch (error) {
    console.error(error);
  }
}

/* Promise resolves to:
 * {
 *   "account": {
 *     "_id": "e6f39a5b-a6d0-4556-b889-0cf09d8a84f7",
 *     "contactId": "88615e02-3e8a-4297-8939-5d0a432b322a",
 *     "memberId": "a517751b-a1ca-4423-8d91-aaf8f5b34215",
 *     "points":   {
 *       "balance": 15,
 *       "earned": 10,
 *       "redeemed": 0,
 *       "adjusted": 5
 *     },
 *     "rewardAvailable": true,
 *     "_createdDate": "2021-12-06T14:33:19.114Z",
 *     "_updatedDate": "2021-12-07T07:30:23.749Z",
 *     "revision": "4"
 *   }
 * } 
 */
```

### getAccount (self-managed)
Self-managed 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 getAccount(_id) {
  const response = await myWixClient.accounts.getAccount(_id);
};
```

---