> ## Documentation Index
> Fetch the complete documentation index at: https://nuntly.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Import contacts

> Import contacts from a CSV file in the dashboard or through the API. Map columns to the email, the unsubscribed flag, and properties, then follow the import.

An import adds or updates many contacts from one CSV file. You can start it [from the dashboard](#from-the-dashboard) or through the API. Through the API, you create the import, upload the file to the URL it returns, then read the import until it reaches a final status. Nuntly processes the file in the background and writes the contacts in batches.

> [!NOTE]
>
> Through the API, creating an import needs an API key with write access to the `contact` permission resource, and reading imports needs read access. See [Set up Broadcast](https://nuntly.com/docs/guides/broadcast-setup.md#api-key-permissions).

## How an import works

**1. Create the import**

`POST /contacts/imports` records your options and returns an upload URL with signed form fields. The upload URL stops accepting files 10 minutes after creation.

**2. Upload the file**

Post the CSV file to the upload URL as a multipart form, at most 20 MB.

**3. Follow the import**

`GET /contacts/imports/{importId}` returns the status and the row counters. Read it until the status is `completed`, `failed`, `expired`, or `canceled`.

## From the dashboard

In the dashboard, open **Broadcast** > **Contacts** and click **Import CSV**. The page creates the same import as the API, always with an explicit [column mapping](#map-the-columns). The rest of this guide applies to it: the file rules, what each row does, segments, topics, and unsubscribes.

The page has two tabs: **New import** holds the form, and **History** lists the [imports](#import-history). The form has five steps, **File**, **Preview in your browser**, **Columns**, **Targets and consent**, and **Start**, shown in a row at the top, with the current step's content below. **Continue** opens the next step once the current one is complete; **Back** opens the step before. A completed step in the row opens again on click. **Back** on the **Preview in your browser** step shows the drop area again, to choose another file.

**1. Drop the file**

Drop one CSV file, or click **Choose a file**. Nothing from the file leaves your browser until you start the import. The page moves on to the file's preview.

**2. Check the preview**

The **Preview in your browser** step shows the file's columns and first three data rows, then counts the data rows and the rows that will be unsubscribed. Click **Continue**.

**3. Pick a target for each column**

Each column gets a suggested target under **Import as**: **Email**, **Unsubscribed**, one of your contact properties, **Create property**, or **Ignore**. Change any suggestion; pick **Ignore** to leave a column out. **Create property** opens a small panel with **Property name** and **Type** (String or Number); the pencil button next to the target opens it again. Click **Continue**.

**4. Choose the targets and confirm consent**

Pick segments under **Add to segments**, topics under **Subscribe to**, and, under **Existing contacts**, **Update existing contacts** (`upsert`, the default) or **Leave existing contacts unchanged** (`skip`). Then check the [consent box](#consent) and click **Continue**.

**5. Start the import**

The last step summarizes the file, the columns, the targets, and the consent, each with an **Edit** link to its step. Click **Start import**. The page creates the properties marked **Create property**, creates the import, then uploads the file, and asks before you leave while the upload runs. Once storage confirms the upload, the page clears the file, the mapping, and the consent, and switches to the **History** tab, where the import is the top entry. The targets stay for your next import.

### Suggested targets

A column matches a target when their names are equal once lowercased, with every character other than an ASCII letter or digit removed. `First Name`, `first-name`, and `FIRSTNAME` all match the property `first_name`.

* `email`, `e-mail`, `mail`, and `email address` suggest **Email**; `unsubscribed`, `unsubscribe`, and `opted_out` suggest **Unsubscribed**. Both win over a property with the same name.
* A column matching one of your properties suggests that property. A second import of the same export reuses the properties the first one created.
* A column matching nothing suggests **Create property**, type String, with a name built from its header. The header is lowercased, each run of characters other than ASCII letters, digits, and `_` becomes one `_`, and leading or trailing `_` are removed. `Date d'inscription` becomes `date_d_inscription`.
* Each target, a property to create included, is suggested for the leftmost matching column only. A later column with no other free match starts on **Ignore**.
* A header matching nothing that cannot be a property name, such as `id`, `2024`, or `Имя`, starts on **Ignore**. Pick **Create property** and type a name to import it.
* A header that looks like an email address starts on **Ignore**: the file probably has no header row.
* When your existing properties cannot be loaded, the columns table stays disabled until **Load again** succeeds.

### What blocks the start

The page does not let you start, and says why next to the cause, when the import would certainly fail or be refused. A file or column problem keeps that step's **Continue** disabled, and you on that step, until you fix it. This happens, for example, when:

* the file is empty or larger than 20 MB, is not UTF-8, has a quoting error, or has more than 256 columns,
* no column is mapped to **Email**, or two columns are mapped to the same target (**Mapped twice: pick one**),
* a mapped header appears twice in the file,
* a property to create has a name that is not allowed.

When the properties to create would take your organization past 50 properties, the **Columns** step's **Continue** stays disabled and says how many to leave out.

Two blocks are specific to the dashboard. A mapped column whose header looks like an email address means the file has no header row: add one and drop the file again. A property to create named exactly like an existing property is refused: pick the existing property instead.

Warnings do not block the start. They count the rows that will fail, those with:

* an unsubscribed value that is not [accepted](#cell-values),
* a value that is not a number in a Number column,
* an email address that cannot be used,
* a different number of columns than the header.

Do not map a `Status` column holding `subscribed` or `unsubscribed` to **Unsubscribed**: neither value is [accepted](#cell-values), so every row holding one fails. A header with a semicolon or a tab and no comma also warns: export the file again as CSV UTF-8, comma-separated.

Your browser computes the preview counts. When they differ from the import's counters in the **History** tab, the counters show what the import wrote.

### Consent

The **Continue** to the start step stays disabled until you check this box:

> I confirm that every contact in this file agreed to receive email from my organization, and that none of them come from a purchased, rented or third-party list.

It links to the prohibited uses in the [Terms of Service](https://nuntly.com/legal/terms-of-service#prohibited), and resets for every new file. The import records the member who started it in `initiator`, and when they confirmed consent in `consentConfirmedAt`. See [Create an import](#create-an-import).

### When the start does not finish

* When the page created properties and then failed to create the import, it keeps those properties and lists them. Their rows now target the created properties, so a new start does not create them again.
* A refused upload, or a tab closed during the upload, leaves the import **Waiting for file** until it expires on its own. Start again to create a new import.
* When storage gives no usable answer, the page cannot confirm the upload and asks you to check the import in the **History** tab before starting again. If that import received the file, a second start imports it a second time.
* When the answer to the import creation is lost, the page cannot confirm the start and asks you to check the **History** tab. The properties to create may already exist.

### Import history

The **History** tab lists your organization's imports, from the dashboard and from the API, newest first. **Load older** shows older ones. Each entry shows its status, creation time, origin (**Dashboard** or **API**), row counters, and, for a failed import, its reason. Select an entry for its detail: counters, [unresolved references](#deleted-segments-topics-and-properties), options, file size and received time, and start and finish times.

While an import is unfinished, its entry and the open detail refresh every 5 seconds, as long as the **History** tab is shown and the page is visible. The statuses are those of the API: see [Statuses](#statuses). After the page uploads a file, its import shows **File received, starting soon** until processing starts, or **Waiting for file** once you reload the page.

## Create an import

Send `Idempotency-Key` on every creation. See [Retries and idempotency](#retries-and-idempotency).

```bash theme={null}
curl -X POST https://api.nuntly.com/contacts/imports \
  -H 'Authorization: Bearer ntly_your_api_key_here' \
  -H 'Content-Type: application/json' \
  -H 'Idempotency-Key: 7c9e6679-7425-40de-944b-e07fc1f90ae7' \
  -d '{
    "onConflict": "upsert",
    "declaredFileSize": 48213,
    "columnMapping": {
      "E-mail": { "type": "email" },
      "Unsubscribed": { "type": "unsubscribed" },
      "Plan": { "type": "property", "name": "plan" }
    },
    "segments": [{ "id": "seg_01kabn43yqyxn2bx4ve84mczd3" }],
    "topics": [{ "id": "tpc_01kabn43yqyxn2bx4ve84mczd3", "state": "subscribed" }]
  }'
```

Every option is optional. An empty body `{}` creates an import with the defaults below.

| Option | Default | Description |
| - | - | - |
| `onConflict` | `upsert` | What a row does when its address belongs to an existing contact: `upsert` updates the contact, `skip` leaves it unchanged. See [What each row does](#what-each-row-does). |
| `format` | `csv` | The file format. `csv` is the only value. |
| `declaredFileSize` | none | The size of the file you will upload, in bytes, from 1 to 20,971,520. When you set it, the upload URL refuses a larger file. |
| `columnMapping` | none | Maps headers of the file to the email, the unsubscribed flag, or contact properties. Without it, headers are matched by name. See [Map the columns](#map-the-columns). |
| `segments` | `[]` | Up to 25 segments. Created and updated contacts are added to each of them. |
| `topics` | `[]` | Up to 25 topic states, each `subscribed` or `unsubscribed`, applied to the contact of every row that does not fail. |

The response is `201` with the import and three fields that only the creation returns:

```json theme={null}
{
  "data": {
    "id": "ctimp_01kabn43yqyxn2bx4ve84mczd3",
    "status": "awaiting_upload",
    "failureReason": null,
    "onConflict": "upsert",
    "format": "csv",
    "declaredFileSize": 48213,
    "file": null,
    "rows": { "total": null, "created": 0, "updated": 0, "skipped": 0, "failed": 0 },
    "unresolvedReferences": [],
    "uploadUrl": "<upload URL>",
    "uploadFormFields": { "<field name>": "<field value>" },
    "expiresAt": "2026-11-23T10:10:00.000Z",
    "createdAt": "2026-11-23T10:00:00.000Z"
  }
}
```

The example leaves out some fields. The import also echoes your options and carries `initiator`, `consentConfirmedAt`, `processingStartedAt`, `finishedAt`, and `updatedAt`.

`initiator` says who created the import. An import created through the API has `initiator.type` `api_key`, the id of the calling key, and `consentConfirmedAt` `null`. Retrieve and list also return imports started [from the dashboard](#from-the-dashboard), with `initiator.type` `user` and the id of the member who started it. Their `consentConfirmedAt` is the time that member confirmed [consent](#consent). A creation body cannot set either field.

The creation fails with `422` and creates nothing when an option is invalid, for example:

* a segment or topic id that your organization does not hold,
* a topic listed twice with two different states,
* a mapping with no header, or with two headers, mapped to the email,
* a mapping that maps two headers to the same target,
* a mapping with a header that is `__proto__` once surrounding whitespace is removed. That name is reserved, so rename the column in your file,
* a mapped property name that matches none of your contact properties. A name that differs from an existing property only by letter case is refused with `contact_property_name_case_mismatch`, which names the property to use, as on a contact creation.

## Upload the file

Post the file to `uploadUrl` as `multipart/form-data`:

* Copy every entry of `uploadFormFields` as a form field, unchanged, and add no other field.
* Add the file last, in a field named `file`. Fields placed after it are ignored.
* Do not send your API key. The signed fields authorize this one upload.
* Upload before `expiresAt`, 10 minutes after creation. The file must hold 1 byte to 20 MB, or at most `declaredFileSize` when you set it.

```bash curl theme={null}
# import.json holds the creation response.
fields=()
while IFS= read -r field; do
  fields+=(--form-string "$field")
done < <(jq -r '.data.uploadFormFields | to_entries[] | "\(.key)=\(.value)"' import.json)

curl -X POST "$(jq -r '.data.uploadUrl' import.json)" \
  "${fields[@]}" \
  -F 'file=@contacts.csv;type=text/csv'
```

```typescript TypeScript theme={null}
import { readFile } from 'node:fs/promises';

// `created` is the `data` object of the creation response.
const form = new FormData();
for (const [name, value] of Object.entries(created.uploadFormFields)) {
  form.append(name, value);
}
form.append('file', new Blob([await readFile('contacts.csv')], { type: 'text/csv' }), 'contacts.csv');

const upload = await fetch(created.uploadUrl, { method: 'POST', body: form });
if (!upload.ok) {
  throw new Error(`Upload refused with ${upload.status}`);
}
```

A `2xx` response means the file is stored. A file above the size limit, or an upload after `expiresAt`, is refused with a `4xx` response, and the import stays `awaiting_upload` until it expires. To upload again, create a new import.

Each import reads one file: the first one stored through its upload URL. A second file posted to the same URL is never read. To import a corrected file, create a new import.

## Follow the import

```bash theme={null}
curl https://api.nuntly.com/contacts/imports/ctimp_01kabn43yqyxn2bx4ve84mczd3 \
  -H 'Authorization: Bearer ntly_your_api_key_here'
```

Read the import every few seconds until its status is final. While it is `processing`, contacts are written in batches: the contacts of every finished batch are visible through the API, and `rows` counts them.

| Field | Description |
| - | - |
| `rows.total` | The number of data rows in the file, without the header and blank lines. `null` until the file structure is checked. |
| `rows.created`, `rows.updated`, `rows.skipped`, `rows.failed` | Rows written so far, per outcome. Their sum is the progress, and equals `rows.total` once the import is `completed`. |
| `file` | The received file: `receivedAt`, `size`, and `sha256`. `null` until processing starts. `sha256` stays `null` until the whole file is read. |
| `unresolvedReferences` | Segments, topics, or properties of your options that no longer existed during processing. See [Deleted segments, topics, and properties](#deleted-segments-topics-and-properties). |
| `failureReason` | Why the import failed. `null` unless the status is `failed`. |

`GET /contacts/imports` lists the imports of your organization, newest first, with the `limit` and `cursor` pagination of the other list endpoints. Neither endpoint returns the upload URL again.

### Statuses

| Status | Dashboard | Final | Meaning |
| - | - | - | - |
| `awaiting_upload` | Waiting for file | No | Created. Nuntly waits for the file. |
| `processing` | Processing | No | The file arrived and its rows are being written. |
| `completed` | Completed | Yes | Every row was handled. Some rows may have failed: check `rows.failed`. |
| `failed` | Failed | Yes | The import stopped. `failureReason` says why. |
| `expired` | Expired | Yes | No file arrived. An import moves to `expired` a few minutes after `expiresAt`, and writes nothing. |
| `canceled` | Canceled | Yes | The file arrived while your organization was disabled. Nothing was read or written. |

You cannot cancel an import, from the dashboard or through the API, and a final status never changes.

### Failure reasons

| `failureReason` | Dashboard | Meaning | What was written |
| - | - | - | - |
| `file_too_large` | The file is larger than 20 MB | The file is larger than 20 MB. | Nothing. |
| `invalid_format` | The file could not be read as a CSV: UTF-8, comma-separated, with a header row and an email column | The file is not a CSV file that Nuntly can read. See [Prepare the file](#prepare-the-file). | Nothing. The whole file is checked before any row is written. |
| `processing_timeout` | The import ran out of time; contacts already written are kept | Processing did not finish within its time limit, or the file could no longer be read. | The batches finished before it stopped. `rows` counts them. |

To write the remaining rows after a `processing_timeout`, create a new import with the same file. Rows that were already written then count as `updated` under `upsert`, or as `skipped` under `skip`.

## Prepare the file

The file must be:

* UTF-8, with or without a byte order mark,
* comma-separated, with a header row, and fields quoted with double quotes when they hold a comma, a quote, or a line break,
* at most 256 columns,
* at most 20 MB.

Lines can end with LF or CRLF. A completely empty line is ignored. A line of commas is a row with an empty email cell, which fails.

The import fails with `invalid_format`, writing nothing, when the file has no header row, holds an invalid UTF-8 byte, has an unterminated quoted field, has more than 256 columns, or uses another delimiter such as a semicolon or a tab. A header-only file completes with every counter at zero.

### Map the columns

Each column goes to one target: the email, the unsubscribed flag, or a contact property. Headers are compared after removing surrounding whitespace, and letter case counts.

**Without `columnMapping`**, headers are matched by name:

* a header `email` goes to the email, and a header `unsubscribed` to the unsubscribed flag,
* a header equal to the exact name of one of your [contact properties](https://nuntly.com/docs/guides/broadcast-segments.md#contact-properties) goes to that property,
* every other column is ignored, including columns with an empty header.

The import fails with `invalid_format` when no header is `email`, when two non-empty headers are identical, or when a header matches both a field name (`email` or `unsubscribed`) and a property name. A header `Email` does not match: use a mapping for headers that differ from the target names.

Do not create or delete contact properties while an import without `columnMapping` is processing. Headers are matched to your properties again each time processing resumes, so a change can leave a column filled for only part of the file.

**With `columnMapping`**, only the mapped headers are read, and nothing is matched by name. Exactly one header maps to `{ "type": "email" }`. The others map to `{ "type": "unsubscribed" }` or to `{ "type": "property", "name": "<exact property name>" }`, each target at most once. The import fails with `invalid_format` when a mapped header is missing from the file or appears twice. A mapped unsubscribed column that is missing from the file fails the import too, so those contacts are never imported as subscribed.

### Cell values

| Target | Accepted values |
| - | - |
| Email | Surrounding whitespace is removed and the address is lowercased, then checked as on a contact creation. |
| String property | Stored as written, letter case and inner spaces kept. |
| Number property | A plain decimal after removing surrounding whitespace: an optional leading `-`, digits, and an optional `.` followed by digits, with at most 15 significant digits. `007` reads as 7. `.5`, `5.`, `+5`, `1e3`, `1,000`, and `1,5` are refused. |
| Unsubscribed | True: `true`, `yes`, `y`, `1`. False: `false`, `no`, `n`, `0`. Letter case is ignored. An empty cell changes nothing. |

The number rule is stricter than the contact API on purpose: every accepted value is stored exactly.

## What each row does

Rows are handled in file order. Each row gets one outcome:

| Outcome | When |
| - | - |
| `created` | Your organization holds no contact with the row's address. |
| `updated` | A contact with that address exists and `onConflict` is `upsert`. |
| `skipped` | A contact with that address exists and `onConflict` is `skip`. |
| `failed` | The row is invalid. It writes nothing. |

A created contact gets the row's non-empty values, and a property left empty gets its default value when its definition has one. An updated contact gets the row's non-empty values too, but an empty cell keeps the stored value: an import never removes a property value.

Several rows for one address follow the same rules, in file order. The first row creates the contact. Under `upsert` the next rows update it, so the last non-empty value wins; under `skip` they are skipped. The counters count rows, not contacts.

Two imports running at the same time can write the same contact. The values of the batch written last stand.

### Failed rows write nothing

A row fails when:

* its email cell is empty or is not a valid email address,
* a value does not fit its property type, such as `abc` for a number property, or holds a character that cannot be stored, such as a null byte,
* its values would exceed the property limits of a contact,
* it has more or fewer fields than the header,
* its unsubscribed value is not one of the accepted values.

A failed row writes nothing at all: no contact, no property value, no unsubscribe, no topic state, and no segment membership. The other rows of the file are still written.

Watch for this with unsubscribes: when a row for an existing contact says `unsubscribed` = `true` but fails on another cell, the contact stays subscribed until you fix the row and import it again.

## Segments and topics

Created and updated contacts join every segment listed in `segments`. Skipped and failed rows add nobody, and a contact that is already a member stays one.

Each topic state in `topics` applies to the contact of every created, updated, or skipped row, whatever the row's unsubscribed value. The file has no per-row topic column.

| State | Effect |
| - | - |
| `unsubscribed` | Sets the contact's state for that topic to `unsubscribed`. |
| `subscribed` | Records a subscription only for a contact with no record for that topic. It never changes an `unsubscribed` record. See [Topics](https://nuntly.com/docs/guides/broadcast-segments.md#topics). |

## Unsubscribes, bounces, and complaints

A row whose unsubscribed value is true records an [unsubscribe](https://nuntly.com/docs/guides/broadcast-unsubscribe.md#what-an-unsubscribe-changes) for its address, also when the row is `skipped`. It works like an unsubscribe through the link in a broadcast: the address is left out of every later broadcast and the unsubscribe stays when the contact is deleted. An address that already has an unsubscribe keeps it.

An import never resubscribes anyone. A false or empty unsubscribed value does not remove an existing unsubscribe, and a later row for the same address does not undo an unsubscribe written by an earlier row.

An import does not add addresses to the [suppression list](https://nuntly.com/docs/guides/broadcast-unsubscribe.md#suppression-list). When you move your list from another provider, map the addresses that provider marked as bounced, cleaned, or complained to the unsubscribed column with the value `true`. Otherwise they stay in your audience.

```csv theme={null}
email,unsubscribed,plan
ada@example.com,false,pro
bounced@example.com,true,free
complained@example.org,true,free
```

Some providers export unsubscribed, bounced, or complained addresses as a separate file, without an unsubscribed column. An import has no option to unsubscribe every row, and a topic set to `unsubscribed` changes that topic only. Add an `unsubscribed` column set to `true` on every row of that file, then import it. Import it before or after your main list: since an import never resubscribes anyone, the order does not matter.

```csv theme={null}
email,unsubscribed
left@example.com,true
bounced@example.com,true
```

## Deleted segments, topics, and properties

Your options are checked at creation, and every segment, topic, and property is looked up again while the rows are written. When one was deleted in between:

* a deleted segment or topic is skipped for the rest of the import,
* a deleted property's column is ignored for the rest of the import,
* the import still completes, and lists each of them in `unresolvedReferences` with its type and its id or name.

Without `columnMapping`, a property deleted just before processing resumes is no longer matched by name, so its column is ignored without being listed (see [Map the columns](#map-the-columns)).

A property deleted and created again with another type is checked against its current type. The options shown on the import never change after creation.

## Retries and idempotency

Send an [`Idempotency-Key`](https://nuntly.com/docs/guides/idempotency) header on every creation, and keep the key until you have the response.

| What happened | What to do |
| - | - |
| `500` response | Retry with the same key. Nothing was created and the key was cleared, so the retry creates the import. |
| No response (network error, timeout) | Retry with the same key and the same body. If the first request created the import, you get its first response again with the `Idempotent-Replayed: true` header, and your organization still holds one import. |
| `409` with `idempotency_key_in_progress` | The first request is still running. Wait a moment, then retry with the same key. |

A replayed response is the first response unchanged, including its upload URL and `expiresAt`, and the import as it was at creation. Before you upload with it:

1. Compare `expiresAt` with the current time. Before `expiresAt`, upload with the replayed fields.
2. After `expiresAt`, retrieve the import. If it is still `awaiting_upload`, create a new import with a new key and upload with the new response. The old import expires on its own and writes nothing.

## Imports and erasure requests

An import writes the rows of the file you uploaded, as you uploaded it. If you delete a contact after uploading a file that contains its address, the import can create that contact again when it processes the file. An import cannot be canceled once its file is uploaded, and it writes nothing later than 72 hours and 30 minutes after the upload. To honor an erasure request that arrives while an import is pending, wait until the import is `completed` or `failed`, then delete the contact. Better, remove the address from the file before you upload it. An import never removes an unsubscribe: if the person asked to stop receiving your emails, unsubscribe them. The unsubscribe stays in force even if the contact is deleted and later imported again. The uploaded file is never read more than 72 hours after its upload and is deleted within 7 days of upload.

See [Data retention](https://nuntly.com/docs/guides/data-retention.md#contact-import-files) for what the import keeps after its file is deleted.

## Next steps

> [card] [Contacts, segments, and topics](https://nuntly.com/docs/guides/broadcast-segments.md)
>
> Contact properties, segments, topics, and how recipients are chosen

> [card] [Unsubscribe and suppression](https://nuntly.com/docs/guides/broadcast-unsubscribe.md)
>
> What an unsubscribe changes and how the suppression list works

> [card] [Create and send a broadcast](https://nuntly.com/docs/guides/broadcast-sending.md)
>
> Send to your imported contacts

> [card] [Idempotency keys](https://nuntly.com/docs/guides/idempotency.md)
>
> Key format, replayed responses, and error codes


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.