> 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

# QueryLoyaltyImports

# Package: accounts

# Namespace: LoyaltyImports

# Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/accounts/imports/query-loyalty-imports.md

## Permission Scopes:
Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY

## Introduction

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

Query Loyalty Imports runs with these defaults, which you can override:

- `"createdDate"` is sorted in `"DESC"` order.
- `"paging.limit"` is `50`.

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: queryLoyaltyImports
 Description: Retrieves a list of loyalty imports with the specified paging, filtering, and sorting.  Query Loyalty Imports runs with these defaults, which you can override:  - `"createdDate"` is sorted in `"DESC"` order. - `"paging.limit"` is `50`.  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/_api/loyalty-imports/v1/loyalty-imports/query
 Method: POST
 # 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: CursorQuery   | 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.  | validation: format double
              - name: longitude | type: number | description: Address longitude.  | validation: format double
 Query fields:
   - field: createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: QueryLoyaltyImportsResponse
  - name: loyaltyImports | type: array<LoyaltyImport> | description: List of loyalty imports matching the query.  
     - name: id | type: string | description: The GUID of the import.  | read-only: true | validation: format GUID
     - name: asyncImportJobId | type: string | description: GUID of the asynchronous import job associated with this import.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty import is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty import.  Ignored when creating a loyalty import.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the loyalty import was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the loyalty import was last updated.  | read-only: true | validation: format date-time
     - name: status | type: ImportStatus | description: Current status of the import process.  | read-only: true 
         - enum:
         -     UNKNOWN: Status is unknown or not specified.
         -     INITIATED: The import has initiated but processing hasn't started yet.
         -     PARSING: The system is currently parsing the import file.
         -     PARSED: The import file has been successfully parsed and is ready to import.
         -     IMPORTING: The system is currently importing the parsed data.
         -     IMPORTED: The import process is complete. This status indicates the process finished, but doesn't guarantee all data imported successfully.
         -     FAILED: The import process has failed.
     - name: fileMetadata | type: FileMetadata | description: Metadata of the uploaded file containing loyalty points data.  
        - name: size | type: integer | description: Size of the uploaded file in bytes. Max: `10 MB`.  | read-only: true | validation: maximum 104857600, format int32
        - name: name | type: string | description: Name of the uploaded file.  | read-only: true | validation: format GUID
        - name: url | type: string | description: URL of the uploaded file.  | validation: minLength 3, maxLength 10000
        - name: header | type: FileHeader | description: Column headings from the first row of the uploaded CSV file.  
           - name: values | type: array<string> | description: Column headings from the first row of the uploaded file.  | validation: maxItems 100, maxLength 1000
        - name: headerMappingInfo | type: HeaderMappingInfo | description: Mapping between loyalty data fields and the corresponding columns in the uploaded file.  Must include mappings for both `EMAIL` and `POINTS` to be valid.  
           - name: headerMappings | type: array<HeaderMapping> | description: Mappings between required loyalty data fields and file columns. Must contain exactly 2 mappings: one for `"EMAIL"` and one for `"POINTS"`.  | validation: minItems 2, maxItems 2
              - name: columnName | type: ColumnName | description: The required loyalty data field that this mapping corresponds to. Must be either `"EMAIL"` or `"POINTS"`.  
                     - enum:
                     -     EMAIL: Column containing the customer's email address.
                     -     POINTS: Column containing the customer's loyalty point balance to be imported or updated.
              - name: columnIndex | type: integer | description: The zero-based index of the column in the uploaded file that contains the data for this loyalty field. For example, if the email addresses are in the second column of the CSV file, this value would be `1`.  
        - name: sampleDataRows | type: array<SampleDataRow> | description: Up to 5 sample rows from the import file, providing a preview of the data to be imported.  | validation: maxItems 5
           - name: values | type: array<string> | description: Values in one sample data row. Each value corresponds to a column in the CSV file. The number of values matches the number of columns in the file.  | validation: maxItems 20, maxLength 1000
     - name: parseResult | type: ParseResult | description: Results of parsing the uploaded file, including the number of rows parsed and any parse errors.  
        - name: parsedRowCount | type: integer | description: Number of rows parsed from the uploaded import file.  | read-only: true | validation: format int32
        - name: parseErrorReason | type: string | description: Reason code explaining why parsing failed, if applicable.  | read-only: true | validation: maxLength 1000
     - name: importResult | type: ImportResult | description: Results of the import process, including success and failure counts.  
        - name: errorFileExists | type: boolean | description: Whether an error file detailing import failures is available for download. The file includes row-by-row import status, error reasons, and original data.  
        - name: successCount | type: integer | description: Number of rows successfully imported.  | read-only: true | validation: format int32
        - name: failureCount | type: integer | description: Number of rows that failed to import due to errors.  | read-only: true | validation: format int32
  - 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 imports
