> 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

# Method name: adjustPoints(accountId: string, options: AdjustPointsOptions)

# Method package: wixLoyaltyV2

# Method menu location: wixLoyaltyV2 --> accounts --> adjustPoints

# Method Link: https://dev.wix.com/docs/velo/apis/wix-loyalty-v2/accounts/adjust-points.md

# Method Description:

Adjusts the point balance of a loyalty account.

You can adjust the balance in two ways:
- `balance` allows you to set the total points balance to this new amount. The transaction `type` will return as `"ADJUST"`.
- `amount` allows you to adjust 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 result in a negative balance. If you pass an integer in both the `balance` and the `amount` parameters then the `balance` adjustment takes effect and the
`amount` adjustment is ignored.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Adjust loyalty account balance (dashboard page code)

```javascript
import { accounts } from 'wix-loyalty.v2';

// Sample accountId value: "1ab8f49c-a329-4ddc-a31d-814afbb3b565";

/* Sample options values:
 *  {
 *    balance: 715,
 *    description: "Sync from external program.",
 *    revision: "3"
 *   };
 */

export async function myAdjustPointsFunction(accountId, options) {
  try {
    const updatedAccount = await accounts.adjustPoints(accountId, options);

    const updatedBalance = updatedAccount.account.points.balance;
    const transactionId = updatedAccount.transaction_id;

    console.log('Success! New account balance is: ', updatedBalance, ' The ID for this transaction is: ', transactionId);  

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

/* Promise resolves to:
 * {
 *   "transaction_id": "1ab8f49c-a329-4ddc-a31d-814afbb3b565",
 *   "account": {
 *     "_id": "1ab8f49c-a329-4ddc-a31d-814afbb3b565",
 *     "contactId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "memberId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "points": {
 *       "balance": 715,
 *       "earned": 0,
 *       "adjusted": 715,
 *       "redeemed": 0
 *     },
 *     "rewardAvailable": false,
 *     "_createdDate": "2022-11-28T11:57:30.722Z",
 *     "_updatedDate": "2023-01-17T12:04:49.620Z",
 *     "lastActivityDate": "2023-01-17T12:04:49.619Z",
 *     "revision": "2",
 *     "tier": {
 *       "_id": "05e9d924-54c4-4540-94ef-8edd1e303611",
 *       "_updatedDate": "2023-01-17T12:04:49.619Z",
 *       "points": 715
 *     }
 *   }
 * }
 */

```

## Adjust loyalty account balance (export from backend code)

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { accounts } from 'wix-loyalty.v2';

// Sample accountId value: "1ab8f49c-a329-4ddc-a31d-814afbb3b565";

/* Sample options values:
 *  {
 *    balance: 715,
 *    description: "Sync from external program.",
 *    revision: "3"
 *   };
 */

export const myAdjustPointsFunction = webMethod(
  Permissions.Anyone, 
  async (accountId, options) => {
  try {
    const updatedAccount = await accounts.adjustPoints(accountId, options);

    const updatedBalance = updatedAccount.account.points.balance;
    const transactionId = updatedAccount.transaction_id;

    console.log('Success! New account balance is: ', updatedBalance, ' The ID for this transaction is: ', transactionId);  

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

/* Promise resolves to:
 * {
 *   "transaction_id": "da9096b4-a7fe-41a0-bf3b-05c22e3102fb",
 *   "account": {
 *     "_id": "1ab8f49c-a329-4ddc-a31d-814afbb3b565",
 *     "contactId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "memberId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "points": {
 *       "balance": 715,
 *       "earned": 0,
 *       "adjusted": 715,
 *       "redeemed": 0
 *     },
 *     "rewardAvailable": false,
 *     "_createdDate": "2022-11-28T11:57:30.722Z",
 *     "_updatedDate": "2023-01-17T12:04:49.620Z",
 *     "lastActivityDate": "2023-01-17T12:04:49.619Z",
 *     "revision": "2",
 *     "tier": {
 *       "_id": "05e9d924-54c4-4540-94ef-8edd1e303611",
 *       "_updatedDate": "2023-01-17T12:04:49.619Z",
 *       "points": 715
 *     }
 *   }
 * }
 */

```

## Get a loyalty account's latest revision, then give points to the account 

```javascript
import { Permissions, webMethod } from "wix-web-module";
import { accounts } from "wix-loyalty.v2";
import * as wixAuth from "wix-auth";

// Sample accountId value: "1ab8f49c-a329-4ddc-a31d-814afbb3b565".

/* Sample options value:
 * {
 *   "amount": 50,
 *   "description": "Shared on social media."
 * }
 */

export const myGetRevisionAndAdjustPointsFunction = webMethod(
  Permissions.Anyone,
  async (accountId, options) => {
    const elevatedGetLoyaltyAccount = wixAuth.elevate(accounts.getAccount);
    const retrievedLoyaltyAccount = await elevatedGetLoyaltyAccount(accountId);
    const currentRevision = retrievedLoyaltyAccount.account.revision;

    options.revision = currentRevision;

    const elevatedAdjustPoints = wixAuth.elevate(accounts.adjustPoints);

    try {
      const updatedAccount = await elevatedAdjustPoints(accountId, options);

      const updatedBalance = updatedAccount.account.points.balance;
      const transactionId = updatedAccount.transaction_id;

      console.log(
        "Success! New account balance is: ",
        updatedBalance,
        ". This ID for this transaction is: ",
        transactionId
      );

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

/* Promise resolves to:
 * {
 *   "transaction_id": "060e672a-d86b-4761-b587-1e97a34fd2f6",
 *   "account": {
 *     "_id": "1ab8f49c-a329-4ddc-a31d-814afbb3b565",
 *     "contactId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "memberId": "3128dc64-74fc-442f-aa32-e8e871dad141",
 *     "points": {
 *       "balance": 295,
 *       "earned": 45,
 *       "adjusted": 250,
 *       "redeemed": 0
 *     },
 *     "rewardAvailable": true,
 *     "_createdDate": "2022-11-28T11:57:30.722Z",
 *     "_updatedDate": "2023-01-19T12:03:16.946Z",
 *     "lastActivityDate": "2023-01-19T12:03:16.945Z",
 *     "revision": "19",
 *     "tier": {
 *       "_id": "65fdf385-37b9-42e8-81c8-2e5fafe446f0",
 *       "_updatedDate": "2023-01-19T12:03:16.945Z",
 *       "points": 295
 *     }
 *   }
 * }
 */

```

---