> 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 # ExecuteLoyaltyImport # Package: accounts # Namespace: LoyaltyImports # Method link: https://dev.wix.com/docs/api-reference/crm/loyalty-program/accounts/imports/execute-loyalty-import.md ## Permission Scopes: Manage Loyalty: SCOPE.DC-LOYALTY.MANAGE-LOYALTY ## Introduction Starts the actual import process for a loyalty import. Call this method after the loyalty import object reaches the `"PARSED"` status. --- ## REST API ### Schema ``` Method: executeLoyaltyImport Description: Starts the actual import process for a loyalty import. Call this method after the loyalty import object reaches the `"PARSED"` status. URL: https://www.wixapis.com/v1/loyalty-imports/execute Method: POST # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: loyaltyImportId Method parameters: param name: headerMappingInfo | type: HeaderMappingInfo - 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`. param name: loyaltyImportId | type: loyaltyImportId | description: Loyalty import GUID. | required: true Return type: ExecuteLoyaltyImportResponse - name: loyaltyImport | type: LoyaltyImport | description: Executed loyalty import. - 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. ``` ### Examples ### Execute Loyalty import ```curl curl -X POST \ 'https://www.wixapis.com/_api/loyalty-imports/v1/loyalty-imports/execute' \ -H 'Authorization: ' \ -H 'Content-Type: application/json' \ -d '{ "loyaltyImportId": "5cc0b472-e488-4de3-92ba-bd718a44933a", "headerMappingInfo": { "headerMappings": [ { "columnName": "EMAIL", "columnIndex": 2 }, { "columnName": "POINTS", "columnIndex": 3 } ] } }' ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.accounts.LoyaltyImports.executeLoyaltyImport(loyaltyImportId, options) Description: Starts the actual import process for a loyalty import. Call this method after the loyalty import object reaches the `"PARSED"` status. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: loyaltyImportId Method parameters: param name: loyaltyImportId | type: string | description: Loyalty import GUID. | required: true param name: options | type: ExecuteLoyaltyImportOptions none - name: headerMappingInfo | type: HeaderMappingInfo | description: Header mapping information for the import file. - 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`. Return type: PROMISE - name: loyaltyImport | type: LoyaltyImport | description: Executed loyalty import. - 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. ``` ### Examples ### executeLoyaltyImport ```javascript import { imports } from '@wix/loyalty'; async function executeLoyaltyImport(loyaltyImportId,options) { const response = await imports.executeLoyaltyImport(loyaltyImportId,options); }; ``` ### executeLoyaltyImport (with elevated permissions) ```javascript import { imports } from '@wix/loyalty'; import { auth } from '@wix/essentials'; async function myExecuteLoyaltyImportMethod(loyaltyImportId,options) { const elevatedExecuteLoyaltyImport = auth.elevate(imports.executeLoyaltyImport); const response = await elevatedExecuteLoyaltyImport(loyaltyImportId,options); } ``` ### executeLoyaltyImport (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 executeLoyaltyImport(loyaltyImportId,options) { const response = await myWixClient.imports.executeLoyaltyImport(loyaltyImportId,options); }; ``` ---