```curl
curl -X POST \
  'https://www.wixapis.com/_api/loyalty-imports/v1/loyalty-imports/query' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  -d '{
        "query": {}
    }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.loyalty.imports.queryLoyaltyImports(query)
 Description: Retrieves a list of loyalty imports with the specified paging, filtering, and sorting.  Query Loyalty Imports runs with these defaults, which you can override:  - `"createdDate"` is sorted in `"DESC"` order. - `"paging.limit"` is `50`.  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: LoyaltyImportQuery   | 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: _createdDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: _updatedDate | operators: $eq, $ne, $in, $exists, $gt, $gte, $lt, $lte | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
   - field: status | operators: $eq, $ne, $in, $exists | sort: ASC, DESC | aggregatable: undefined | searchable: undefined
 Return type: PROMISE<QueryLoyaltyImportsResponse>
  - name: loyaltyImports | type: array<LoyaltyImport> | description: List of loyalty imports matching the query.  
     - name: _id | type: string | description: The GUID of the import.  | read-only: true | validation: format GUID
     - name: asyncImportJobId | type: string | description: GUID of the asynchronous import job associated with this import.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the loyalty import is updated. To prevent conflicting changes, the current `revision` must be passed when updating the loyalty import.  Ignored when creating a loyalty import.  | read-only: true | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the loyalty import was created.  | read-only: true 
     - name: _updatedDate | type: Date | description: Date and time the loyalty import was last updated.  | read-only: true 
     - name: status | type: ImportStatus | description: Current status of the import process.  | read-only: true 
         - enum:
         -     UNKNOWN: Status is unknown or not specified.
         -     INITIATED: The import has initiated but processing hasn't started yet.
         -     PARSING: The system is currently parsing the import file.
         -     PARSED: The import file has been successfully parsed and is ready to import.
         -     IMPORTING: The system is currently importing the parsed data.
         -     IMPORTED: The import process is complete. This status indicates the process finished, but doesn't guarantee all data imported successfully.
         -     FAILED: The import process has failed.
     - name: fileMetadata | type: FileMetadata | description: Metadata of the uploaded file containing loyalty points data.  
        - name: size | type: integer | description: Size of the uploaded file in bytes. Max: `10 MB`.  | read-only: true | validation: maximum 104857600, format int32
        - name: name | type: string | description: Name of the uploaded file.  | read-only: true | validation: format GUID
        - name: url | type: string | description: URL of the uploaded file.  | validation: minLength 3, maxLength 10000
        - name: header | type: FileHeader | description: Column headings from the first row of the uploaded CSV file.  
           - name: values | type: array<string> | description: Column headings from the first row of the uploaded file.  | validation: maxItems 100, maxLength 1000
        - name: headerMappingInfo | type: HeaderMappingInfo | description: Mapping between loyalty data fields and the corresponding columns in the uploaded file.  Must include mappings for both `EMAIL` and `POINTS` to be valid.  
           - name: headerMappings | type: array<HeaderMapping> | description: Mappings between required loyalty data fields and file columns. Must contain exactly 2 mappings: one for `"EMAIL"` and one for `"POINTS"`.  | validation: minItems 2, maxItems 2
              - name: columnName | type: ColumnName | description: The required loyalty data field that this mapping corresponds to. Must be either `"EMAIL"` or `"POINTS"`.  
                     - enum:
                     -     EMAIL: Column containing the customer's email address.
                     -     POINTS: Column containing the customer's loyalty point balance to be imported or updated.
              - name: columnIndex | type: integer | description: The zero-based index of the column in the uploaded file that contains the data for this loyalty field. For example, if the email addresses are in the second column of the CSV file, this value would be `1`.  
        - name: sampleDataRows | type: array<SampleDataRow> | description: Up to 5 sample rows from the import file, providing a preview of the data to be imported.  | validation: maxItems 5
           - name: values | type: array<string> | description: Values in one sample data row. Each value corresponds to a column in the CSV file. The number of values matches the number of columns in the file.  | validation: maxItems 20, maxLength 1000
     - name: parseResult | type: ParseResult | description: Results of parsing the uploaded file, including the number of rows parsed and any parse errors.  
        - name: parsedRowCount | type: integer | description: Number of rows parsed from the uploaded import file.  | read-only: true | validation: format int32
        - name: parseErrorReason | type: string | description: Reason code explaining why parsing failed, if applicable.  | read-only: true | validation: maxLength 1000
     - name: importResult | type: ImportResult | description: Results of the import process, including success and failure counts.  
        - name: errorFileExists | type: boolean | description: Whether an error file detailing import failures is available for download. The file includes row-by-row import status, error reasons, and original data.  
        - name: successCount | type: integer | description: Number of rows successfully imported.  | read-only: true | validation: format int32
        - name: failureCount | type: integer | description: Number of rows that failed to import due to errors.  | read-only: true | validation: format int32
  - 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

### queryLoyaltyImports
```javascript
import { imports } from '@wix/loyalty';

async function queryLoyaltyImports(query) {
  const response = await imports.queryLoyaltyImports(query);
};
```

### queryLoyaltyImports (with elevated permissions)
```javascript
import { imports } from '@wix/loyalty';
import { auth } from '@wix/essentials';

async function myQueryLoyaltyImportsMethod(query) {
  const elevatedQueryLoyaltyImports = auth.elevate(imports.queryLoyaltyImports);
  const response = await elevatedQueryLoyaltyImports(query);
}
```

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

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


async function queryLoyaltyImports(query) {
  const response = await myWixClient.imports.queryLoyaltyImports(query);
};
```

---