> 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

# QueryLoyaltyTransactions

# Package: accounts

# Namespace: LoyaltyTransactions

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

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

## Introduction

Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting.

To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md),
[Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md),
and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).

---

## REST API

### Schema

```
 Method: queryLoyaltyTransactions
 Description: Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting.  To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).
 URL: https://www.wixapis.com/loyalty-transactions/v1/loyalty-transactions/query
 Method: POST
 Method parameters:
   param name: query | type: CursorQuery    
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
 Query fields:
   - field: id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: idempotencyKey | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: transactionType | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: amount | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: description | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryLoyaltyTransactionsResponse
  - name: loyaltyTransactions | type: array<LoyaltyTransaction> | description: Retrieved loyalty transactions.  
     - ONE-OF: 
        - name: earnInfo | type: EarnInfo | description: Information on points earned.  
           - ONE-OF: 
              - name: followedSocialMedia | type: FollowedSocialMedia | description: Details on following on social media.  
                 - name: channel | type: string | description: Social media channel. For example, `"FACEBOOK"` or `"INSTAGRAM"`.  | validation: maxLength 32
           - name: appId | type: string | description: GUID of the app that generated the earned points.  | read-only: true | validation: minLength 1
           - name: activityType | type: string | description: Activity type.  
           - name: orderId | type: string | description: Order GUID.  | validation: maxLength 512
           - name: limitApplied | type: boolean | description: Whether the points amount was adjusted by an earn points limit provider.  | read-only: true 
        - name: redeemInfo | type: RedeemInfo | description: Information on points redeemed.  
           - name: rewardId | type: string | description: GUID of the reward that was redeemed.  | read-only: true | validation: format GUID
           - name: rewardType | type: string | description: Type of reward that was redeemed.  | read-only: true 
           - name: referenceEntityId | type: string | description: GUID of the specific item that was redeemed in this transaction.  Each reward that's redeemed has a unique `referenceEntityId`.  | read-only: true | validation: format GUID
        - name: adjustInfo | type: AdjustInfo | description: Information on points adjusted.  
           - name: appId | type: string | description: GUID of the app that initiated the points adjustment.  | read-only: true | validation: minLength 1
           - name: amountBefore | type: integer | description: Amount before adjustment.  
           - name: amountAfter | type: integer | description: Amount after adjustment.  
        - name: refundInfo | type: RefundInfo | description: Information on points refunded.  
           - name: appId | type: string | description: GUID of the app that refunded points.  | read-only: true | validation: minLength 1
           - name: refundedTransactionId | type: string | description: GUID of the transaction that was refunded.  | read-only: true | validation: format GUID
        - name: expireInfo | type: ExpireInfo | description: Information on points expired.  
           - name: amountBefore | type: integer | description: Amount before expiration.  
           - name: amountAfter | type: integer | description: Amount after expiration.  
        - name: earnAttemptInfo | type: EarnAttemptInfo | description: Information on a limited earn attempt recorded with 0 points.  
           - name: appId | type: string | description: GUID of the app that generated the earn operation.  | read-only: true | validation: minLength 1
           - name: activityType | type: string | description: Activity type.  
           - name: orderId | type: string | description: Order GUID.  | validation: maxLength 512
     - name: id | type: string | description: Transaction GUID.  | validation: format GUID
     - name: accountId | type: string | description: Account GUID.  | validation: format GUID
     - name: createdDate | type: string | description: Date and time the transaction was created.  | read-only: true | validation: format date-time
     - name: amount | type: integer | description: The number of points earned, adjusted, redeemed, or expired in the transaction.  + `EARN`: Number of points earned by a customer taking an action. + `REDEEM`: The number of points redeemed by a customer for a reward. + `ADJUST`: The number of points adjusted to a customer's balance. + `REFUND`: The number of points refunded for a previously redeemed reward. + `EXPIRE`: The number of points that expired due to customer inactivity for a configured period.  
     - name: transactionType | type: TransactionType | description: Type of transaction.  
         - enum:
         -     UNKNOWN: Unknown transaction type.
         -     EARN: Number of points earned by a customer taking an action. See [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md).
         -     REDEEM: Number of points redeemed by a customer for a reward.
         -     ADJUST: Number of points adjusted to a customer's balance. See [Adjust Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/adjust-points.md).
         -     REFUND: Number of points refunded for a previously redeemed reward.
         -     EXPIRE: Number of points that expired due to customer inactivity for a configured period.
         -     EARN_ATTEMPT: Record of an earn attempt that was limited to 0 points.
     - name: description | type: string | description: Transaction description.  | validation: maxLength 100
     - name: idempotencyKey | type: string | description: Unique identifier, generated by the client. Used to recognize repeated attempts of the same request. Only present when manually adding points with [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md).  | validation: maxLength 128
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query loyalty transactions
```curl
curl -X POST \
  'https://www.wixapis.com/loyalty-transactions/v1/loyalty-transactions/query' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  --data-binary '{
                   "query": {
                     "filter": {
                       "transactionType": {
                         "$eq": "EARN"
                       }
                     }
                   }
                 }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.transactions.queryLoyaltyTransactions(query)
 Description: Retrieves a list of loyalty transactions with the specified paging, filtering, and sorting.  To learn about working with _Query_ methods, see [API Query Language](https://dev.wix.com/docs/rest/articles/get-started/api-query-language.md), [Sorting and Paging](https://dev.wix.com/docs/rest/articles/get-started/sorting-and-paging.md), and [Field Projection](https://dev.wix.com/docs/rest/articles/get-started/field-projection.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  query
 Method parameters: 
   param name: query | type: LoyaltyTransactionQuery   | required: true 
     - name: cursorPaging | type: CursorPaging | description: Cursor paging options.  Learn more about [cursor paging](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#cursor-paging).  
        - name: limit | type: integer | description: Maximum number of items to return in the results.  | validation: minimum 0, maximum 100, format int32
        - name: cursor | type: string | description: Pointer to the next or previous page in the list of results.  Pass the relevant cursor token from the `pagingMetadata` object in the previous call's response. Not relevant for the first request.  | validation: maxLength 16000
        - name: filter | type: object | description: Filter object.  Learn more about [filtering](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#filters).  
        - name: sort | type: array<Sorting> | description: Sort object.  Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting).  | validation: maxItems 5
           - name: fieldName | type: string | description: Name of the field to sort by.  | validation: maxLength 512
           - name: order | type: SortOrder | description: Sort order.  
                 - enum: ASC, DESC
           - name: origin | type: AddressLocation | description: Origin point for geo-distance sorting on a GEO field results are ordered by distance from this point (ASC = nearest first, DESC = farthest first).  
              - name: latitude | type: number | description: Address latitude.  
              - name: longitude | type: number | description: Address longitude.  
 Query fields:
   - field: _id | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: accountId | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: idempotencyKey | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: transactionType | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: amount | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: description | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte, $startsWith | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryLoyaltyTransactionsResponse>
  - name: loyaltyTransactions | type: array<LoyaltyTransaction> | description: Retrieved loyalty transactions.  
     - ONE-OF: 
        - name: earnInfo | type: EarnInfo | description: Information on points earned.  
           - ONE-OF: 
              - name: followedSocialMedia | type: FollowedSocialMedia | description: Details on following on social media.  
                 - name: channel | type: string | description: Social media channel. For example, `"FACEBOOK"` or `"INSTAGRAM"`.  | validation: maxLength 32
           - name: appId | type: string | description: GUID of the app that generated the earned points.  | read-only: true | validation: minLength 1
           - name: activityType | type: string | description: Activity type.  
           - name: orderId | type: string | description: Order GUID.  | validation: maxLength 512
           - name: limitApplied | type: boolean | description: Whether the points amount was adjusted by an earn points limit provider.  | read-only: true 
        - name: redeemInfo | type: RedeemInfo | description: Information on points redeemed.  
           - name: rewardId | type: string | description: GUID of the reward that was redeemed.  | read-only: true | validation: format GUID
           - name: rewardType | type: string | description: Type of reward that was redeemed.  | read-only: true 
           - name: referenceEntityId | type: string | description: GUID of the specific item that was redeemed in this transaction.  Each reward that's redeemed has a unique `referenceEntityId`.  | read-only: true | validation: format GUID
        - name: adjustInfo | type: AdjustInfo | description: Information on points adjusted.  
           - name: appId | type: string | description: GUID of the app that initiated the points adjustment.  | read-only: true | validation: minLength 1
           - name: amountBefore | type: integer | description: Amount before adjustment.  
           - name: amountAfter | type: integer | description: Amount after adjustment.  
        - name: refundInfo | type: RefundInfo | description: Information on points refunded.  
           - name: appId | type: string | description: GUID of the app that refunded points.  | read-only: true | validation: minLength 1
           - name: refundedTransactionId | type: string | description: GUID of the transaction that was refunded.  | read-only: true | validation: format GUID
        - name: expireInfo | type: ExpireInfo | description: Information on points expired.  
           - name: amountBefore | type: integer | description: Amount before expiration.  
           - name: amountAfter | type: integer | description: Amount after expiration.  
        - name: earnAttemptInfo | type: EarnAttemptInfo | description: Information on a limited earn attempt recorded with 0 points.  
           - name: appId | type: string | description: GUID of the app that generated the earn operation.  | read-only: true | validation: minLength 1
           - name: activityType | type: string | description: Activity type.  
           - name: orderId | type: string | description: Order GUID.  | validation: maxLength 512
     - name: _id | type: string | description: Transaction GUID.  | validation: format GUID
     - name: accountId | type: string | description: Account GUID.  | validation: format GUID
     - name: _createdDate | type: Date | description: Date and time the transaction was created.  | read-only: true 
     - name: amount | type: integer | description: The number of points earned, adjusted, redeemed, or expired in the transaction.  + `EARN`: Number of points earned by a customer taking an action. + `REDEEM`: The number of points redeemed by a customer for a reward. + `ADJUST`: The number of points adjusted to a customer's balance. + `REFUND`: The number of points refunded for a previously redeemed reward. + `EXPIRE`: The number of points that expired due to customer inactivity for a configured period.  
     - name: transactionType | type: TransactionType | description: Type of transaction.  
         - enum:
         -     UNKNOWN: Unknown transaction type.
         -     EARN: Number of points earned by a customer taking an action. See [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md).
         -     REDEEM: Number of points redeemed by a customer for a reward.
         -     ADJUST: Number of points adjusted to a customer's balance. See [Adjust Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/adjust-points.md).
         -     REFUND: Number of points refunded for a previously redeemed reward.
         -     EXPIRE: Number of points that expired due to customer inactivity for a configured period.
         -     EARN_ATTEMPT: Record of an earn attempt that was limited to 0 points.
     - name: description | type: string | description: Transaction description.  | validation: maxLength 100
     - name: idempotencyKey | type: string | description: Unique identifier, generated by the client. Used to recognize repeated attempts of the same request. Only present when manually adding points with [Earn Points](https://dev.wix.com/docs/rest/crm/loyalty-program/accounts/earn-points.md).  | validation: maxLength 128
  - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata.  
     - name: count | type: integer | description: Number of items returned in current page.  | validation: format int32
     - name: cursors | type: Cursors | description: Cursor strings that point to the next page, previous page, or both.  
        - name: next | type: string | description: Cursor string pointing to the next page in the list of results.  | validation: maxLength 16000
        - name: prev | type: string | description: Cursor pointing to the previous page in the list of results.  | validation: maxLength 16000
     - name: hasNext | type: boolean | description: Whether there are more pages to retrieve following the current page.  + `true`: Another page of results can be retrieved. + `false`: This is the last page.  


```

### Examples

### Query loyalty transaction (with elevated permissions)
```javascript
import { transactions } from "@wix/loyalty";
import { auth } from "@wix/essentials";

const elevatedQueryLoyaltyTransactions = auth.elevate(transactions.queryLoyaltyTransactions);

async function queryLoyaltyTransactions() {
  const { items } = await elevatedQueryLoyaltyTransactions().find();
}

/* Promise resolves to:
 *
 * {
 *     "_createdDate": "2024-06-10T14:55:26.916Z",
 *     "_id": "1d0d1159-f578-4f37-98df-f988fa728ff9",
 *     "accountId": "ec8a038b-aefb-4bed-bd15-635906cc6a60",
 *     "transactionType": "ADJUST",
 *     "amount": -70,
 *     "description": "",
 *     "idempotencyKey": "1d0d1159-f578-4f37-98df-f988fa728ff9",
 *     "adjustInfo": {
 *     "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
 *     "amountBefore": 70,
 *     "amountAfter": 0
 *     }
 * },
 * {
 *     "_createdDate": "2024-06-10T15:27:31.073Z",
 *     "_id": "318563e8-ebca-4531-b284-27cec8807b5e",
 *     "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *     "transactionType": "ADJUST",
 *     "amount": 50,
 *     "description": "",
 *     "idempotencyKey": "318563e8-ebca-4531-b284-27cec8807b5e",
 *     "adjustInfo": {
 *     "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
 *     "amountBefore": 0,
 *     "amountAfter": 50
 *     }
 * }
 */
```

### Query loyalty transaction
```javascript
import { transactions } from "@wix/loyalty";

async function queryLoyaltyTransactions() {
  const { items } = await transactions.queryLoyaltyTransactions().find();
}

/* Promise resolves to:
 *
 * {
 *     "_createdDate": "2024-06-10T14:55:26.916Z",
 *     "_id": "1d0d1159-f578-4f37-98df-f988fa728ff9",
 *     "accountId": "ec8a038b-aefb-4bed-bd15-635906cc6a60",
 *     "transactionType": "ADJUST",
 *     "amount": -70,
 *     "description": "",
 *     "idempotencyKey": "1d0d1159-f578-4f37-98df-f988fa728ff9",
 *     "adjustInfo": {
 *     "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
 *     "amountBefore": 70,
 *     "amountAfter": 0
 *     }
 * },
 * {
 *     "_createdDate": "2024-06-10T15:27:31.073Z",
 *     "_id": "318563e8-ebca-4531-b284-27cec8807b5e",
 *     "accountId": "d0dc5ba3-4a10-4cfc-b304-c976d8ac7303",
 *     "transactionType": "ADJUST",
 *     "amount": 50,
 *     "description": "",
 *     "idempotencyKey": "318563e8-ebca-4531-b284-27cec8807b5e",
 *     "adjustInfo": {
 *     "appId": "553c79f3-5625-4f38-b14b-ef7c0d1e87df",
 *     "amountBefore": 0,
 *     "amountAfter": 50
 *     }
 * }
 */
```

### queryLoyaltyTransactions (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 { transactions } from '@wix/loyalty';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { transactions },
  // Include the auth strategy and host as relevant
});


async function queryLoyaltyTransactions(query) {
  const response = await myWixClient.transactions.queryLoyaltyTransactions(query);
};
```

---