---
title: "Import a batch file"
slug: "import-a-batch-file"
abstract: "Upload a JSONL batch file to the Profile Import API, monitor its progress, and view the results."
---

# Import a batch file

> [!important]
> 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:

:::walkthrough

- [Create an API key](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#create-an-api-key)
- [Prepare your JSONL file](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#prepare-your-jsonl-file)
- [Compute the MD5 checksum](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#compute-the-md5-checksum-of-the-jsonl-file)
- [Upload the file](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#upload-the-file)
- [Monitor the batch](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#monitor-the-batch)
- [View the results](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#view-the-results)

:::

> [!notice]
> **Before you begin**
>
> - You have a JSONL file ready to upload. See [batch file format](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/batch-file-format.html) for formatting requirements.
> - No other batch is currently `QUEUED` or `RUNNING` for 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.

> [!note]
> 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:

1. In SitecoreAI, click **Performance** > **Settings** > **Profile import**.

2. Click the **Credentials** tab, and then click **Create credential**.

3. Enter a name for the credential and an optional description.

4. 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.

5. Click **Create**, then copy the API key. The key is displayed only one time and cannot be retrieved after you close the dialog.

> [!warning]
> 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.

```jsonl
{"recordType":"profile","identifiers":[{"provider":"email","id":"alice1@example.com"}],"contact":{"firstName":"Alice1","lastName":"Smith2"}, "extensions":{"where": "In the wonderland"}}
{"recordType":"profile","identifiers":[{"provider":"email","id":"alice2@example.com"}],"contact":{"firstName":"Alice2","lastName":"Smith2"}, "extensions":{"where": "In the wonderland1"}}
{"recordType":"profile","identifiers":[{"provider":"email","id":"alice3@example.com"}],"contact":{"firstName":"Alice3","lastName":"Smith2"}, "extensions":{"where": "In the wonderland2"}}
{"recordType":"profile","identifiers":[{"provider":"email","id":"alice4@example.com"}],"contact":{"firstName":"Alice4","lastName":"Smith2"}, "extensions":{"where": "In the wonderland3"}}
{"recordType":"profile","identifiers":[{"provider":"email","id":"alice5@example.com"}],"contact":{"firstName":"Alice5","lastName":"Smith2"}, "extensions":{"where": "In the wonderland4"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0042"},{"provider":"email","id":"bob@example.com"}],"contact":{"firstName":"Bob","lastName":"Jones"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
{"recordType":"profile","identifiers":[{"provider":"userid","id":"crm-0044"}],"contact":{"firstName":"James","lastName":"Red"}}
```

For full formatting requirements, including the required `identifiers` structure and supported fields, see [batch file format](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/batch-file-format.html).

> [!tip]
> 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:

::::tabs
:::tab{title="Linux"}

```bash
md5sum guests.jsonl | awk '{print $1}'
```

:::

:::tab{title="macOS"}

```bash
md5 -q guests.jsonl
```

:::

:::tab{title="Windows (PowerShell)"}

```powershell
(Get-FileHash guests.jsonl -Algorithm MD5).Hash.ToLower()
```

:::

:::tab{title="Windows (CMD)"}

```cmd
certutil -hashfile guests.jsonl MD5
```

:::
::::

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](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#upload-the-file).

## Upload the file

> [!note]
> In non-production environments, you can upload the file through the [Profile import page](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/import-a-batch-file.html#upload-through-the-profile-import-page-non-production-only), 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.

```bash
curl -X POST "{base_url}/v1/batches" \
  -H "Authorization: ApiKey <your-api-key>" \
  -F "file=@guests.jsonl" \
  -F "md5=01556b1dcc2b3cb87889838ee349357a"
```

A successful upload returns `202 Accepted` with a `batchId` you use to track the batch:

```json
{
    "batchId": "7266232b-a7d4-496c-b0b3-be8dbde7495a",
    "status": "QUEUED",
    "checksumMd5": "01556b1dcc2b3cb87889838ee349357a",
    "fileSizeBytes": 1873,
    "createdAt": "2026-07-02T13:14:36.546433Z"
}
```

Save the `batchId`. You'll use it to check status and download results.

> [!note]
> 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](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/profile-import-api.html#upload-a-profile-batch-file).

### Delete profiles

To permanently delete profiles instead of creating or updating them, add the `operationType` form part with a value of `DELETE`. Each record in the file must use `"recordType": "PROFILE_DELETION"` and an `identifiers` array. For the record format, including identifier requirements, see [Deletion records](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/batch-file-format.html#deletion-records).

```bash
curl -X POST "{base_url}/v1/batches" \
  -H "Authorization: ApiKey <your-api-key>" \
  -F "file=@guests-to-delete.jsonl" \
  -F "md5=01556b1dcc2b3cb87889838ee349357a" \
  -F "operationType=DELETE"
```

> [!warning]
> Deletion is permanent and can't be undone. Submitting a deletion batch requires the same API key permissions as importing profiles, so make sure to control access to your API keys carefully.

The batch follows the same upload, monitoring, and results process as an import batch. To confirm a batch was processed as a deletion, check `deletedRecords` and `notFoundRecords` in the [batch statistics](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/profile-import-api.html#get-batch-statistics).

### Upload through the Profile import page (non-production only)

To upload a file through the SitecoreAI UI:

1. In SitecoreAI, click **Performance** > **Settings** > **Profile import**.

2. In the **Uploads** tab, click **Upload batch**.

3. 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`:

```bash
curl "{base_url}/v1/batches/{batchId}/status" \
  -H "Authorization: ApiKey <your-api-key>"
```

The response includes the current status and record counts:

```json
{
    "batchId": "7266232b-a7d4-496c-b0b3-be8dbde7495a",
    "status": "COMPLETED_WITH_ERRORS",
    "totalRecords": 12,
    "succeededRecords": 6,
    "failedRecords": 6,
    "processingTimeSeconds": 64,
    "startedProcessingAt": "2026-07-02T13:14:39.064400Z",
    "finishedProcessingAt": "2026-07-02T13:15:43.475259Z"
}
```

For a description of each state and retry behavior, see [batch states](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/profile-import-errors-and-troubleshooting.html#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](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/profile-import-api.html#get-batch-statistics) to get a high-level overview of the import:

```bash
curl "{base_url}/v1/batches/7266232b-a7d4-496c-b0b3-be8dbde7495a/stats" \
  -H "Authorization: ApiKey <your-api-key>"
```

The response includes a summary of the import:

```json
{
    "batchId": "7266232b-a7d4-496c-b0b3-be8dbde7495a",
    "status": "COMPLETED_WITH_ERRORS",
    "checksumMd5": "01556b1dcc2b3cb87889838ee349357a",
    "fileSizeBytes": 1873,
    "totalRecords": 12,
    "succeededRecords": 6,
    "createdRecords": 3,
    "updatedRecords": 3,
    "failedRecords": 6,
    "failedByCode": {
        "INVALID_RECORD": {
            "count": 6,
            "firstRecordIndex": 6,
            "firstDescription": "No identifier with a valid id and a recognised provider"
        }
    },
    "processingTimeSeconds": 64,
    "createdBy": "joby@example.com",
    "createdAt": "2026-07-02T13:14:36.546433Z",
    "startedProcessingAt": "2026-07-02T13:14:39.064400Z",
    "finishedProcessingAt": "2026-07-02T13:15:43.475259Z"
}
```

You can also [download the results](https://doc.sitecore.com/sai/en/developers/sitecoreai/profile-import/profile-import-api.html#download-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.
