> 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 # 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/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. - 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. - 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 | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: QueryLoyaltyImportsResponse - name: loyaltyImports | type: array | description: List of loyalty imports matching the query. - name: id | type: string | description: The GUID of the import. - name: asyncImportJobId | type: string | description: GUID of the asynchronous import job associated with this import. - 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. - name: createdDate | type: string | description: Date and time the loyalty import was created. - name: updatedDate | type: string | description: Date and time the loyalty import was last updated. - name: status | type: ImportStatus | description: Current status of the import process. - 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`. - name: name | type: string | description: Name of the uploaded file. - name: url | type: string | description: URL of the uploaded file. - name: header | type: FileHeader | description: Column headings from the first row of the uploaded CSV file. - name: values | type: array | description: Column headings from the first row of the uploaded file. - 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 | description: Mappings between required loyalty data fields and file columns. Must contain exactly 2 mappings: one for `"EMAIL"` and one for `"POINTS"`. - 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 | description: Up to 5 sample rows from the import file, providing a preview of the data to be imported. - name: values | type: array | 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. - 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. - name: parseErrorReason | type: string | description: Reason code explaining why parsing failed, if applicable. - 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. - name: failureCount | type: integer | description: Number of rows that failed to import due to errors. - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in current page. - 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. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. - 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: ' \ -H 'Content-Type: application/json' \ -d '{ "query": {} }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.accounts.LoyaltyImports.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. - 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. - 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 | description: Sort object. Learn more about [sorting](https://dev.wix.com/docs/rest/articles/getting-started/api-query-language.md#sorting). - name: fieldName | type: string | description: Name of the field to sort by. - name: order | type: SortOrder | description: Sort order. - enum: ASC, DESC Return type: PROMISE - name: loyaltyImports | type: array | description: List of loyalty imports matching the query. - name: _id | type: string | description: The GUID of the import. - name: asyncImportJobId | type: string | description: GUID of the asynchronous import job associated with this import. - 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. - name: _createdDate | type: Date | description: Date and time the loyalty import was created. - name: _updatedDate | type: Date | description: Date and time the loyalty import was last updated. - name: status | type: ImportStatus | description: Current status of the import process. - 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`. - name: name | type: string | description: Name of the uploaded file. - name: url | type: string | description: URL of the uploaded file. - name: header | type: FileHeader | description: Column headings from the first row of the uploaded CSV file. - name: values | type: array | description: Column headings from the first row of the uploaded file. - 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 | description: Mappings between required loyalty data fields and file columns. Must contain exactly 2 mappings: one for `"EMAIL"` and one for `"POINTS"`. - 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 | description: Up to 5 sample rows from the import file, providing a preview of the data to be imported. - name: values | type: array | 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. - 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. - name: parseErrorReason | type: string | description: Reason code explaining why parsing failed, if applicable. - 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. - name: failureCount | type: integer | description: Number of rows that failed to import due to errors. - name: pagingMetadata | type: CursorPagingMetadata | description: Paging metadata. - name: count | type: integer | description: Number of items returned in current page. - 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. - name: prev | type: string | description: Cursor pointing to the previous page in the list of results. - 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-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 { 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); }; ``` ---