Import a batch file
Feature availability is part of a phased rollout. Your organization may not see this functionality yet. It will become available when your environment is included in the rollout.
In this walkthrough, you upload a JSONL file to the Profile Import API, track it through to completion, and view the results.
This walkthrough describes how to:
- Create an API key
- Prepare your JSONL file
- Compute the MD5 checksum
- Upload the file
- Monitor the batch
- View the results
- You have a JSONL file ready to upload. See batch file format for formatting requirements.
- No other batch is currently
QUEUEDorRUNNINGfor your environment. Only one batch can be active at a time.
Create an API key
In production environments, you must authenticate using a static API key. You can create API keys from the Profile import page in SitecoreAI settings.
In production environments, only Organization Owners and Organization Admins can create API keys. In non-production environments, all users can create API keys.
To create an API key:
-
In SitecoreAI, click Performance > Settings > Profile import.
-
Click the Credentials tab, and then click Create credential.
-
Enter a name for the credential and an optional description.
-
If you want the API key to expire after a year, then select Credential expires in 1 year. If you don't select this option, the API key does not expire.
-
Click Create, then copy the API key. The key is displayed only one time and cannot be retrieved after you close the dialog.
Copy the API key before closing the dialog. You cannot retrieve it again after it disappears. If you lose it, you must create a new credential.
Prepare your JSONL file
Your input file must be UTF-8 encoded JSON Lines (JSONL) format, with one JSON object per line. Each line is an independent record that corresponds to a profile payload.
For full formatting requirements, including the required identifiers structure and supported fields, see batch file format.
Keep file sizes under 100 MB. If your data set exceeds this limit, split it into multiple files and upload them one at a time, waiting for each batch to complete before starting the next.
Compute the MD5 checksum of the JSONL file
The API requires an MD5 checksum of your JSONL file to verify integrity during upload. Use one of the following methods to compute the MD5 hash before uploading:
The command outputs a 32-character hex string such as 01556b1dcc2b3cb87889838ee349357a. Copy this value. You pass it as the md5 form field when you upload through the API.
Upload the file
In non-production environments, you can upload the file through the Profile import page, but in production environments, you must use the API.
Use a POST request with multipart/form-data to upload your file through the Profile Import API. Replace {base_url} with your API endpoint. You can find this on the Credentials tab of the Profile import page. Include your API key in the Authorization header.
A successful upload returns 202 Accepted with a batchId you use to track the batch:
Save the batchId. You'll use it to check status and download results.
If you receive a 429 Too Many Requests error, a batch is already queued or running for your environment. Wait for it to finish before uploading a new file.
For a full list of error responses, see the Profile Import API.
Upload through the Profile import page (non-production only)
To upload a file through the SitecoreAI UI:
-
In SitecoreAI, click Performance > Settings > Profile import.
-
In the Uploads tab, click Upload batch.
-
Select your JSONL file and click Upload.
After the upload completes, the batch appears in the Uploads tab where you can monitor its progress.
Monitor the batch
You can monitor the batch from the Profile import page, or poll the status endpoint using the batchId:
The response includes the current status and record counts:
For a description of each state and retry behavior, see batch states.
View the results
After the batch reaches a final state (COMPLETED, COMPLETED_WITH_ERRORS, or FAILED), you can view the results in the Profile import page or use the stats endpoint to get a high-level overview of the import:
The response includes a summary of the import:
You can also download the results to see the outcome for each record.
You have now successfully imported a batch file. You prepared a JSONL file, computed its MD5 checksum, uploaded it using the API, monitored processing, and retrieved the results.